Ejemplo n.º 1
0
	def test_file_monitor(self):
		"""Tests the file monitor by printing on screen the tasks that would be created. ToDo: automatically verify this output."""
		obs = schedule_observer(testing=True)
		obs.start()
		try:
			new_file_loc =os.path.join(EXAMPLE_FILES_LOCATION, 'test')
			#create
			with open(new_file_loc, 'w') as new_file:
				pass
			time.sleep(1)
			#modify
			with open(new_file_loc, 'w') as new_file:
				new_file.write('Hello!!!!!!!!!!!!!!')
			time.sleep(1)
			#delete, create
			ch_file_loc = os.path.join(EXAMPLE_FILES_LOCATION, 'still_test')
			os.rename(new_file_loc, ch_file_loc)
			time.sleep(1)
			#delete
			os.remove(ch_file_loc)
			time.sleep(1)
		except KeyboardInterrupt:
			pass
		finally:
			obs.stop()
			obs.join()
Ejemplo n.º 2
0

hard_check_files()


# FLASK
flask_app = create_flask(FLASK_CONFIG, DATABASE_CONFIG)


def run_server():
    flask_app.run()


server = Process(target=run_server)


# START
obs = schedule_observer()
obs.start()
server.start()

try:
    while True:
        time.sleep(60 * 60)
        hard_check_files()
except KeyboardInterrupt:
    obs.stop()
    server.terminate()
obs.join()
server.join()