-
Notifications
You must be signed in to change notification settings - Fork 0
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
18 changed files
with
587 additions
and
274 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: python | ||
|
||
python: | ||
- "3.4" | ||
|
||
install: | ||
- pip install -r tests/requirements.txt | ||
- pip install nose | ||
|
||
script: nosetests --with-coverage --cover-package=shcmd | ||
|
||
after_success: | ||
- pip install coveralls | ||
- coveralls |
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 @@ | ||
include README.rst LICENSE tests/requirements.txt |
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,35 @@ | ||
SHCMD | ||
----- | ||
|
||
Note: Work in Progress. | ||
|
||
This lib aims to provide a Human friendly interface for subprocess. | ||
|
||
If you need piped subprocesses, give envoy_ a try. | ||
|
||
.. image:: https://travis-ci.org/SkyLothar/shcmd.svg?branch=master | ||
:target: https://travis-ci.org/SkyLothar/shcmd | ||
.. image:: https://travis-ci.org/SkyLothar/shcmd.svg?branch=master | ||
:target: https://travis-ci.org/SkyLothar/shcmd | ||
.. image:: https://img.shields.io/coveralls/SkyLothar/shcmd/master.svg | ||
:target: https://coveralls.io/r/SkyLothar/shcmd | ||
|
||
Usage | ||
^^^^^^ | ||
|
||
.. code-block:: python | ||
import shcmd | ||
with shcmd.cd("/tmp"): | ||
# get result directly | ||
assert shcmd.run("pwd") == "/tmp" | ||
# get streamed result packed in a generator | ||
streamed = shcmd.run("ls", stream=True) | ||
for filename in streamed.iter_lines(): | ||
print(filename) | ||
# get full stdout/stderr | ||
print(streamed.stdout) | ||
print(streamed.stderr) | ||
.. _`envoy`: https://github.com/kennethreitz/envoy |
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,29 @@ | ||
__version__ = "0.1.2" | ||
__author__ = "SkyLothar" | ||
__email__ = "allothar@gmail.com" | ||
__url__ = "https://github.com/skylothar/shcmd" | ||
|
||
import os | ||
|
||
__all__ = ["cd", "cd_to", "run", "tar_generator"] | ||
|
||
from .cmd import cd, cd_to | ||
from .proc import Proc | ||
from .tar import tar_generator | ||
from .utils import expand_args | ||
|
||
|
||
DEFAULT_TIMEOUT = 60 | ||
|
||
|
||
def run(cmd, cwd=None, env=None, timeout=None, stream=False): | ||
proc = Proc( | ||
expand_args(cmd), | ||
os.path.realpath(cwd or os.getcwd()), | ||
env=env or {}, | ||
timeout=timeout or DEFAULT_TIMEOUT | ||
) | ||
|
||
if not stream: | ||
proc.block() | ||
return proc |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class CmdError(Exception): | ||
class ShCmdError(Exception): | ||
pass |
Oops, something went wrong.