Example #1
0
	def _job(self):
		try:
			self._set_pling()
			self._running = True
			while True:
				cmd = self.q.get()
	
				q = cmd[0]
				a = cmd[2] if len(cmd)>2 else None
				cmd = cmd[1]
				if cmd == "timeout":
					assert self._plinger is None
					q.put(None)
					return True
				elif cmd == "cancel":
					if self._plinger:
						self._plinger.cancel()
						self._plinger = None
					q.put(None)
					return False
				elif cmd == "update":
					q.put(None)
					self.end = a
					self._set_pling()
				elif cmd == "remain":
					q.put(unixtime(self.end)-unixtime(now(self.force)))
				else:
					q.put(RuntimeError('Unknown command: '+cmd))
		finally:
			q,self.q = self.q,None
			super(Waiter,self).delete()
			if q is not None:
				while not q.empty():
					q.get()[0].put(StopIteration())
Example #2
0
	def _set_pling(self):
		timeout = unixtime(self.end) - unixtime(now(self.force))
		if timeout <= 0.1:
			timeout = 0.1
		if self._plinger:
			self._plinger.cancel()
		self._plinger = callLater(self.force, timeout, self._pling)
Example #3
0
	def msg(self):
		return "update %s %d:%s" % (self.file.filename,int(unixtime(now())),":".join((str(x) for x in self.val)))
Example #4
0
def ttime():
	return time()-unixtime(startup)
Example #5
0
def ixtime(t=None,force=False):
	if t is None:
		t = now(force)
	r = unixtime(t)-unixtime(realStartup if force else startup)
	return "%.1f" % (r,)
Example #6
0
	def ixtime(t,_=None):
		return unixtime(t)
Example #7
0
	def value(self):
		if self._plinger is None:
			return None
		return unixtime(self.end)-unixtime(now(self.force))
Example #8
0
	def _set_pling(self):
		timeout = unixtime(self.end) - unixtime(now(self.force))
		if timeout <= 0.1:
			timeout = 0.1
		self.stop_job("_plinger")
		self.start_job("_plinger",self._pling, timeout)
Example #9
0
    def realSeconds(self):
        from homevent.times import unixtime, now

        return unixtime(now(True))
Example #10
0
    def seconds(self):
        from homevent.times import unixtime, now

        return unixtime(now())
Example #11
0
def realGetSeconds(self):
    from homevent.times import unixtime, now

    return self.getTime() - unixtime(now(True))