Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: tools/archive_crash.py

Issue 350483003: Build Tools Cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more fixes as reviewed by ricow Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/android_link.py ('k') | tools/build.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21
22 def CreateTarball(dir, tarname): 22 def CreateTarball(input_dir, tarname):
23 print 'Creating tar file: %s' % (tarname) 23 print 'Creating tar file: %s' % tarname
24 tar = tarfile.open(tarname, mode='w:gz') 24 tar = tarfile.open(tarname, mode='w:gz')
25 tar.add(dir) 25 tar.add(input_dir)
26 tar.close() 26 tar.close()
27 27
28 def CopyToGCS(filename): 28 def CopyToGCS(filename):
29 gs_location = 'gs://%s/%s/' % (GCS_FOLDER, uuid.uuid4()) 29 gs_location = 'gs://%s/%s/' % (GCS_FOLDER, uuid.uuid4())
30 cmd = ['gsutil', 'cp', filename, gs_location] 30 cmd = ['gsutil', 'cp', filename, gs_location]
31 print 'Running command: %s' % (cmd) 31 print 'Running command: %s' % cmd
32 subprocess.check_call(cmd) 32 subprocess.check_call(cmd)
33 archived_filename = '%s%s' % (gs_location, filename.split('/').pop()) 33 archived_filename = '%s%s' % (gs_location, filename.split('/').pop())
34 print 'Dump now available in %s' % (archived_filename) 34 print 'Dump now available in %s' % archived_filename
35 35
36 def Main(): 36 def Main():
37 if utils.GuessOS() != 'linux': 37 if utils.GuessOS() != 'linux':
38 print 'Currently only archiving crash dumps on linux' 38 print 'Currently only archiving crash dumps on linux'
39 return 0 39 return 0
40 print 'Looking for crash dumps' 40 print 'Looking for crash dumps'
41 num_dumps = 0 41 num_dumps = 0
42 for v in os.listdir('/tmp'): 42 for v in os.listdir('/tmp'):
43 if v.startswith('coredump'): 43 if v.startswith('coredump'):
44 fullpath = '/tmp/%s' % (v) 44 fullpath = '/tmp/%s' % v
45 if os.path.isdir(fullpath): 45 if os.path.isdir(fullpath):
46 num_dumps += 1 46 num_dumps += 1
47 tarname = '%s.tar.gz' % fullpath 47 tarname = '%s.tar.gz' % fullpath
48 CreateTarball(fullpath, tarname) 48 CreateTarball(fullpath, tarname)
49 CopyToGCS(tarname) 49 CopyToGCS(tarname)
50 os.unlink(tarname) 50 os.unlink(tarname)
51 shutil.rmtree(fullpath) 51 shutil.rmtree(fullpath)
52 print 'Found %s core dumps' % (num_dumps) 52 print 'Found %s core dumps' % num_dumps
53 53
54 if __name__ == '__main__': 54 if __name__ == '__main__':
55 sys.exit(Main()) 55 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/android_link.py ('k') | tools/build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698