예제 #1
0
	def __init__(self, config, sg_timer, sg_notify):
		self.config = config
		self.sg_timer = sg_timer
		self.sg_notify = sg_notify

		# send startup report
		if 'startup' in self.config:
			self.sg_notify.notify(self.config.startup, 'Stargate is now running', 'Stargate startup')

		# register for shutdown events
		if 'shutdown' in self.config:
			sg_signal.add_exit_listener(self.on_exit)

		# register for logger.exception
		if 'exception' in self.config:
			sg_signal.add_exception_listener(self.on_exception)
예제 #2
0
	def __init__(self, dbconfig, sg_events, sg_timer):
		sg_signal.add_exit_listener(self._checkpoint_all)
		sg_signal.add_hup_listener(self._checkpoint_all)
		self.sg_timer = sg_timer

		self._dbfilename = dbconfig.datafile
		self._conn = sqlite3.connect(self._dbfilename, check_same_thread = False)
		self._conn.row_factory = sqlite3.Row
		self._cursor = self._conn.cursor()
		self._version = 1
		self._init_schema()
		self._lock = threading.RLock()
		self._checkpoint_interval = float(dbconfig.checkpoint_interval)
		if self._checkpoint_interval > 0:
			self._install_periodic_checkpointer()
		sg_events.subscribe_all(self.on_device_event)