Exemplo n.º 1
0
 def duration(self, duration):
     """Assign a time limit to the job."""
     if isinstance(duration, str):
         time = parse_fsd(duration)
     elif isinstance(duration, datetime.timedelta):
         time = duration.total_seconds()
     elif isinstance(duration, (float, int)):
         time = float(duration)
     else:
         raise TypeError(
             "duration must be an int, float, string, or timedelta")
     if time < 0:
         raise ValueError("duration must not be negative")
     if math.isnan(time) or math.isinf(time):
         raise ValueError("duration must be a normal, finite value")
     self.setattr("system.duration", time)
Exemplo n.º 2
0
 def duration(self, duration):
     """
     Assign a time limit to the job.  The duration may be:
     - an int or float in seconds
     - a string in Flux Standard Duration
     - a python datetime.timedelta
     A duration of zero is interpreted as "not set".
     """
     if isinstance(duration, six.string_types):
         time = parse_fsd(duration)
     elif isinstance(duration, datetime.timedelta):
         time = duration.total_seconds()
     elif isinstance(duration, (float, int)):
         time = float(duration)
     else:
         raise TypeError("duration must be an int, float, string, or timedelta")
     if time < 0:
         raise ValueError("duration must not be negative")
     if math.isnan(time) or math.isinf(time):
         raise ValueError("duration must be a normal, finite value")
     self.setattr("system.duration", time)