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
This commit is contained in:
parent
a3210822ce
commit
ac9313e5a5
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user