diff --git a/binarycpython/utils/HPC.py b/binarycpython/utils/HPC.py index f91807df133c41928b91f34a6e66622cab8679f9..6fc011d3a8e3f8f3ce348720fed5a800b3c81450 100644 --- a/binarycpython/utils/HPC.py +++ b/binarycpython/utils/HPC.py @@ -228,7 +228,7 @@ class HPC(condor,slurm): """ id = self.HPC_jobID() - if id.startswith('None'): + if id is None or id.startswith('None'): t = [None,None] elif self.HPC_job(): print("JOBID",id) diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index bcd8861a76fec580071f7ed0e60e802fe11f1f7d..75dc6439d9e1c8fccbfdbc36d6c924257eb425f3 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -1340,7 +1340,7 @@ class Population(analytics, self.verbose_print( "Process {} started at {}.\tUsing store memaddr {}".format( ID, - datetime.datetime.now().isoformat(), + self.now(), self.grid_options["_store_memaddr"], ), self.grid_options["verbosity"], @@ -2250,7 +2250,7 @@ class Population(analytics, 3, ) - def now(self,style=None): + def now(self,style=None,specifier=None): """ convenience function to return a string of the current time, using the format "%m/%d/%Y %H:%M:%S" @@ -2258,15 +2258,16 @@ class Population(analytics, Args: style : if "nospace" then return the date/time with the format "%Y%m%d_%H%M%S" + + specifier: if set, uses this as a specifier rather than whatever is set by default or in the style variable """ - if style == 'nospace': - return datetime.datetime.strftime( - datetime.datetime.now(), - "%Y%m%d_%H%M%S" - ) - else: - return datetime.datetime.strftime( - datetime.datetime.now(), - "%m/%d/%Y %H:%M:%S" - ) + now = datetime.datetime.now() + if not specifier: + if style == 'nospace': + # special case + specifier = "%Y%m%d_%H%M%S" + else: + # our default + specifier = "%m/%d/%Y %H:%M:%S" + return datetime.datetime.strftime(now,specifier)