Exemplo n.º 1
0
	def recv_keys(self, keys):
		self.shet.reset()
		for key in keys:
			code, name = key.split()
			
			self.shet.add_action(join("send", name), partial(self.send, name))
			
			on_command = self.shet.add_event(join("on_command", name))
			on_first_command = self.shet.add_event(join("on_first_command", name))
			self.events[name] = (on_command, on_first_command)
Exemplo n.º 2
0
	def list_full_paths(self, path='/'):
		path = path.rstrip('/')
		node = self.get_node(path)

		if not isinstance(node, DirectoryTree):
			return
		else:
			for name, sub_node in node.iteritems():
				if isinstance(sub_node, DirectoryTree):
					for sub_path in self.list_full_paths(shetpath.join(path,
					                                                  name)):
						yield shetpath.join(name,
						                   sub_path)
				else:
					yield name
Exemplo n.º 3
0
	def update_watches(self):
		# Remove all watches
		for watch in self.watches:
			self.unwatch_event(watch)
		self.watches = []
		
		# Add watches for each controller.
		for controller in self.controllers:
			self.watch_event(join(controller, "state_change"),
			                 partial(self.on_change, controller))
Exemplo n.º 4
0
	def __init__(self, root, timeout, override_timeout=60):
		self.root = root
		
		ShetClient.__init__(self)
		
		self.on_change = self.add_event("on_change")
		
		self.timer_path = join(root, "timer")
		self.override_timer_path = join(root, "override")
		
		Timer(self.timer_path, timeout).install()
		Timer(self.override_timer_path, override_timeout).install()
		
		EventToAction(join(root, "timer", "timed_out"), join(root, "timer", "turn_off")).install()
		
		self.watch_event("override/timed_out", self.finish_override)
		self.override = False
		self.state = False
		self.saved_state = False
		self.timer_turn_on()
Exemplo n.º 5
0
Arquivo: client.py Projeto: 18sg/SHET
	def relative_path(self, path):
		if path.startswith('/'):
			return path
		else:
			return shetpath.join(self.root, path)
Exemplo n.º 6
0
def setup_light(name, time):
	Aggregator(name, ["/lights/override", "override", "/lights/daylight", "timer"]).install()
	TimerController(join(name, "timer"), time, False).install()
	TimerController(join(name, "override"), 10*60, None).install()
Exemplo n.º 7
0
	def update_state(self, controller):
		d = self.call(join(controller, "get_state"))
		def callback(state):
			self.controller_states[controller] = state
		d.addCallback(callback)
		return d