Merge pull request #24 from dacarley/watch-for-uploaded-files
Added a filesystem watcher for uploaded files
This commit is contained in:
@@ -118,6 +118,12 @@ fi
|
||||
# Install rc.local
|
||||
cp scripts/rc.local /etc/
|
||||
|
||||
# Ensure that the watchdog python library is installed
|
||||
pip3 list --format=columns | grep watchdog >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
pip3 install scripts/watchdog-v0.10.6.tar.gz
|
||||
fi
|
||||
|
||||
# Install bbctrl
|
||||
if $UPDATE_PY; then
|
||||
rm -rf /usr/local/lib/python*/dist-packages/bbctrl-*
|
||||
|
||||
BIN
scripts/watchdog-v0.10.6.tar.gz
Normal file
BIN
scripts/watchdog-v0.10.6.tar.gz
Normal file
Binary file not shown.
2
setup.py
2
setup.py
@@ -35,6 +35,6 @@ setup(
|
||||
'scripts/edit-boot-config',
|
||||
'scripts/browser',
|
||||
],
|
||||
install_requires = 'tornado sockjs-tornado pyserial pyudev smbus2'.split(),
|
||||
install_requires = 'tornado sockjs-tornado pyserial pyudev smbus2 watchdog'.split(),
|
||||
zip_safe = False,
|
||||
)
|
||||
|
||||
@@ -30,6 +30,15 @@ import copy
|
||||
import uuid
|
||||
import os
|
||||
import bbctrl
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
class UploadChangeHandler(FileSystemEventHandler):
|
||||
def __init__(self, state):
|
||||
self.state = state
|
||||
|
||||
def on_any_event(self, event):
|
||||
self.state.load_files()
|
||||
|
||||
|
||||
class State(object):
|
||||
@@ -79,6 +88,10 @@ class State(object):
|
||||
self.reset()
|
||||
self.load_files()
|
||||
|
||||
observer = Observer()
|
||||
observer.schedule(UploadChangeHandler(self), self.ctrl.get_upload(), recursive=True)
|
||||
observer.start()
|
||||
|
||||
|
||||
#def is_metric(self): return self.get('units', 'METRIC') == 'METRIC'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user