-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
118 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
@task | ||
def setup(): | ||
createVenvs() | ||
createVenv() | ||
updatePackages() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Extension module for PIE that provides unix specific shortcuts. | ||
""" | ||
__VERSION__='0.0.1' | ||
|
||
import pie | ||
|
||
|
||
def cmd(c,use_sudo=False): | ||
sudo(c) if use_sudo else pie.cmd(c) | ||
|
||
def sudo(c): | ||
pie.cmd('sudo {}'.format(c)) | ||
|
||
|
||
def set_permissions(p,mode=None,owner=None,group=None,use_sudo=False): | ||
if mode: cmd('chmod {:04o} {}'.format(mode,p),use_sudo) | ||
if owner: cmd('chown {} {}'.format(owner,p),use_sudo) | ||
if group: cmd('chgrp {} {}'.format(group,p),use_sudo) | ||
|
||
|
||
def mkdir(p,mode=None,owner=None,group=None,use_sudo=False): | ||
cmd('mkdir {}'.format(p),use_sudo) | ||
set_permissions(p,mode,owner,group,use_sudo) | ||
|
||
def put_file(src,dest,mode=None,owner=None,group=None,use_sudo=False): | ||
cmd('cp {} {}'.format(src,dest),use_sudo) | ||
set_permissions(dest,mode,owner,group,use_sudo) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from pie import * | ||
|
||
|
||
@task | ||
def cmd_no_failure(): | ||
cmd('python -c "print(\'alpha\')"') | ||
|
||
|
||
@task | ||
def cmd_failure_non_existent(): | ||
cmd('non_existent') | ||
cmd('python -c "print(\'beta\')"') | ||
|
||
|
||
@task | ||
def cmd_failure_error_code(): | ||
cmd('python -c "import sys; sys.exit(3)"') | ||
cmd('python -c "print(\'gamma\')"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('pie_tasks_path',['error_handling'],indirect=['pie_tasks_path']) | ||
def test_cmd_no_failure(pie,capfd,pie_tasks_path): | ||
pie.main(['cmd_no_failure']) | ||
out,err=capfd.readouterr() | ||
out=out.replace(os.linesep,'\n') | ||
assert out=='alpha\n' | ||
|
||
@pytest.mark.parametrize('pie_tasks_path',['error_handling'],indirect=['pie_tasks_path']) | ||
def test_cmd_failure_non_existent(pie,capfd,pie_tasks_path): | ||
errorcode=pie.main(['cmd_failure_non_existent']) | ||
out,err=capfd.readouterr() | ||
assert not out.endswith('beta\n') | ||
assert errorcode==1 | ||
|
||
@pytest.mark.parametrize('pie_tasks_path',['error_handling'],indirect=['pie_tasks_path']) | ||
def test_cmd_failure_error_code(pie,capfd,pie_tasks_path): | ||
errorcode=pie.main(['cmd_failure_error_code']) | ||
out,err=capfd.readouterr() | ||
assert not out.endswith('gamma\n') | ||
assert errorcode==3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters