configure watchdog to accept a list of dirs to watch

- fix PlayingFrom component not working with album
- fix types issues on PlayingFrom component
This commit is contained in:
geoffrey45
2022-07-15 15:40:11 +03:00
parent 97b61970c5
commit 3882317cb6
11 changed files with 73 additions and 41 deletions
-1
View File
@@ -60,7 +60,6 @@ class RemoveDuplicates:
for t in self.tracklist
if t.uniq_hash not in uniq_hashes
]
pprint(uniq_hashes[:5])
tracks = UseBisection(self.tracklist, "uniq_hash", uniq_hashes)()
return tracks
+18 -6
View File
@@ -3,6 +3,7 @@ This library contains the classes and functions related to the watchdog file wat
"""
import os
import time
from typing import List
from app import instances
from app.helpers import create_hash
@@ -19,29 +20,39 @@ class OnMyWatch:
Contains the methods for initializing and starting watchdog.
"""
directory = os.path.expanduser("~")
home_dir = os.path.expanduser("~")
dirs = [home_dir]
observers: List[Observer] = []
def __init__(self):
self.observer = Observer()
def run(self):
event_handler = Handler()
self.observer.schedule(event_handler, self.directory, recursive=True)
for dir in self.dirs:
print("something")
self.observer.schedule(event_handler, os.path.realpath(dir), recursive=True)
self.observers.append(self.observer)
try:
self.observer.start()
print("something something")
except OSError:
log.error("Could not start watchdog.")
return
try:
while True:
time.sleep(5)
except:
self.observer.stop()
time.sleep(1)
except KeyboardInterrupt:
for o in self.observers:
o.unschedule_all()
o.stop()
print("Observer Stopped")
self.observer.join()
for o in self.observers:
o.join()
def add_track(filepath: str) -> None:
@@ -82,6 +93,7 @@ class Handler(PatternMatchingEventHandler):
"""
Fired when a supported file is created.
"""
print("💠 created file 💠")
self.files_to_process.append(event.src_path)
def on_deleted(self, event):
-1
View File
@@ -1,7 +1,6 @@
"""
Contains all the models for objects generation and typing.
"""
import random
from dataclasses import dataclass
from dataclasses import field
from typing import List