summaryrefslogtreecommitdiff
path: root/library.py
diff options
context:
space:
mode:
authorMichaël Ball <michael.ball@gmail.com>2015-12-20 15:22:16 +0000
committerMichaël Ball <michael.ball@gmail.com>2015-12-20 15:29:39 +0000
commit3f14c56860ff67e2d2a689fe3f362ad7a25631d5 (patch)
tree6ac2d39fd268231f4f7ebdf8a41661c27b89101e /library.py
parentf0b11a127a127a91217fcd5645c772ce37b2bfcf (diff)
Syntax improvements
Diffstat (limited to 'library.py')
-rwxr-xr-xlibrary.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/library.py b/library.py
index 6cdb732..531a148 100755
--- a/library.py
+++ b/library.py
@@ -1,11 +1,12 @@
#!/usr/bin/env python
import configparser
import gevent
-from gevent import queue
+from gevent import monkey, queue
import logging
import mutagen
import os
+from db.db_manager import DbManager
from models.track import Track
@@ -24,6 +25,7 @@ def store_track_task():
def run(path=None):
+ db = DbManager()
if path is not None:
if os.path.isdir(path):
store_dir(path)
@@ -31,13 +33,15 @@ def run(path=None):
store_file(path)
else:
store_dir("/media/Music")
+ db.export()
def store_file(path):
+ logger = logging.getLogger("store_file")
m = mutagen.File(path, easy=True)
if m:
if not Track.store(path, m):
- print("Problem saving %s" % (path,))
+ logger.error("Problem saving %s" % (path,))
def store_dir(path):
@@ -50,10 +54,10 @@ def store_dir(path):
file_path = "".join([root, "/", name])
file, ext = os.path.splitext(file_path)
- if ext in allowed_extensions:
+ if ext.lower() in allowed_extensions:
file_store.put(file_path)
- logger.info("Storing tracks")
+ logger.info("Storing tracks")
gevent.joinall([gevent.spawn(store_track_task)] * 6)
logger.info("Done")
@@ -88,6 +92,7 @@ def update_track_filename(oldpath, newpath):
track.save()
if __name__ == "__main__":
+ monkey.patch_all()
config = configparser.ConfigParser()
config.read("mach2.ini")