From 16db38e1cef4686e22a2314592b7fc761e5feb90 Mon Sep 17 00:00:00 2001 From: jimboid Date: Tue, 14 Jun 2016 10:00:50 +0100 Subject: [PATCH] modified revovery file writing and recovery method to support date and time stamp in the filename. This allows lots of Longbow instances to use the recovery facility. --- Longbow/corelibs/scheduling.py | 5 ++++- Longbow/longbow | 25 ++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Longbow/corelibs/scheduling.py b/Longbow/corelibs/scheduling.py index 5dbde7a..cb11004 100755 --- a/Longbow/corelibs/scheduling.py +++ b/Longbow/corelibs/scheduling.py @@ -284,7 +284,10 @@ def monitor(jobs): allfinished = False interval = 0 longbowdir = os.path.expanduser('~/.Longbow') - jobfile = os.path.join(longbowdir, "jobs.recovery") + jobfile = os.path.join(longbowdir, "recovery-", + time.strftime("%Y%m%d-%H%M%S")) + + LOG.info("recovery file will be placed at path '{0}'".format(jobfile)) # Find out which job has been set the highest polling frequency and use # that. diff --git a/Longbow/longbow b/Longbow/longbow index 1e1b0ad..7ec354b 100755 --- a/Longbow/longbow +++ b/Longbow/longbow @@ -163,7 +163,7 @@ def main(parameters): STAGING.cleanup(jobs) -def recover(): +def recover(recoveryfile): """ This method is for attempting to recover a Longbow session. This should be @@ -176,7 +176,7 @@ def recover(): LOG.info("Attempting to find the recovery files") longbowdir = os.path.expanduser('~/.Longbow') - jobfile = os.path.join(longbowdir, "jobs.recovery") + jobfile = os.path.join(longbowdir, recoveryfile) # Load the jobs recovery file. if os.path.isfile(jobfile): @@ -541,6 +541,25 @@ if __name__ == "__main__": RECOVER = True + try: + + POSITION = LONGBOWARGS.index("-recover") + + except ValueError: + + POSITION = LONGBOWARGS.index("--recover") + + if (POSITION + 1 == len(LONGBOWARGS) or + LONGBOWARGS[POSITION + 1].startswith("-")): + + raise EX.CommandlineargsError( + "Please specify a valid file for the --recover command line " + "parameter e.g. longbow --recover [filename] ...") + + else: + + RECOVERFILE = LONGBOWARGS[POSITION + 1] + # Store the VERBOSE parameter if (LONGBOWARGS.count("-verbose") == 1 or LONGBOWARGS.count("--verbose") == 1): @@ -790,7 +809,7 @@ if __name__ == "__main__": LOG.info("Entering recovery mode.") - recover() + recover(RECOVERFILE) except Exception as ERR: