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
This commit is contained in:
boyska 2017-02-04 18:54:06 +01:00
parent 78dc70d2a6
commit f88e5602a7
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
4 changed files with 15 additions and 5 deletions

View file

@ -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'

View file

@ -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'

View file

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

View file

@ -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'