Module Expr Str Import alias Import alias Assign NameStore Str Assign NameStore Str Assign NameStore TupleLoad Num Num Num ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore Num decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Return NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If AttributeLoad NameLoad attr body If CompareNotEq NameLoad NameLoad body AugAssignAdd AttributeStore NameLoad attr NameLoad If AttributeLoad NameLoad attr body If CompareNotEq NameLoad NameLoad body AugAssignAdd AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareIsNot AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Assign AttributeStore NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Dict Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr If UnaryOpNot AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot AttributeLoad NameLoad attr body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If UnaryOpNot AttributeLoad NameLoad attr body Raise Call NameLoad Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Return AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore ListComp NameLoad comprehension NameStore NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Return AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore ListComp NameLoad comprehension NameStore NameLoad NameLoad Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Expr Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list
N/A N/A 
shell
=====

A better way to run shell commands in Python.

If you just need to quickly run a command, you can use the ``shell`` shortcut
function::

    >>> from shell import shell
    >>> ls = shell('ls')
    >>> for file in ls.output():
    ...     print file
    'another.txt'

If you need to extend the behavior, you can also use the ``Shell`` object::

    >>> from shell import Shell
    >>> sh = Shell(has_input=True)
    >>> cat = sh.run('cat -u')
    >>> cat.write('Hello, world!')
    >>> cat.output()
    ['Hello, world!']

 N/A shlex N/A subprocess N/A __author__ Daniel Lindsley N/A __license__ New BSD N/A __version__ N/A 1 0 1 ShellException N/A Exception N/A N/A The base exception for all shell-related errors. N/A N/A MissingCommandException N/A ShellException N/A N/A Thrown when no command was setup. N/A N/A CommandError N/A ShellException N/A N/A Thrown when a command fails. N/A error_code 1 N/A Shell N/A object N/A N/A 
    Handles executing commands & recording output.

    Optionally accepts a ``has_input`` parameter, which should be a boolean.
    If set to ``True``, the command will wait to execute until you call the
    ``Shell.write`` method & send input. (Default: ``False``)

    Optionally accepts a ``record_output`` parameter, which should be a boolean.
    If set to ``True``, the stdout from the command will be recorded.
    (Default: ``True``)

    Optionally accepts a ``record_errors`` parameter, which should be a boolean.
    If set to ``True``, the stderr from the command will be recorded.
    (Default: ``True``)

    Optionally accepts a ``strip_empty`` parameter, which should be a boolean.
    If set to ``True``, only non-empty lines from ``Shell.output`` or
    ``Shell.errors`` will be returned. (Default: ``True``)
     __init__ N/A N/A self has_input record_output record_errors strip_empty N/A False True True True N/A N/A N/A self has_input has_input N/A N/A self record_output record_output N/A N/A self record_errors record_errors N/A N/A self strip_empty strip_empty N/A N/A self last_command N/A N/A self line_breaks N/A N/A self pid None N/A N/A self code 0 N/A N/A self _popen None N/A N/A self _stdout N/A N/A self _stderr N/A _split_command N/A N/A self command N/A N/A N/A 
        Splits a string command into the individual args to pass to ``Popen``.

        If the ``command`` is an array, it is left untouched.
         N/A N/A isinstance command N/A tuple list N/A N/A command N/A N/A N/A shlex split command N/A _handle_output N/A N/A self stdout stderr N/A N/A N/A 
        Takes stdout/stderr & optionally retains them internally.

        Requires a ``stdout`` parameter, which should either be the output as
        a string or ``None``.

        Requires a ``stderr`` parameter, which should either be the errors as
        a string or ``None``.

        Records nothing if the ``record_*`` options have been set to ``False``.
         N/A N/A self record_output N/A N/A N/A stdout None N/A N/A N/A self _stdout stdout N/A N/A self record_errors N/A N/A N/A stderr None N/A N/A N/A self _stderr stderr N/A _communicate N/A N/A self the_input N/A None N/A N/A 
        Handles communicating with the process & optionally sends input.

        Optionally accepts a ``the_input`` parameter, which can be a string
        to send to the process. (Default: ``None``)
         N/A N/A stdout stderr N/A N/A N/A self _popen communicate input the_input N/A N/A N/A self _handle_output stdout stderr N/A N/A N/A N/A self _popen returncode None N/A N/A N/A self code N/A N/A self _popen returncode N/A run N/A N/A self command N/A N/A N/A 
        Runs a given command.

        Requires a ``command`` parameter should be either a string command
        (easier) or an array of arguments to send as the command (if you know
        what you're doing).

        Returns the ``Shell`` instance.

        Example::

            >>> from shell import Shell
            >>> sh = Shell()
            >>> sh.run('ls- alh')

         N/A N/A self last_command command N/A command_bits N/A N/A self _split_command command N/A kwargs N/A stdout stderr universal_newlines N/A subprocess PIPE N/A subprocess PIPE True N/A N/A self has_input N/A N/A N/A kwargs N/A stdin N/A subprocess PIPE N/A N/A self _popen N/A N/A subprocess Popen command_bits kwargs N/A N/A self pid N/A N/A self _popen pid N/A N/A N/A self has_input N/A N/A N/A N/A self _communicate N/A self N/A write N/A N/A self the_input N/A N/A N/A 
        If you're working with an interactive process, sends that input to
        the process.

        This needs to be used in conjunction with the ``has_input=True``
        parameter.

        Requires a ``the_input`` parameter, which should be a string of the
        input to send to the command.

        Returns the ``Shell`` instance.

        Example::

            >>> from shell import Shell
            >>> sh = Shell(has_input=True)
            >>> sh.run('cat -u')
            >>> sh.write('Hello world!')

         N/A N/A N/A self _popen N/A N/A N/A MissingCommandException No command has been provided. Please call ``run`` first. N/A N/A N/A self _communicate the_input N/A self N/A kill N/A N/A self N/A N/A N/A 
        Kills a given process.

        Example::

            >>> from shell import Shell
            >>> sh = Shell()
            >>> sh.run('some_long_running_thing')
            >>> sh.kill()

         N/A N/A N/A self _popen N/A N/A N/A MissingCommandException No command has been provided. Please call ``run`` first. N/A N/A N/A N/A self _popen kill N/A self N/A output N/A N/A self raw N/A False N/A N/A 
        Returns the output from running a command.

        Optionally accepts a ``raw`` parameter, which should be a boolean. If
        ``raw`` is set to ``False``, you get an array of lines of output. If
        ``raw`` is set to ``True``, the raw string of output is returned.
        (Default: ``False``)

        Example::

            >>> from shell import Shell
            >>> sh = Shell()
            >>> sh.run('ls ~')
            >>> sh.output()
            [
                'hello.txt',
                'world.txt',
            ]

         N/A raw N/A N/A N/A self _stdout N/A lines N/A N/A N/A self _stdout split N/A self line_breaks N/A N/A self strip_empty N/A N/A lines N/A line N/A line lines line N/A lines N/A errors N/A N/A self raw N/A False N/A N/A 
        Returns the errors from running a command.

        Optionally accepts a ``raw`` parameter, which should be a boolean. If
        ``raw`` is set to ``False``, you get an array of lines of errors. If
        ``raw`` is set to ``True``, the raw string of errors is returned.
        (Default: ``False``)

        Example::

            >>> from shell import Shell
            >>> sh = Shell()
            >>> sh.run('ls /there-s-no-way-anyone/has/this/directory/please')
            >>> sh.errors()
            [
                'ls /there-s-no-way-anyone/has/this/directory/please: No such file or directory'
            ]

         N/A raw N/A N/A N/A self _stderr N/A lines N/A N/A N/A self _stderr split N/A self line_breaks N/A N/A self strip_empty N/A N/A lines N/A line N/A line lines line N/A lines N/A N/A shell N/A N/A command has_input record_output record_errors strip_empty N/A False True True True N/A N/A 
    A convenient shortcut for running commands.

    Requires a ``command`` parameter should be either a string command
    (easier) or an array of arguments to send as the command (if you know
    what you're doing).

    Optionally accepts a ``has_input`` parameter, which should be a boolean.
    If set to ``True``, the command will wait to execute until you call the
    ``Shell.write`` method & send input. (Default: ``False``)

    Optionally accepts a ``record_output`` parameter, which should be a boolean.
    If set to ``True``, the stdout from the command will be recorded.
    (Default: ``True``)

    Optionally accepts a ``record_errors`` parameter, which should be a boolean.
    If set to ``True``, the stderr from the command will be recorded.
    (Default: ``True``)

    Optionally accepts a ``strip_empty`` parameter, which should be a boolean.
    If set to ``True``, only non-empty lines from ``Shell.output`` or
    ``Shell.errors`` will be returned. (Default: ``True``)

    Returns the ``Shell`` instance, which has been run with the given command.

    Example::

        >>> from shell import shell
        >>> sh = shell('ls -alh *py')
        >>> sh.output()
        ['hello.py', 'world.py']

     N/A sh N/A Shell has_input has_input record_output record_output record_errors record_errors strip_empty strip_empty N/A N/A N/A sh run command N/A