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): ...@@ -118,6 +118,8 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
help="SlapOS configuration file.") help="SlapOS configuration file.")
parser.add_argument("--maximal_delay", help="The maximal delay value in seconds. " \ parser.add_argument("--maximal_delay", help="The maximal delay value in seconds. " \
"A negative value leads start immediately.") "A negative value leads start immediately.")
parser.add_argument("--now", action="store_true", default=False,
help="Launch slapgrid without delay.")
# Parses arguments # Parses arguments
if argument_tuple == (): if argument_tuple == ():
...@@ -219,9 +221,12 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple): ...@@ -219,9 +221,12 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
else: else:
signature_certificate_list = None signature_certificate_list = None
maximal_delay = float(option_dict.get("maximal_delay", "300")) if option_dict["now"]:
maximal_delay = 0
else:
maximal_delay = float(option_dict.get("maximal_delay", "300"))
if maximal_delay > 0: if maximal_delay > 0:
duration = maximal_delay * random() duration = int(maximal_delay * random())
logging.info("Sleeping for %s seconds. To disable this feature, " \ logging.info("Sleeping for %s seconds. To disable this feature, " \
"check maximal_delay parameter in manual." % duration) "check maximal_delay parameter in manual." % duration)
time.sleep(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