Example #1
0
	def run(self):
		"""Daemons main loop."""

		self.system_config = system_config.retrieve_config()	
		self.user_config = user_config.retrieve_config()	
		system_status.set_uptime_start()

		self.internet_test_time = external_resources.test_internet_connection()
		self.dropbox_test_time = external_resources.test_dropbox_connection()
		self.download_image_time = external_resources.sync_dropbox_images()

		while True:
			if not self.paused:
				self.check_task_timing()

			time.sleep(1)	
Example #2
0
	def check_task_timing(self):
		"""Checks if it is time to do tasks. 

		Checks if enough time has gone by to test internet connection, dropbox connection
		or to sync dropbox images. 

		"""

		current_time = time.time()
		internet_test_delta = math.floor(current_time - self.internet_test_time)
		dropbox_test_delta = math.floor(current_time - self.dropbox_test_time)
		download_image_delta = math.floor(current_time - self.download_image_time)

		if (internet_test_delta >= self.system_config.internet_test_wait):
			self.internet_test_time = external_resources.test_internet_connection()

		if (dropbox_test_delta >= (self.system_config.dropbox_test_wait * 60)):
			self.dropbox_test_time = external_resources.test_dropbox_connection()

		if (download_image_delta >= (self.user_config.image_download_wait * 60)):
			self.download_image_time = external_resources.sync_dropbox_images()