Skip to content

Commit

Permalink
invoke: add work around to run invoke on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
arecarn committed May 14, 2017
1 parent ac64055 commit 99f3e96
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# disable the check for unused-arguments to ignore unused ctx parameter in tasks
# pylint: disable=unused-argument

isWindows = os.name == 'nt'
if isWindows:
IS_WINDOWS = os.name == 'nt'
if IS_WINDOWS:
# setting 'shell' is a work around for issue #345 of invoke
run_args = {'is_pty': False, 'shell': 'C:\Windows\System32\cmd.exe'}
RUN_ARGS = {'is_pty': False, 'shell': r'C:\Windows\System32\cmd.exe'}
else:
run_args = {'is_pty': True}
RUN_ARGS = {'is_pty': True}


def get_files():
Expand All @@ -35,22 +35,22 @@ def setup(ctx):
"""
Install python requirements
"""
ctx.run('python3 -m pip install -r requirements.txt', **run_args)
ctx.run('python3 -m pip install -r requirements.txt', **RUN_ARGS)

@task
def clean(ctx):
"""
Clean repository using git
"""
ctx.run('git clean --interactive', **run_args)
ctx.run('git clean --interactive', **RUN_ARGS)

@task
def lint(ctx):
"""
Run pylint on this module
"""
cmd = 'python3 -m pylint --output-format=parseable {files}'
ctx.run(cmd.format(files=get_files()), **run_args)
ctx.run(cmd.format(files=get_files()), **RUN_ARGS)

@task
def metrics(ctx):
Expand All @@ -60,15 +60,15 @@ def metrics(ctx):
cmd = 'radon {metric} --min B {files}'
metrics_to_run = ['cc', 'mi']
for metric in metrics_to_run:
ctx.run(cmd.format(metric=metric, files=get_files()), **run_args)
ctx.run(cmd.format(metric=metric, files=get_files()), **RUN_ARGS)

@task
def test(ctx):
"""
Test Task
"""
cmd = 'py.test'
ctx.run(cmd, **run_args)
ctx.run(cmd, **RUN_ARGS)

@task(test, lint, default=True)
def default(ctx):
Expand All @@ -83,4 +83,4 @@ def build(ctx):
Task to build an executable using pyinstaller
"""
cmd = 'pyinstaller -n dploy --onefile ' + os.path.join('dploy', '__main__.py')
ctx.run(cmd, **run_args)
ctx.run(cmd, **RUN_ARGS)

0 comments on commit 99f3e96

Please sign in to comment.