| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The LUCI Authors. All rights reserved. | 2 # Copyright 2017 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Utility exporting basic filesystem operations. | 6 """Utility exporting basic filesystem operations. |
| 7 | 7 |
| 8 This file was cut from "scripts/common/chromium_utils.py" at: | 8 This file was cut from "scripts/common/chromium_utils.py" at: |
| 9 91310531c31fa645256b4fb5d44b460c42b3e151 | 9 91310531c31fa645256b4fb5d44b460c42b3e151 |
| 10 """ | 10 """ |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if not os.path.isdir(dest): | 147 if not os.path.isdir(dest): |
| 148 if os.path.exists(dest): | 148 if os.path.exists(dest): |
| 149 raise OSError(errno.EEXIST, os.strerror(errno.EEXIST)) | 149 raise OSError(errno.EEXIST, os.strerror(errno.EEXIST)) |
| 150 os.makedirs(dest, mode) | 150 os.makedirs(dest, mode) |
| 151 | 151 |
| 152 | 152 |
| 153 def _Glob(base, pattern): | 153 def _Glob(base, pattern): |
| 154 cwd = os.getcwd() | 154 cwd = os.getcwd() |
| 155 try: | 155 try: |
| 156 os.chdir(base) | 156 os.chdir(base) |
| 157 print('\n'.join(sorted(glob.glob(pattern)))) | 157 hits = glob.glob(pattern) |
| 158 if hits: |
| 159 print('\n'.join(sorted(hits))) |
| 158 finally: | 160 finally: |
| 159 os.chdir(cwd) | 161 os.chdir(cwd) |
| 160 | 162 |
| 161 | 163 |
| 162 def _Remove(path): | 164 def _Remove(path): |
| 163 try: | 165 try: |
| 164 os.remove(path) | 166 os.remove(path) |
| 165 except OSError as e: | 167 except OSError as e: |
| 166 if e.errno != errno.ENOENT: | 168 if e.errno != errno.ENOENT: |
| 167 raise | 169 raise |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 data['message'] = 'UNKNOWN: %s' % e | 271 data['message'] = 'UNKNOWN: %s' % e |
| 270 | 272 |
| 271 with opts.json_output: | 273 with opts.json_output: |
| 272 json.dump(data, opts.json_output) | 274 json.dump(data, opts.json_output) |
| 273 | 275 |
| 274 return 0 | 276 return 0 |
| 275 | 277 |
| 276 | 278 |
| 277 if __name__ == '__main__': | 279 if __name__ == '__main__': |
| 278 sys.exit(main(sys.argv[1:])) | 280 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |