def info(self): if self.running not in ("off","error"): tm = unixdelta(self.next-now()) elif self.last is not None: tm = unixdelta(now()-self.last) else: tm = "never" return "%s %s" % (self.running,tm)
def weigth(self, mod=False): if self.value_tm is None: return None n = now() t = n-self.value_tm nt = self.total_tm+t nts = unixdelta(nt) if mod: self.total_tm = nt if nts == 0: ## called right after init'ing return 0 else: return unixdelta(t) / nts
def weigth(self, mod=False): if self.value_tm is None: return None n = now() t = n - self.value_tm nt = self.total_tm + t nts = unixdelta(nt) if mod: self.total_tm = nt if nts == 0: ## called right after init'ing return 0 else: return unixdelta(t) / nts
def weigth(self, mod=False): if self.value_tm is None: return None t = now() - self.value_tm nt = unixdelta(t) if nt == 0: ## called right after init'ing return 0 else: return 1 - (1 - self.p)**(nt / self.p_base)
def weigth(self, mod=False): if self.value_tm is None: return None t = now()-self.value_tm nt = unixdelta(t) if nt == 0: ## called right after init'ing return 0 else: return 1-(1-self.p)**(nt/self.p_base)
def time_int(self): if self.started_at is None: return None if not self.running.is_set(): delta = now() - self.started_at elif self.job: delta = self.started_at - now() else: delta = now() - self.started_at return unixdelta(delta)
def sleepUntil(force,delta): from moat.times import unixdelta,now,sleep if isinstance(delta,dt.datetime): delta = delta - now() if isinstance(delta,dt.timedelta): delta = unixdelta(delta) if delta < 0: # we're late delta = 0 # but let's hope not too late sleep(force,delta)
def sleepUntil(force, delta): from moat.times import unixdelta, now, sleep if isinstance(delta, dt.datetime): delta = delta - now() if isinstance(delta, dt.timedelta): delta = unixdelta(delta) if delta < 0: # we're late delta = 0 # but let's hope not too late sleep(force, delta)
def list(self): yield super(Timeslot,self) yield ("run",self.running) if self.interval is not None: yield ("interval"," ".join(str(x) for x in self.interval)) yield ("duration",self.duration) if self.last is not None: yield ("last",self.last) if self.next is not None: yield ("next",self.next) if self.slotter is not None: yield ("slot",(unixdelta(self.next-now()))/self.duration)
def time_name(self): if self.started_at is None: return "never" if not self.running.is_set(): delta = now() - self.started_at elif self.job: delta = self.started_at - now() else: delta = now() - self.started_at delta = unixdelta(delta) res = humandelta(delta) return u"‹"+res+"›"
def info(self): if self.total_samples == 0: return "(new)" return "%s %s" % (self._calc(), unixdelta(self.total_tm))
def msg(self): delta = unixdelta(self.timer.end-now(True)) if delta < 0.1: delta = 0.1 return "%s %d %d %.3f" % ("s" if self.val else "c", self.card,self.port,delta)
def msg(self): delta = unixdelta(self.timer.end - now(True)) if delta < 0.1: delta = 0.1 return "%s %d %d %.3f" % ("s" if self.val else "c", self.card, self.port, delta)