Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | # Script for uploading to x20 as a dependency in the same way we use cloud |
| 7 | # storage. |
| 8 | |
| 9 | import optparse |
| 10 | import os |
| 11 | import shutil |
| 12 | import stat |
| 13 | import subprocess |
| 14 | import sys |
| 15 | import tarfile |
| 16 | import utils |
| 17 | |
Jeffrey van Gogh | 5dac448 | 2018-01-24 02:36:38 -0800 | [diff] [blame] | 18 | GMSCORE_DEPS = '/google/data/rw/teams/r8/deps' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 19 | |
| 20 | def parse_options(): |
| 21 | return optparse.OptionParser().parse_args() |
| 22 | |
Jean-Marie Henaff | 7a64eec | 2018-05-31 15:30:35 +0200 | [diff] [blame] | 23 | def uploadFile(filename, dest): |
| 24 | print 'Uploading to %s' % dest |
| 25 | shutil.copyfile(filename, dest) |
| 26 | subprocess.check_call(['chmod', '664', dest]) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 27 | |
| 28 | def Main(): |
| 29 | (options, args) = parse_options() |
| 30 | assert len(args) == 1 |
| 31 | name = args[0] |
| 32 | print 'Creating archive for %s' % name |
| 33 | if not name in os.listdir('.'): |
| 34 | print 'You must be standing directly below the directory you are uploading' |
| 35 | return 1 |
Jean-Marie Henaff | 7a64eec | 2018-05-31 15:30:35 +0200 | [diff] [blame] | 36 | filename = utils.create_archive(name) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 37 | sha1 = utils.get_sha1(filename) |
| 38 | dest = os.path.join(GMSCORE_DEPS, sha1) |
Jean-Marie Henaff | 7a64eec | 2018-05-31 15:30:35 +0200 | [diff] [blame] | 39 | uploadFile(filename, dest) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 40 | sha1_file = '%s.sha1' % filename |
| 41 | with open(sha1_file, 'w') as output: |
| 42 | output.write(sha1) |
| 43 | print 'Sha (%s) written to: %s' % (sha1, sha1_file) |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | sys.exit(Main()) |