mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user