Chromium Code Reviews| Index: tools/archive_crash.py |
| =================================================================== |
| --- tools/archive_crash.py (revision 0) |
| +++ tools/archive_crash.py (revision 0) |
| @@ -0,0 +1,51 @@ |
| +#!/usr/bin/env python |
| +# |
| +# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +# for details. All rights reserved. Use of this source code is governed by a |
| +# BSD-style license that can be found in the LICENSE file. |
| +# |
| + |
| +# A script that copies a core file and binary to GCS |
| +# We expect the dumps to be located in /tmp/coredump_PID directory |
| +# After we copy out the core files we delete the dumps localy |
| + |
| +import os |
| +import shutil |
| +import sys |
| +import subprocess |
| +import tarfile |
| +import uuid |
| + |
| +GSC_FOLDER = 'dart-crashes' |
|
Bill Hesse
2014/01/29 07:01:52
Why is this GSC_FOLDER instead of GCS_FOLDER?
ricow1
2014/01/29 09:41:38
Unintentional, fixed
|
| + |
| +def CreateTarball(dir, tarname): |
| + print 'Creating tar file: %s' % (tarname) |
| + tar = tarfile.open(tarname, mode='w:gz') |
| + tar.add(dir) |
| + tar.close() |
| + |
| +def CopyToGCS(filename): |
| + gs_location = 'gs://%s/%s/' % (GSC_FOLDER, uuid.uuid4()) |
| + cmd = ['gsutil', 'cp', filename, gs_location] |
|
Bill Hesse
2014/01/29 07:01:52
So people (all non-google users? all non-buildbot
ricow1
2014/01/29 09:41:38
This script is _not_ called from tools/test.dart -
|
| + print 'Running command: %s' % (cmd) |
| + subprocess.check_call(cmd) |
| + archived_filename = '%s%s' % (gs_location, filename.split('/').pop()) |
| + print 'Dump now available in %s' % (archived_filename) |
| + |
| +def Main(): |
| + print 'Looking for crash dumps' |
| + num_dumps = 0 |
| + for v in os.listdir('/tmp'): |
| + if v.startswith('coredump'): |
| + fullpath = '/tmp/%s' % (v) |
| + if os.path.isdir(fullpath): |
| + num_dumps += 1 |
| + tarname = '%s.tar.gz' % fullpath |
| + CreateTarball(fullpath, tarname) |
| + CopyToGCS(tarname) |
| + os.unlink(tarname) |
|
Bill Hesse
2014/01/29 07:01:52
Will we not reach this if the gsutil command fails
ricow1
2014/01/29 09:41:38
Again, this is meant to be called on the bot, if w
|
| + shutil.rmtree(fullpath) |
| + print 'Found %s core dumps' % (num_dumps) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main()) |
| Property changes on: tools/archive_crash.py |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |
| Added: svn:executable |
| + * |