| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Upload DM output PNG files and JSON summary to Google Storage.""" | 6 """Upload DM output PNG files and JSON summary to Google Storage.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import datetime | 9 import datetime |
| 10 import os | 10 import os |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import gs_utils | 25 import gs_utils |
| 26 | 26 |
| 27 # Private, but Google-readable. | 27 # Private, but Google-readable. |
| 28 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE | 28 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE |
| 29 FINE_ACLS = [( | 29 FINE_ACLS = [( |
| 30 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN, | 30 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN, |
| 31 'google.com', | 31 'google.com', |
| 32 gs_utils.GSUtils.Permission.READ | 32 gs_utils.GSUtils.Permission.READ |
| 33 )] | 33 )] |
| 34 | 34 |
| 35 if not os.path.isfile(os.path.join(dm_dir, 'dm.json')): |
| 36 sys.exit("no dm.json file found in output directory.") |
| 37 |
| 35 # Move dm.json to its own directory to make uploading it easier. | 38 # Move dm.json to its own directory to make uploading it easier. |
| 36 tmp = tempfile.mkdtemp() | 39 tmp = tempfile.mkdtemp() |
| 37 shutil.move(os.path.join(dm_dir, 'dm.json'), | 40 shutil.move(os.path.join(dm_dir, 'dm.json'), |
| 38 os.path.join(tmp, 'dm.json')) | 41 os.path.join(tmp, 'dm.json')) |
| 39 | 42 |
| 40 # Only images are left in dm_dir. Upload any new ones. | 43 # Only images are left in dm_dir. Upload any new ones. |
| 41 gs = gs_utils.GSUtils() | 44 gs = gs_utils.GSUtils() |
| 42 gs.upload_dir_contents(dm_dir, | 45 gs.upload_dir_contents(dm_dir, |
| 43 'skia-android-dm', | 46 'skia-android-dm', |
| 44 'dm-images-v1', | 47 'dm-images-v1', |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 fine_grained_acl_list = FINE_ACLS) | 68 fine_grained_acl_list = FINE_ACLS) |
| 66 | 69 |
| 67 | 70 |
| 68 # Just for hygiene, put dm.json back. | 71 # Just for hygiene, put dm.json back. |
| 69 shutil.move(os.path.join(tmp, 'dm.json'), | 72 shutil.move(os.path.join(tmp, 'dm.json'), |
| 70 os.path.join(dm_dir, 'dm.json')) | 73 os.path.join(dm_dir, 'dm.json')) |
| 71 os.rmdir(tmp) | 74 os.rmdir(tmp) |
| 72 | 75 |
| 73 if '__main__' == __name__: | 76 if '__main__' == __name__: |
| 74 main(*sys.argv[1:]) | 77 main(*sys.argv[1:]) |
| OLD | NEW |