Example #1
0
	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)
Example #2
0
File: avg.py Project: M-o-a-T/moat
	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
Example #3
0
 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
Example #4
0
 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)
Example #5
0
File: avg.py Project: M-o-a-T/moat
	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)
Example #6
0
	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)
Example #7
0
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)
Example #8
0
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)
Example #9
0
	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)
Example #10
0
	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+"›"
Example #11
0
 def info(self):
     if self.total_samples == 0:
         return "(new)"
     return "%s %s" % (self._calc(), unixdelta(self.total_tm))
Example #12
0
File: wago.py Project: smurfix/MoaT
	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)
Example #13
0
 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)
Example #14
0
File: avg.py Project: M-o-a-T/moat
	def info(self):
		if self.total_samples == 0:
			return "(new)"
		return "%s %s" % (self._calc(), unixdelta(self.total_tm))