From ac9313e5a5af9e350d66c0ae628ca900c4cfc218 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 27 Jul 2015 13:33:30 -0400 Subject: [PATCH] add -n --name flag to worlddump We're worlddumping at success points in grenade, and it would be much handier to explain when that happens via a symbolic name in the filename. Add a --name option to worlddump to allow it. Change-Id: I644200fe08e404dc7ca2006478ae4e11ca020672 --- tools/worlddump.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/worlddump.py b/tools/worlddump.py index e4ba02b51c..926b4a1873 100755 --- a/tools/worlddump.py +++ b/tools/worlddump.py @@ -31,12 +31,19 @@ def get_options(): parser.add_argument('-d', '--dir', default='.', help='Output directory for worlddump') + parser.add_argument('-n', '--name', + default='', + help='Additional name to tag into file') return parser.parse_args() -def filename(dirname): +def filename(dirname, name=""): now = datetime.datetime.utcnow() - return os.path.join(dirname, now.strftime("worlddump-%Y-%m-%d-%H%M%S.txt")) + fmt = "worlddump-%Y-%m-%d-%H%M%S" + if name: + fmt += "-" + name + fmt += ".txt" + return os.path.join(dirname, now.strftime(fmt)) def warn(msg): @@ -125,7 +132,7 @@ def guru_meditation_report(): def main(): opts = get_options() - fname = filename(opts.dir) + fname = filename(opts.dir, opts.name) print "World dumping... see %s for details" % fname sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) with open(fname, 'w') as f: