Ejemplo n.º 1
0
	def do(self,action):
		allowed = self.getActions(self.state)
		if action not in allowed:
			logging.warning('Ignoring illegal action %s from %s',action,self.state.name)
		else:
			self.state = self.setState(allowed[action])
			logging.debug('Action "%s" enters the state %s',action,self.state.name)
Ejemplo n.º 2
0
	def start(self):
		# Our service name should already have been set in the global initialize() function.
		assert(self.service_name is not None)
		# Let the world know we are starting
		logging.info('Starting proxy as %s' % self.service_name)
		# TODO: add a monitor for our state transitions
		#archiving.addMonitor('state',[('value',data.unsigned)])
		# Tell the archiver about the data we provide
		archiving.start()
		# Perform any optional startup configuration
		try:
			sys.modules['__main__'].configure()
		except AttributeError:
			logging.debug('Proxy does not perform any startup configuration')
		# Initialize our state machine
		self.state = self.setState(self)
		logging.info('Started in state %s',self.state.name)
		# Start the main loop (this call never returns)
		twisted.internet.reactor.run()