def next_execution(self) -> Time:
     time = self._latest_execution
     while time < Time.now():
         if time > self._last_execution:
             return Time.never()
         time += self._interval
     return time
    def __call__(self, target, sync=False, timeout=100) -> CommandResult:
        execute_subprocess(['etherwake', target.mac])
        result = CommandResult()
        start = Time.now()
        if sync:
            result.state = 'failed'
            while not target.status == 'UP' and Time.now() - start < timeout:
                pass

        if target.status == 'UP':
            result.state = 'successful'
        result.message = 'Ping returned after %(time)s seconds' % {'time': str(Time.now() - start)}
        return result
 def __call__(self, additional_args=list(), sync=False) -> CommandResult:
     result = CommandResult()
     args = self.args
     args.append(additional_args)
     args.insert(0, self.executable)
     pid = Popen(args, stdout=PIPE)
     result.state = 'running'
     result.message = 'Execution started at %(time)s\nStdout:\n' % {'time': Time.now()}
     if sync:
         pid.wait()
         result.message += pid.stdout.read().decode(getlocale()[1])
     return result
 def next_execution(self) -> Time:
     if self._execution_time < Time.now():
         return Time.never()
     return self._execution_time
 def __init__(self, creator: User, command: Command):
     self._creation_time = Time.now()
     self._creator = creator
     self._command = command