From 5252111e9132cd2533a77bbbbf97d9f777f2469f Mon Sep 17 00:00:00 2001 From: Emory P Date: Fri, 1 Nov 2013 14:46:16 -0400 Subject: [PATCH] some status messages for scan and flush database more often during scan to prevent error from cancelling entire scan --- .gitignore | 1 + api/media.py | 4 +++- cli.py | 1 + db.py | 4 ++-- main.wsgi | 2 +- scanner.py | 6 +++++- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c9b568f..d4e16ab 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc *.swp +start_server.sh diff --git a/api/media.py b/api/media.py index 2c2d43d..7a0f216 100755 --- a/api/media.py +++ b/api/media.py @@ -21,8 +21,9 @@ def prepare_transcoding_cmdline(base_cmdline, input_file, input_format, output_f @app.route('/rest/stream.view', methods = [ 'GET', 'POST' ]) def stream_media(): status, res = get_entity(request, Track) + if not status: - return res + return res maxBitRate, format, timeOffset, size, estimateContentLength = map(request.args.get, [ 'maxBitRate', 'format', 'timeOffset', 'size', 'estimateContentLength' ]) if format: @@ -78,6 +79,7 @@ def stream_media(): proc.terminate() proc.wait() + response = Response(transcode(), mimetype = dst_mimetype) else: response = send_file(res.path, mimetype = dst_mimetype) diff --git a/cli.py b/cli.py index 80da3d4..98a85dd 100755 --- a/cli.py +++ b/cli.py @@ -104,6 +104,7 @@ class CLI(cmd.Cmd): s = Scanner(db.session) if folders: folders = map(lambda n: db.Folder.query.filter(db.Folder.name == n and db.Folder.root == True).first() or n, folders) + print folders if any(map(lambda f: isinstance(f, basestring), folders)): print "No such folder(s): " + ' '.join(f for f in folders if isinstance(f, basestring)) for folder in filter(lambda f: isinstance(f, db.Folder), folders): diff --git a/db.py b/db.py index 4c932e3..247fa6a 100755 --- a/db.py +++ b/db.py @@ -12,7 +12,7 @@ from sqlalchemy.dialects.postgresql import UUID as pgUUID import uuid, datetime, time import os.path - + class UUID(TypeDecorator): """Platform-somewhat-independent UUID type @@ -58,7 +58,7 @@ def now(): return datetime.datetime.now().replace(microsecond = 0) engine = create_engine(config.get('base', 'database_uri'), convert_unicode = True) -session = scoped_session(sessionmaker(autocommit = False, autoflush = False, bind = engine)) +session = scoped_session(sessionmaker(autoflush = True, bind = engine)) Base = declarative_base() Base.query = session.query_property() diff --git a/main.wsgi b/main.wsgi index d2bbdb1..d320397 100755 --- a/main.wsgi +++ b/main.wsgi @@ -1,7 +1,7 @@ # coding: utf-8 import os.path, sys -sys.path.insert(0, '/path/to/the/supysonic/app') +sys.path.insert(0, '/home/emory/supysonic') import config if not config.check(): diff --git a/scanner.py b/scanner.py index 907c1de..c062278 100755 --- a/scanner.py +++ b/scanner.py @@ -23,7 +23,10 @@ class Scanner: self.__deleted_tracks = 0 def scan(self, folder): - for root, subfolders, files in os.walk(folder.path): + print "scanning", folder.path + for root, subfolders, files in os.walk(folder.path, topdown=False): + for p in subfolders: + db.session.flush() for f in files: self.__scan_file(os.path.join(root, f), folder) folder.last_scan = int(time.time()) @@ -60,6 +63,7 @@ class Scanner: self.__remove_track(tr) return else: + print "Added ", path tag = self.__try_load_tag(path) if not tag: return