diff --git a/dev-requirements.txt b/dev-requirements.txt index b7367219..7b0e96c8 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,5 @@ # Automate tasks -fabric +invoke # Build documentation sphinx diff --git a/fabfile.py b/fabfile.py deleted file mode 100644 index f23da2b1..00000000 --- a/fabfile.py +++ /dev/null @@ -1,63 +0,0 @@ -from fabric.api import execute, local, settings, task - - -@task -def docs(): - local('make -C docs/ html') - - -@task -def autodocs(): - auto(docs) - - -@task -def test(path=None): - path = path or 'tests/' - local('nosetests ' + path) - - -@task -def autotest(path=None): - auto(test, path=path) - - -@task -def coverage(path=None): - path = path or 'tests/' - local( - 'nosetests --with-coverage --cover-package=mopidy ' - '--cover-branches --cover-html ' + path) - - -@task -def autocoverage(path=None): - auto(coverage, path=path) - - -@task -def lint(path=None): - path = path or '.' - local('flake8 $(find %s -iname "*.py")' % path) - - -@task -def autolint(path=None): - auto(lint, path=path) - - -def auto(task, *args, **kwargs): - while True: - local('clear') - with settings(warn_only=True): - execute(task, *args, **kwargs) - local( - 'inotifywait -q -e create -e modify -e delete ' - '--exclude ".*\.(pyc|sw.)" -r docs/ mopidy/ tests/') - - -@task -def update_authors(): - # Keep authors in the order of appearance and use awk to filter out dupes - local( - "git log --format='- %aN <%aE>' --reverse | awk '!x[$0]++' > AUTHORS") diff --git a/tasks.py b/tasks.py new file mode 100644 index 00000000..80b655b5 --- /dev/null +++ b/tasks.py @@ -0,0 +1,50 @@ +import sys + +from invoke import run, task + + +@task +def docs(watch=False, warn=False): + if watch: + return watcher(docs) + run('make -C docs/ html', warn=warn) + + +@task +def test(path=None, coverage=False, watch=False, warn=False): + if watch: + return watcher(test) + path = path or 'tests/' + cmd = 'nosetests' + if coverage: + cmd += ( + ' --with-coverage --cover-package=mopidy' + ' --cover-branches --cover-html') + cmd += ' %s' % path + run(cmd, pty=True, warn=warn) + + +@task +def lint(watch=False, warn=False): + if watch: + return watcher(lint) + run('flake8', warn=warn) + + +@task +def update_authors(): + # Keep authors in the order of appearance and use awk to filter out dupes + run("git log --format='- %aN <%aE>' --reverse | awk '!x[$0]++' > AUTHORS") + + +def watcher(task, *args, **kwargs): + while True: + run('clear') + kwargs['warn'] = True + task(*args, **kwargs) + try: + run( + 'inotifywait -q -e create -e modify -e delete ' + '--exclude ".*\.(pyc|sw.)" -r docs/ mopidy/ tests/') + except KeyboardInterrupt: + sys.exit()