Merge branch 'release-0.4'
merges hotfix
This commit is contained in:
commit
8aebeae560
5 changed files with 41 additions and 3 deletions
|
@ -60,9 +60,9 @@ copyright = '2015-2016, boyska'
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.4'
|
||||
version = '0.4.2'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.4'
|
||||
release = '0.4.2'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
|
@ -27,6 +27,7 @@ def get_conf(prefix='LARIGIRA_'):
|
|||
conf['EVENT_TICK_SECS'] = 30 # period for scheduling events
|
||||
conf['DEBUG'] = False
|
||||
conf['LOG_CONFIG'] = False
|
||||
conf['TMPDIR'] = os.getenv('TMPDIR', '/tmp/')
|
||||
conf.update(from_envvars(prefix=prefix))
|
||||
return conf
|
||||
|
||||
|
|
31
larigira/test_unused.py
Normal file
31
larigira/test_unused.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
|
||||
from .unused import UnusedCleaner
|
||||
from .config import get_conf
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def unusedcleaner():
|
||||
return UnusedCleaner(get_conf(prefix='LARIGIRATEST_'))
|
||||
|
||||
|
||||
# this test suite heavily assumes that TMPDIR == /tmp/, which is the default
|
||||
# indeed. However, the code does not rely on this assumption.
|
||||
|
||||
def test_watch_file(unusedcleaner):
|
||||
# despite not existing, the file is added
|
||||
unusedcleaner.watch('file:///tmp/gnam')
|
||||
assert len(unusedcleaner.waiting_removal_files) == 1
|
||||
assert list(unusedcleaner.waiting_removal_files)[0] == '/tmp/gnam'
|
||||
|
||||
|
||||
def test_watch_path_error(unusedcleaner):
|
||||
'''paths are not valid thing to watch. URIs only, thanks'''
|
||||
unusedcleaner.watch('/tmp/foo')
|
||||
assert len(unusedcleaner.waiting_removal_files) == 0
|
||||
|
||||
|
||||
def test_watch_notmp_error(unusedcleaner):
|
||||
'''Files not in TMPDIR are not added'''
|
||||
unusedcleaner.watch('file:///not/in/tmp')
|
||||
assert len(unusedcleaner.waiting_removal_files) == 0
|
|
@ -5,6 +5,7 @@ This component will look for files to be removed. There are some assumptions:
|
|||
* MPD URIs are parsed, and only file:/// is supported
|
||||
'''
|
||||
import os
|
||||
from os.path import commonpath, normpath
|
||||
import logging
|
||||
import mpd
|
||||
|
||||
|
@ -29,6 +30,11 @@ class UnusedCleaner:
|
|||
if not uri.startswith('file:///'):
|
||||
return # not a file URI
|
||||
fpath = uri[len('file://'):]
|
||||
if 'TMPDIR' in self.conf and self.conf['TMPDIR'] \
|
||||
and commonpath([self.conf['TMPDIR'], fpath]) != \
|
||||
normpath(self.conf['TMPDIR']):
|
||||
self.log.info('Not watching file {}: not in TMPDIR'.format(fpath))
|
||||
return
|
||||
if not os.path.exists(fpath):
|
||||
self.log.warning('a path that does not exist is being monitored')
|
||||
self.waiting_removal_files.add(fpath)
|
||||
|
|
2
setup.py
2
setup.py
|
@ -29,7 +29,7 @@ class PyTest(TestCommand):
|
|||
sys.exit(errno)
|
||||
|
||||
setup(name='larigira',
|
||||
version='0.4',
|
||||
version='0.4.2',
|
||||
description='A radio automation based on MPD',
|
||||
long_description=read('README.rst'),
|
||||
author='boyska',
|
||||
|
|
Loading…
Reference in a new issue