Commit 267872ab authored by Yingjie Xu's avatar Yingjie Xu

Fix randomize delay behavior

Do not print multi-precision float number.
Add now option to simplify command line.
parent eae9e1e5
......@@ -118,6 +118,8 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
help="SlapOS configuration file.")
parser.add_argument("--maximal_delay", help="The maximal delay value in seconds. " \
"A negative value leads start immediately.")
parser.add_argument("--now", action="store_true", default=False,
help="Launch slapgrid without delay.")
# Parses arguments
if argument_tuple == ():
......@@ -219,9 +221,12 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
else:
signature_certificate_list = None
if option_dict["now"]:
maximal_delay = 0
else:
maximal_delay = float(option_dict.get("maximal_delay", "300"))
if maximal_delay > 0:
duration = maximal_delay * random()
duration = int(maximal_delay * random())
logging.info("Sleeping for %s seconds. To disable this feature, " \
"check maximal_delay parameter in manual." % duration)
time.sleep(duration)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment