mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
more work on daemonizing background service
This commit is contained in:
parent
1ba3d791f3
commit
55a65d38d9
|
@ -40,8 +40,6 @@ class SkoolOSDaemon:
|
|||
time.strftime("%H:%M:%S", time.gmtime(self.end_time - self.start_time)))
|
||||
|
||||
|
||||
|
||||
|
||||
logger = None
|
||||
|
||||
def Main():
|
||||
|
|
52
BackgroundService/event_processor2.py
Normal file
52
BackgroundService/event_processor2.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
import pyinotify
|
||||
|
||||
wm = pyinotify.WatchManager()
|
||||
mask = pyinotify.IN_CREATE | pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE | \
|
||||
pyinotify.IN_MOVED_TO | pyinotify.IN_MOVED_FROM | pyinotify.IN_OPEN
|
||||
|
||||
class EventHandler(pyinotify.ProcessEvent):
|
||||
_methods = ["IN_CREATE",
|
||||
"IN_CLOSE_WRITE",
|
||||
"IN_DELETE",
|
||||
"IN_MOVED_TO",
|
||||
"IN_MOVED_FROM",
|
||||
"IN_OPEN",
|
||||
]
|
||||
def __process_generator(self, event):
|
||||
description = \
|
||||
"Event: {}\n" \
|
||||
"Event Path: {}\n" \
|
||||
"Timestamp: {}\n".format(
|
||||
method,
|
||||
event.pathname,
|
||||
time.strftime("%A, %B %d, %Y %H:%M:%S", time.localtime())
|
||||
)
|
||||
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"
|
||||
return description
|
||||
|
||||
def process_IN_CREATE(self, event):
|
||||
self.__process_generator(event)
|
||||
def process_IN_CLOSE_WRITE(self, event):
|
||||
self.__process_generator(event)
|
||||
def process_IN_DELETE(self, event):
|
||||
self.__process_generator(event)
|
||||
def process_IN_MOVED_TO(self, event):
|
||||
self.__process_generator(event)
|
||||
def process_IN_MOVED_FROM(self, event):
|
||||
self.__process_generator(event)
|
||||
def process_IN_OPEN(self, event):
|
||||
self.__process_generator(event)
|
||||
|
||||
|
||||
notifier = pyinotify.ThreadedNotifier(wm, EventHandler())
|
||||
notifier.start()
|
||||
|
||||
wdd = wm.add_watch('/tmp', mask, rec=True)
|
||||
input("Press any key to continue...")
|
||||
|
||||
notifier.stop()
|
|
@ -1,27 +1,61 @@
|
|||
appdirs==1.4.3
|
||||
arandr==0.1.10
|
||||
asgiref==3.2.7
|
||||
astroid==2.4.2
|
||||
CacheControl==0.12.6
|
||||
certifi==2020.4.5.1
|
||||
chardet==3.0.4
|
||||
click==7.1.2
|
||||
colorama==0.4.3
|
||||
contextlib2==0.6.0
|
||||
distlib==0.3.0
|
||||
distro==1.4.0
|
||||
Django==3.0.7
|
||||
django-cors-middleware==1.5.0
|
||||
django-crispy-forms==1.9.1
|
||||
django-oauth-toolkit==1.3.2
|
||||
djangorestframework==3.11.0
|
||||
greenlet==0.4.16
|
||||
html5lib==1.0.1
|
||||
idna==2.9
|
||||
isort==4.3.21
|
||||
lazy-object-proxy==1.4.3
|
||||
mccabe==0.6.1
|
||||
meson==0.53.2
|
||||
msgpack==0.6.2
|
||||
oauthlib==3.1.0
|
||||
ordered-set==3.1.1
|
||||
packaging==20.1
|
||||
pep517==0.8.1
|
||||
Pillow==7.1.2
|
||||
progress==1.5
|
||||
prompt-toolkit==1.0.14
|
||||
pulsemixer==1.5.0
|
||||
pycairo==1.19.1
|
||||
pyclipper==1.1.0.post3
|
||||
Pygments==2.6.1
|
||||
PyGObject==3.34.0
|
||||
pyinotify==0.9.6
|
||||
PyInquirer==1.0.3
|
||||
pylint==2.5.3
|
||||
pynvim==0.4.1
|
||||
pyparsing==2.4.6
|
||||
pyperclip==1.8.0
|
||||
pytoml==0.1.21
|
||||
pytz==2020.1
|
||||
pywal==3.3.0
|
||||
regex==2020.5.14
|
||||
requests==2.23.0
|
||||
requests-oauthlib==1.3.0
|
||||
retrying==1.3.3
|
||||
selenium==3.141.0
|
||||
six==1.15.0
|
||||
sqlparse==0.3.1
|
||||
team==1.0
|
||||
toml==0.10.0
|
||||
urllib3==1.25.9
|
||||
wcwidth==0.2.3
|
||||
webencodings==0.5.1
|
||||
Werkzeug==1.0.1
|
||||
wpgtk==6.1.3
|
||||
wrapt==1.12.1
|
||||
|
|
Loading…
Reference in New Issue
Block a user