diff options
author | Michaël Ball <michael.ball@gmail.com> | 2015-12-20 15:22:16 +0000 |
---|---|---|
committer | Michaël Ball <michael.ball@gmail.com> | 2015-12-20 15:29:39 +0000 |
commit | 3f14c56860ff67e2d2a689fe3f362ad7a25631d5 (patch) | |
tree | 6ac2d39fd268231f4f7ebdf8a41661c27b89101e /library.py | |
parent | f0b11a127a127a91217fcd5645c772ce37b2bfcf (diff) |
Syntax improvements
Diffstat (limited to 'library.py')
-rwxr-xr-x | library.py | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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") |