예제 #1
0
파일: timeslot.py 프로젝트: pombreda/MoaT
	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)
예제 #2
0
파일: avg.py 프로젝트: smurfix/HomEvenT
	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
예제 #3
0
파일: avg.py 프로젝트: smurfix/HomEvenT
	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)
예제 #4
0
파일: twist.py 프로젝트: pombreda/MoaT
def sleepUntil(force,delta):
	from homevent.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)
예제 #5
0
파일: timeslot.py 프로젝트: pombreda/MoaT
	def list(self):
		yield ("name"," ".join(unicode(x) for x in self.name))
		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)
예제 #6
0
파일: monitor.py 프로젝트: smurfix/HomEvenT
	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+"›"
예제 #7
0
파일: twist.py 프로젝트: smurfix/HomEvenT
def sleepUntil(force,delta):
	from homevent.times import unixdelta,now

	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

	if "HOMEVENT_TEST" in os.environ:
		ev = AsyncResult()
		callLater(force,delta, ev.set,None)
		ev.get(block=True)
	else:
		gevent.sleep(delta)
예제 #8
0
파일: twist.py 프로젝트: smurfix/HomEvenT
def callLater(force,delta,p,*a,**k):
	from homevent.times import unixdelta,now

	if isinstance(delta,dt.datetime):
		delta = delta - now(force)
	if isinstance(delta,dt.timedelta):
		delta = unixdelta(delta)
	if delta < 0: # we're late
		delta = 0 # but let's hope not too late
	if "HOMEVENT_TEST" in os.environ:
		if force:
			cl = DelayedCall
			delta += reactor.realSeconds()
		else:
			from homevent.testreactor import FakeDelayedCall
			cl = FakeDelayedCall
			delta += reactor.seconds()
	else:
		cl = DelayedCall
		delta += reactor.seconds()
	cl = cl(reactor,delta, gevent.spawn,(p,)+a,k,seconds=reactor.seconds)

	return reactor.callLater(cl)
예제 #9
0
파일: avg.py 프로젝트: smurfix/HomEvenT
	def info(self):
		if self.total_tm is None:
			return "(new)"
		return "%s %s" % (self._calc(), unixdelta(self.total_tm))