1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +00:00

Moving where some callbacks are used

This commit is contained in:
spl0k 2019-05-10 11:39:43 +02:00
parent 7bd4c54e98
commit e354f99d69
2 changed files with 11 additions and 14 deletions

View File

@ -191,7 +191,8 @@ class SupysonicCLI(cmd.Cmd):
if extensions:
extensions = extensions.split(' ')
scanner = Scanner(force = force, extensions = extensions, progress = TimedProgressDisplay(self.stdout))
scanner = Scanner(force = force, extensions = extensions, progress = TimedProgressDisplay(self.stdout),
on_folder_start = self.__unwatch_folder, on_folder_end = self.__watch_folder)
if folders:
fstrs = folders
@ -216,6 +217,14 @@ class SupysonicCLI(cmd.Cmd):
for err in stats.errors:
self.write_line('- ' + err)
def __unwatch_folder(self, folder):
try: self.__daemon.remove_watched_folder(folder.path)
except DaemonUnavailableError: pass
def __watch_folder(self, folder):
try: self.__daemon.add_watched_folder(folder.path)
except DaemonUnavailableError: pass
user_parser = CLIParser(prog = 'user', add_help = False)
user_subparsers = user_parser.add_subparsers(dest = 'action')
user_subparsers.add_parser('list', help = 'List users', add_help = False)

View File

@ -17,8 +17,6 @@ from pony.orm import db_session
from threading import Thread, Event
from .covers import find_cover_in_folder, CoverFile
from .daemon.exceptions import DaemonUnavailableError
from .daemon.client import DaemonClient
from .db import Folder, Artist, Album, Track, User
from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
from .db import RatingFolder, RatingTrack
@ -50,19 +48,9 @@ class ScanQueue(Queue):
self.__last_got = self.queue.pop()
return self.__last_got
def _unwatch_folder(folder):
daemon = DaemonClient()
try: daemon.remove_watched_folder(folder.path)
except DaemonUnavailableError: pass
def _watch_folder(folder):
daemon = DaemonClient()
try: daemon.add_watched_folder(folder.path)
except DaemonUnavailableError: pass
class Scanner(Thread):
def __init__(self, force = False, extensions = None, progress = None,
on_folder_start = _unwatch_folder, on_folder_end = _watch_folder, on_done = None):
on_folder_start = None, on_folder_end = None, on_done = None):
super(Scanner, self).__init__()
if extensions is not None and not isinstance(extensions, list):