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
diff --git a/tools/worlddump.py b/tools/worlddump.py
index e4ba02b..926b4a1 100755
--- a/tools/worlddump.py
+++ b/tools/worlddump.py
@@ -31,12 +31,19 @@
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 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: