os.Environment, os.MachineCmd: Add --tag, --time-stamp

Add support for options --tag and --time-stamp to MachineCmd, and
store them in Environment.tag and .time_stamp, respectively.

.time_stamp defaults to current time if --time-stamp is not present.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2023-06-12 14:18:18 +02:00
commit dccb75246a
2 changed files with 8 additions and 1 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from datetime import datetime
#import dateutil.parser
from .Connections import Connections
from jwutils import Options
from jwutils.log import *
@ -14,7 +15,11 @@ class Environment:
for ft in self.features:
slog(INFO, " {}".format(ft))
self.cmd = cmd
self.time_stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
fmt = "%Y%m%d-%H%M%S"
#self.time_stamp = (datetime.now() if args.time_stamp is None else dateutil.parser.parse(args.time_stamp)).strftime("%Y%m%d-%H%M%S")
self.time_stamp = (datetime.now() if args.time_stamp is None else datetime.strptime(args.time_stamp, fmt)).strftime(fmt)
self.tag = args.tag
slog(INFO, "Tag = {}\n".format(self.tag))
self.connections = Connections()
for spec in args.connection:
self.connections.append(spec)

View file

@ -19,6 +19,8 @@ class MachineCmd(jwutils.Cmd): # export
p.add_argument( "--shutdown-timeout", help="Timeout for a machine to complete an ACPI shutdown request in ms", default=60000)
p.add_argument( "--poweroff-timeout", help="Timeout for a machine to complete a poweroff request in ms", default=100)
p.add_argument( "--features", help="Comma-separated list of features that are passed to the test cases for interpretation", default='')
p.add_argument( "--time-stamp", help="Time stamp used for output tagging and file names", default=None)
p.add_argument( "--tag", help="Tag used for output tagging and file names", default=None)
# TODO: Don't pollute list of generic machine options with Qemu specific stuff
p.add_argument("-R", "--root-part-number", help="Number of root partition (starting from 1)")