| OLD | NEW | 
|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 # | 2 # | 
| 3 # Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 3 # Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a | 
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. | 
| 6 # | 6 # | 
| 7 | 7 | 
| 8 # A script that copies a core file and binary to GCS | 8 # A script that copies a core file and binary to GCS | 
| 9 # We expect the dumps to be located in /tmp/coredump_PID directory | 9 # We expect the dumps to be located in /tmp/coredump_PID directory | 
| 10 # After we copy out the core files we delete the dumps localy | 10 # After we copy out the core files we delete the dumps localy | 
| 11 | 11 | 
| 12 import os | 12 import os | 
| 13 import shutil | 13 import shutil | 
| 14 import sys | 14 import sys | 
| 15 import subprocess | 15 import subprocess | 
| 16 import tarfile | 16 import tarfile | 
| 17 import utils | 17 import utils | 
| 18 import uuid | 18 import uuid | 
| 19 | 19 | 
| 20 GCS_FOLDER = 'dart-crashes' | 20 GCS_FOLDER = 'dart-crashes' | 
|  | 21 GSUTIL='/b/build/scripts/slave/gsutil' | 
| 21 | 22 | 
| 22 def CreateTarball(input_dir, tarname): | 23 def CreateTarball(input_dir, tarname): | 
| 23   print 'Creating tar file: %s' % tarname | 24   print 'Creating tar file: %s' % tarname | 
| 24   tar = tarfile.open(tarname, mode='w:gz') | 25   tar = tarfile.open(tarname, mode='w:gz') | 
| 25   tar.add(input_dir) | 26   tar.add(input_dir) | 
| 26   tar.close() | 27   tar.close() | 
| 27 | 28 | 
| 28 def CopyToGCS(filename): | 29 def CopyToGCS(filename): | 
| 29   gs_location = 'gs://%s/%s/' % (GCS_FOLDER, uuid.uuid4()) | 30   gs_location = 'gs://%s/%s/' % (GCS_FOLDER, uuid.uuid4()) | 
| 30   cmd = ['gsutil', 'cp', filename, gs_location] | 31   cmd = [GSUTIL, 'cp', filename, gs_location] | 
| 31   print 'Running command: %s' % cmd | 32   print 'Running command: %s' % cmd | 
| 32   subprocess.check_call(cmd) | 33   subprocess.check_call(cmd) | 
| 33   archived_filename = '%s%s' % (gs_location, filename.split('/').pop()) | 34   archived_filename = '%s%s' % (gs_location, filename.split('/').pop()) | 
| 34   print 'Dump now available in %s' % archived_filename | 35   print 'Dump now available in %s' % archived_filename | 
| 35 | 36 | 
| 36 def TEMPArchiveBuild(): | 37 def TEMPArchiveBuild(): | 
| 37   d = '/b/build/slave/vm-linux-debug-x64-asan-be/build/dart/out/DebugX64/dart' | 38   d = '/b/build/slave/vm-linux-debug-x64-asan-be/build/dart/out/DebugX64/dart' | 
| 38   CopyToGCS(d) | 39   CopyToGCS(d) | 
| 39 | 40 | 
| 40 def Main(): | 41 def Main(): | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 52         num_dumps += 1 | 53         num_dumps += 1 | 
| 53         tarname = '%s.tar.gz' % fullpath | 54         tarname = '%s.tar.gz' % fullpath | 
| 54         CreateTarball(fullpath, tarname) | 55         CreateTarball(fullpath, tarname) | 
| 55         CopyToGCS(tarname) | 56         CopyToGCS(tarname) | 
| 56         os.unlink(tarname) | 57         os.unlink(tarname) | 
| 57         shutil.rmtree(fullpath) | 58         shutil.rmtree(fullpath) | 
| 58   print 'Found %s core dumps' % num_dumps | 59   print 'Found %s core dumps' % num_dumps | 
| 59 | 60 | 
| 60 if __name__ == '__main__': | 61 if __name__ == '__main__': | 
| 61   sys.exit(Main()) | 62   sys.exit(Main()) | 
| OLD | NEW | 
|---|