From 869360824fbf4ff3aa01f6cf2373b6e1ed974487 Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Thu, 11 Jun 2020 19:36:56 -0400 Subject: [PATCH 1/8] started work on background service --- BackgroundService/bgservice.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 BackgroundService/bgservice.py diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py new file mode 100644 index 0000000..a92ae9a --- /dev/null +++ b/BackgroundService/bgservice.py @@ -0,0 +1,31 @@ +import os, sys +import time +import pyinotify + +start_time = None +edit_times = [] +end_time = None + + +def write_pid_file(): + pid = str(os.getpid()) + f = open('/tmp/skoolos_work_logger', 'w') + f.write(pid) + f.close() + + +def readable_time(input_time): + return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) + + +def start_service(dir_to_watch): + start_time = time.time() + + + +def Main(): + print("This does nothing right now...") + + +if __name__ == "__main__": + Main() From 73b0ce29085cca62b0d85f5d426c960130ab0bf7 Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Fri, 12 Jun 2020 19:45:00 -0400 Subject: [PATCH 2/8] implemented pyinotify module in bg service --- BackgroundService/bgservice.py | 44 ++++++++++++++------------ BackgroundService/event_processor.py | 46 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 BackgroundService/event_processor.py diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index a92ae9a..3ad361f 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -1,26 +1,30 @@ -import os, sys +import os +import sys +import signal import time -import pyinotify - -start_time = None -edit_times = [] -end_time = None +import event_processor -def write_pid_file(): - pid = str(os.getpid()) - f = open('/tmp/skoolos_work_logger', 'w') - f.write(pid) - f.close() - - -def readable_time(input_time): - return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) - - -def start_service(dir_to_watch): - start_time = time.time() - +class SkoolOSDaemmon: + """Constructor""" + def __init__(self, work_dir): + self.work_dir = work_dir + self.start_time = None + self.end_time = None + """Stores the pid of the program to be terminated externally""" + def write_pid_file(self): + pid = str(os.getpid()) + file_ = open('/tmp/skoolosdaemonpid', 'w') + file_.write(pid) + file_.close() + def readable_time(self, input_time): + return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) + def start_service(self): + start_time = time.time() + log_file = open('/tmp/skooloslog-' + start_time, 'w') + log_file.write("Started work: " + self.readable_time(start_time)) + sys.stdout = log_file + event_processor.watch_dir(self.work_dir) def Main(): diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py new file mode 100644 index 0000000..e2b3f5b --- /dev/null +++ b/BackgroundService/event_processor.py @@ -0,0 +1,46 @@ +import time +import pyinotify + + +def readable_time(input_time): + return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) + + +class EventProcessor(pyinotify.ProcessEvent): + _methods = ["IN_ACCESS", + "IN_CREATE", + "IN_CLOSE_WRITE", + "IN_DELETE" + "IN_MOVED_TO", + "IN_MOVED_FROM", + ] + + +def __method_format(method): + return { + "IN_ACCESS":"Accessed a file", + "IN_CREATE":"Created a file", + "IN_CLOSE_WRITE":"Wrote to a file", + "IN_DELETE":"Deleted a file", + "IN_MOVED_TO":"Moved a file or directory in from elsewhere", + "IN_MOVED_FROM":"Moved a file or directory elsewhere", + }[method] + + +def __process_generator(cls, method): + def _method_name(self, event): + print("Method name: {} ()\n" + "Path name: {}\n" + "Event Name: {}\n" + "Timestamp: {}\n".format(__method_format(method), event.pathname, event.maskname, readable_time(time.time()))) + _method_name.__name__ = "process_{}".format(method) + setattr(cls, _method_name.__name__, _method_name) + + +def watch_dir(dir_to_watch): + for method in EventProcessor._methods: + __process_generator(EventProcessor, method) + watch_manager = pyinotify.WatchManager() + event_notifier = pyinotify.Notifier(watch_manager, EventProcessor()) + watch_manager.add_watch(dir_to_watch, pyinotify.ALL_EVENTS) + event_notifier.loop() From 0d737d91c6fd6bd1f0eb1c1aca120393cc2f420b Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Fri, 12 Jun 2020 22:07:52 -0400 Subject: [PATCH 3/8] made bgservice.py into a class --- BackgroundService/bgservice.py | 19 ++++++++++++------- BackgroundService/event_processor.py | 9 +++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index 3ad361f..11136ec 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -5,13 +5,13 @@ import time import event_processor -class SkoolOSDaemmon: +class SkoolOSDaemon: """Constructor""" def __init__(self, work_dir): self.work_dir = work_dir self.start_time = None self.end_time = None - """Stores the pid of the program to be terminated externally""" + self.log_file = None def write_pid_file(self): pid = str(os.getpid()) file_ = open('/tmp/skoolosdaemonpid', 'w') @@ -19,12 +19,17 @@ class SkoolOSDaemmon: file_.close() def readable_time(self, input_time): return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) - def start_service(self): - start_time = time.time() - log_file = open('/tmp/skooloslog-' + start_time, 'w') - log_file.write("Started work: " + self.readable_time(start_time)) - sys.stdout = log_file + def start(self): + self.start_time = time.time() + self.log_file = open('/tmp/skooloslogs/' + str(self.start_time), 'w') + self.log_file.write("Started work: \n" + self.readable_time(self.start_time)) + sys.stdout = self.log_file event_processor.watch_dir(self.work_dir) + def stop(self): + self.end_time = time.time() + self.log_file.write("Stop time: \n" + self.readable_time(self.end_time)) + self.log_file.write("Total work time: " + + time.strftime("%H:%M:%S", time.gmtime(self.end_time - self.start_time))) def Main(): diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py index e2b3f5b..00f4d8a 100644 --- a/BackgroundService/event_processor.py +++ b/BackgroundService/event_processor.py @@ -29,10 +29,15 @@ def __method_format(method): def __process_generator(cls, method): def _method_name(self, event): - print("Method name: {} ()\n" + print("Event description: {}\n" "Path name: {}\n" "Event Name: {}\n" - "Timestamp: {}\n".format(__method_format(method), event.pathname, event.maskname, readable_time(time.time()))) + "Timestamp: {}\n".format(__method_format(method), + event.pathname, + event.maskname, + readable_time(time.time()) + ) + ) _method_name.__name__ = "process_{}".format(method) setattr(cls, _method_name.__name__, _method_name) From dfd7e4c3bddf13503fc24298241081476f98c761 Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Sat, 13 Jun 2020 19:38:06 -0400 Subject: [PATCH 4/8] small changes --- BackgroundService/bgservice.py | 9 +++++++-- BackgroundService/event_processor.py | 2 +- requirements.txt | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index 11136ec..68dc111 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -12,7 +12,7 @@ class SkoolOSDaemon: self.start_time = None self.end_time = None self.log_file = None - def write_pid_file(self): + def __write_pid_file(self): pid = str(os.getpid()) file_ = open('/tmp/skoolosdaemonpid', 'w') file_.write(pid) @@ -20,6 +20,7 @@ class SkoolOSDaemon: def readable_time(self, input_time): return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) def start(self): + __write_pid_file() self.start_time = time.time() self.log_file = open('/tmp/skooloslogs/' + str(self.start_time), 'w') self.log_file.write("Started work: \n" + self.readable_time(self.start_time)) @@ -32,8 +33,12 @@ class SkoolOSDaemon: time.strftime("%H:%M:%S", time.gmtime(self.end_time - self.start_time))) +logger = None + + def Main(): - print("This does nothing right now...") + logger = SkoolOSDaemon("/tmp") + logger.start() if __name__ == "__main__": diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py index 00f4d8a..38dec4b 100644 --- a/BackgroundService/event_processor.py +++ b/BackgroundService/event_processor.py @@ -10,7 +10,7 @@ class EventProcessor(pyinotify.ProcessEvent): _methods = ["IN_ACCESS", "IN_CREATE", "IN_CLOSE_WRITE", - "IN_DELETE" + "IN_DELETE", "IN_MOVED_TO", "IN_MOVED_FROM", ] diff --git a/requirements.txt b/requirements.txt index 1110b47..9a6e972 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ oauthlib==3.1.0 prompt-toolkit==1.0.14 pyclipper==1.1.0.post3 Pygments==2.6.1 +pyinotify==0.9.6 PyInquirer==1.0.3 pyperclip==1.8.0 pytz==2020.1 From a032cf12ad63b0a901a3a3efd0933b34a8033636 Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Sat, 13 Jun 2020 22:10:28 -0400 Subject: [PATCH 5/8] background service polish --- BackgroundService/bgservice.py | 18 ++++++++++--- BackgroundService/event_processor.py | 38 +++++++++++++++++++--------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index 68dc111..00421ee 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -13,6 +13,12 @@ class SkoolOSDaemon: self.end_time = None self.log_file = None def __write_pid_file(self): + try: + dirName = "/tmp/skooloslogs" + # Create log Directory + os.mkdir(dirName) + except FileExistsError: + pass pid = str(os.getpid()) file_ = open('/tmp/skoolosdaemonpid', 'w') file_.write(pid) @@ -20,23 +26,29 @@ class SkoolOSDaemon: def readable_time(self, input_time): return time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime(input_time)) def start(self): - __write_pid_file() + self.__write_pid_file() self.start_time = time.time() self.log_file = open('/tmp/skooloslogs/' + str(self.start_time), 'w') - self.log_file.write("Started work: \n" + self.readable_time(self.start_time)) + self.log_file.write("Start time: " + self.readable_time(self.start_time) + "\n") sys.stdout = self.log_file event_processor.watch_dir(self.work_dir) def stop(self): + event_processor.stop_watching() self.end_time = time.time() self.log_file.write("Stop time: \n" + self.readable_time(self.end_time)) self.log_file.write("Total work time: " + time.strftime("%H:%M:%S", time.gmtime(self.end_time - self.start_time))) + + logger = None - def Main(): + def signal_handler(signum, frame): + logger.stop() + signal.signal(signal.SIGINT, signal_handler) + global logger logger = SkoolOSDaemon("/tmp") logger.start() diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py index 38dec4b..137fbcb 100644 --- a/BackgroundService/event_processor.py +++ b/BackgroundService/event_processor.py @@ -24,28 +24,42 @@ def __method_format(method): "IN_DELETE":"Deleted a file", "IN_MOVED_TO":"Moved a file or directory in from elsewhere", "IN_MOVED_FROM":"Moved a file or directory elsewhere", - }[method] + }.get(method, "Unknown event") def __process_generator(cls, method): def _method_name(self, event): - print("Event description: {}\n" - "Path name: {}\n" - "Event Name: {}\n" - "Timestamp: {}\n".format(__method_format(method), - event.pathname, - event.maskname, - readable_time(time.time()) - ) - ) + description = "Event description: {}\n" \ + "Path name: {}\n" \ + "Event Name: {}\n" \ + "Timestamp: {}\n".format(__method_format(method), + event.pathname, + event.maskname, + readable_time(time.time()) + ) + if "IN_DELETE" in description: + description += "Warning: Unexpected file deletion\n" + if "IN_MOVED_TO" in description: + description += "Warning: Unexpected file add to work\n" + if "IN_MOVED_FROM" in description: + description += "Warning: Unexpected file moved out of directory\n" + print(description) _method_name.__name__ = "process_{}".format(method) setattr(cls, _method_name.__name__, _method_name) +EVENT_NOTIFIER = None + + def watch_dir(dir_to_watch): + global EVENT_NOTIFIER for method in EventProcessor._methods: __process_generator(EventProcessor, method) watch_manager = pyinotify.WatchManager() - event_notifier = pyinotify.Notifier(watch_manager, EventProcessor()) + EVENT_NOTIFIER = pyinotify.Notifier(watch_manager, EventProcessor()) watch_manager.add_watch(dir_to_watch, pyinotify.ALL_EVENTS) - event_notifier.loop() + EVENT_NOTIFIER.loop()#daemonize=True) + + +def stop_watching(): + EVENT_NOTIFIER.stop() From 01e71853bf591278ddc176cdbe18657ad0362d93 Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Sat, 13 Jun 2020 22:53:20 -0400 Subject: [PATCH 6/8] added possible daemon usage --- BackgroundService/bgservice.py | 8 +++++--- BackgroundService/event_processor.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index 00421ee..61e7d15 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -7,8 +7,9 @@ import event_processor class SkoolOSDaemon: """Constructor""" - def __init__(self, work_dir): + def __init__(self, work_dir, daemonize): self.work_dir = work_dir + self.daemonize = daemonize self.start_time = None self.end_time = None self.log_file = None @@ -29,9 +30,9 @@ class SkoolOSDaemon: self.__write_pid_file() self.start_time = time.time() self.log_file = open('/tmp/skooloslogs/' + str(self.start_time), 'w') - self.log_file.write("Start time: " + self.readable_time(self.start_time) + "\n") + self.log_file.write("Start time: \n" + self.readable_time(self.start_time) + "\n\n") sys.stdout = self.log_file - event_processor.watch_dir(self.work_dir) + event_processor.watch_dir(self.work_dir, self.daemonize) def stop(self): event_processor.stop_watching() self.end_time = time.time() @@ -48,6 +49,7 @@ def Main(): def signal_handler(signum, frame): logger.stop() signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) global logger logger = SkoolOSDaemon("/tmp") logger.start() diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py index 137fbcb..bed7b70 100644 --- a/BackgroundService/event_processor.py +++ b/BackgroundService/event_processor.py @@ -7,7 +7,7 @@ def readable_time(input_time): class EventProcessor(pyinotify.ProcessEvent): - _methods = ["IN_ACCESS", + _methods = ["IN_OPEN", "IN_CREATE", "IN_CLOSE_WRITE", "IN_DELETE", @@ -18,7 +18,7 @@ class EventProcessor(pyinotify.ProcessEvent): def __method_format(method): return { - "IN_ACCESS":"Accessed a file", + "IN_OPEN":"Accessed a file", "IN_CREATE":"Created a file", "IN_CLOSE_WRITE":"Wrote to a file", "IN_DELETE":"Deleted a file", @@ -51,14 +51,14 @@ def __process_generator(cls, method): EVENT_NOTIFIER = None -def watch_dir(dir_to_watch): +def watch_dir(dir_to_watch, daemonize=False): global EVENT_NOTIFIER for method in EventProcessor._methods: __process_generator(EventProcessor, method) watch_manager = pyinotify.WatchManager() EVENT_NOTIFIER = pyinotify.Notifier(watch_manager, EventProcessor()) watch_manager.add_watch(dir_to_watch, pyinotify.ALL_EVENTS) - EVENT_NOTIFIER.loop()#daemonize=True) + EVENT_NOTIFIER.loop(daemonize=daemonize) def stop_watching(): From 1af9343228681637e56365bd822c73106f1c4dff Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Sun, 14 Jun 2020 14:27:46 -0400 Subject: [PATCH 7/8] cypt --- .profile | 1 + CLI/oauth/index.html | 2 +- CLI/skoolos.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .profile diff --git a/.profile b/.profile new file mode 100644 index 0000000..df779be --- /dev/null +++ b/.profile @@ -0,0 +1 @@ +{'absences': 2, 'address': None, 'counselor': {'first_name': 'Sean', 'full_name': 'Sean Burke', 'id': 37, 'last_name': 'Burke', 'url': 'https://ion.tjhsst.edu/api/profile/37', 'user_type': 'counselor', 'username': 'SPBurke'}, 'display_name': 'Raffu Khondaker', 'emails': [], 'first_name': 'Raffu', 'full_name': 'Raffu Khondaker', 'grade': {'name': 'sophomore', 'number': 10}, 'graduation_year': 2022, 'id': 36508, 'ion_username': '2022rkhondak', 'is_announcements_admin': False, 'is_eighth_admin': False, 'is_student': True, 'is_teacher': False, 'last_name': 'Khondaker', 'middle_name': 'Al', 'nickname': '', 'phones': [], 'picture': 'https://ion.tjhsst.edu/api/profile/36508/picture', 'sex': 'Male', 'short_name': 'Raffu', 'title': None, 'tj_email': '2022rkhondak@tjhsst.edu', 'user_type': 'student', 'websites': []} \ No newline at end of file diff --git a/CLI/oauth/index.html b/CLI/oauth/index.html index 1c8f1f3..a0b45cf 100644 --- a/CLI/oauth/index.html +++ b/CLI/oauth/index.html @@ -14,7 +14,7 @@
- + Sign in with Ion diff --git a/CLI/skoolos.py b/CLI/skoolos.py index e818d3a..372b28c 100644 --- a/CLI/skoolos.py +++ b/CLI/skoolos.py @@ -14,6 +14,7 @@ from PyInquirer import prompt, print_json import json import os import argparse +from cryptography.fernet import Fernet client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6' client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY' @@ -71,13 +72,14 @@ def authenticate(): server.start() browser.get("localhost:8000/") - - while "http://localhost:8000/?code" not in browser.current_url: + print(1) + while "localhost:8000/callback/?code" not in browser.current_url: time.sleep(0.25) url = browser.current_url - gets = url_decode(url.replace("http://localhost:8000/?", "")) + gets = url_decode(url.replace("localhost:8000/callback/?", "")) code = gets.get("code") + print(2) if state == gets.get("state"): state = gets.get("state") print("states good") @@ -104,6 +106,10 @@ def authenticate(): os.chdir(cdir) profileFile = open(".profile", "w") #profileFile.write(profile.text()) + key = Fernet.generate_key() + file = open('key.key', 'wb') + file.write(key) # The key is type bytes still + file.close() profileFile.write(str(profile)) profileFile.close() From fa2e3f6275587c32e51ebb2d28ad60e9f3ffad3b Mon Sep 17 00:00:00 2001 From: Nathaniel Kenschaft Date: Sun, 14 Jun 2020 14:29:27 -0400 Subject: [PATCH 8/8] began to implement background service with ThreadedNotifier class --- BackgroundService/bgservice.py | 7 +++---- BackgroundService/event_processor.py | 16 ++++++++-------- BackgroundService/test.py | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 BackgroundService/test.py diff --git a/BackgroundService/bgservice.py b/BackgroundService/bgservice.py index 61e7d15..ed26c76 100644 --- a/BackgroundService/bgservice.py +++ b/BackgroundService/bgservice.py @@ -7,9 +7,8 @@ import event_processor class SkoolOSDaemon: """Constructor""" - def __init__(self, work_dir, daemonize): + def __init__(self, work_dir='/tmp'): self.work_dir = work_dir - self.daemonize = daemonize self.start_time = None self.end_time = None self.log_file = None @@ -32,7 +31,7 @@ class SkoolOSDaemon: self.log_file = open('/tmp/skooloslogs/' + str(self.start_time), 'w') self.log_file.write("Start time: \n" + self.readable_time(self.start_time) + "\n\n") sys.stdout = self.log_file - event_processor.watch_dir(self.work_dir, self.daemonize) + event_processor.watch_dir(self.work_dir) def stop(self): event_processor.stop_watching() self.end_time = time.time() @@ -49,7 +48,7 @@ def Main(): def signal_handler(signum, frame): logger.stop() signal.signal(signal.SIGINT, signal_handler) - signal.signal(signal.SIGTERM, signal_handler) + # signal.signal(signal.SIGTERM, signal_handler) global logger logger = SkoolOSDaemon("/tmp") logger.start() diff --git a/BackgroundService/event_processor.py b/BackgroundService/event_processor.py index bed7b70..55c5e15 100644 --- a/BackgroundService/event_processor.py +++ b/BackgroundService/event_processor.py @@ -18,7 +18,7 @@ class EventProcessor(pyinotify.ProcessEvent): def __method_format(method): return { - "IN_OPEN":"Accessed a file", + "IN_OPEN":"Opened a file", "IN_CREATE":"Created a file", "IN_CLOSE_WRITE":"Wrote to a file", "IN_DELETE":"Deleted a file", @@ -38,11 +38,11 @@ def __process_generator(cls, method): readable_time(time.time()) ) if "IN_DELETE" in description: - description += "Warning: Unexpected file deletion\n" + description += "WARNING: Unexpected file deletion\n" if "IN_MOVED_TO" in description: - description += "Warning: Unexpected file add to work\n" + description += "WARNING: Unexpected file add to work\n" if "IN_MOVED_FROM" in description: - description += "Warning: Unexpected file moved out of directory\n" + description += "WARNING: Unexpected file moved out of directory\n" print(description) _method_name.__name__ = "process_{}".format(method) setattr(cls, _method_name.__name__, _method_name) @@ -51,14 +51,14 @@ def __process_generator(cls, method): EVENT_NOTIFIER = None -def watch_dir(dir_to_watch, daemonize=False): +def watch_dir(dir_to_watch): global EVENT_NOTIFIER for method in EventProcessor._methods: __process_generator(EventProcessor, method) watch_manager = pyinotify.WatchManager() - EVENT_NOTIFIER = pyinotify.Notifier(watch_manager, EventProcessor()) - watch_manager.add_watch(dir_to_watch, pyinotify.ALL_EVENTS) - EVENT_NOTIFIER.loop(daemonize=daemonize) + EVENT_NOTIFIER = pyinotify.ThreadedNotifier(watch_manager, EventProcessor()) + watch_manager.add_watch(dir_to_watch, pyinotify.ALL_EVENTS, rec=True) + EVENT_NOTIFIER.loop() def stop_watching(): diff --git a/BackgroundService/test.py b/BackgroundService/test.py new file mode 100644 index 0000000..b797228 --- /dev/null +++ b/BackgroundService/test.py @@ -0,0 +1,19 @@ +from bgservice import SkoolOSDaemon as sod +import threading + +logger = sod() + + +if __name__ == "__main__": + line=1 + print(line) + line+=1 + logger.start() + print(line) + line+=1 + input("Enter any key when you are done modifyng the /tmp/ directory") + print(line) + line+=1 + logger.stop() + print(line) + line+=1