Browse Source

more,better log messages for audiogens

now audiogens will have their own logger and will log the "source" of
what they are adding to playlist
refs #36
boyska 7 years ago
parent
commit
f88e5602a7

+ 4 - 1
larigira/audiogen_mostrecent.py

@@ -7,6 +7,7 @@ from tempfile import mkstemp
 from pytimeparse.timeparse import timeparse
 
 from larigira.fsutils import scan_dir
+log = logging.getLogger(__name__)
 
 
 def get_mtime(fname):
@@ -17,7 +18,7 @@ def recent_choose(paths, howmany, minepoch):
     found_files = {}
     for path in paths:
         if not os.path.exists(path):
-            logging.warning("Can't find requested path: %s", path)
+            log.warning("Can't find requested path: %s", path)
             continue
         if os.path.isfile(path):
             found_files[path] = get_mtime(path)
@@ -66,6 +67,8 @@ def generate(spec):
                       prefix='audiogen-randomdir-')
         os.close(tmp[0])
         shutil.copy(path, tmp[1])
+        log.info("copying %s -> %s", path, os.path.basename(tmp[1]))
         yield 'file://{}'.format(tmp[1])
 
+
 generate.description = 'Select most recent file inside a directory'

+ 5 - 2
larigira/audiogen_randomdir.py

@@ -5,6 +5,7 @@ import random
 from tempfile import mkstemp
 
 from larigira.fsutils import scan_dir
+log = logging.getLogger(__name__)
 
 
 def generate(spec):
@@ -23,7 +24,7 @@ def generate(spec):
     found_files = set()
     for path in spec['paths']:
         if not os.path.exists(path):
-            logging.warning("Can't find requested path: %s", path)
+            log.warning("Can't find requested path: %s", path)
             continue
         if os.path.isfile(path):
             found_files.add(path)
@@ -34,9 +35,11 @@ def generate(spec):
 
     for path in picked:
         tmp = mkstemp(suffix=os.path.splitext(path)[-1],
-                      prefix='audiogen-randomdir-')
+                      prefix='randomdir-')
         os.close(tmp[0])
         shutil.copy(path, tmp[1])
+        log.info("copying %s -> %s", path, os.path.basename(tmp[1]))
         yield 'file://{}'.format(tmp[1])
 
+
 generate.description = 'Picks random files from a specified directory'

+ 1 - 1
larigira/audiogen_script.py

@@ -20,7 +20,7 @@ import os
 import subprocess
 
 from .config import get_conf
-log = logging.getLogger('audioscript')
+log = logging.getLogger(__name__)
 
 
 def generate(spec):

+ 5 - 1
larigira/audiogen_static.py

@@ -2,6 +2,7 @@ import os
 import logging
 import shutil
 from tempfile import mkstemp
+log = logging.getLogger(__name__)
 
 
 def generate(spec):
@@ -15,11 +16,14 @@ def generate(spec):
 
     for path in spec['paths']:
         if not os.path.exists(path):
-            logging.warning("Can't find requested path: %s", path)
+            log.warning("Can't find requested path: %s", path)
             continue
         tmp = mkstemp(suffix=os.path.splitext(path)[-1],
                       prefix='audiogen-static-')
         os.close(tmp[0])
+        log.info("copying %s -> %s", path, os.path.basename(tmp[1]))
         shutil.copy(path, tmp[1])
         yield 'file://{}'.format(tmp[1])
+
+
 generate.description = 'Picks always the same specified file'