Package gbp :: Module command_wrappers :: Class Command

[hide private]
[frames] | no frames]

# Class Command

    object --+
             |
            Command

Known Subclasses:
  - CatenateTarArchive
  - , Dch
  - , DpkgSourceExtract
  - , GitCommand
  - , PackTarArchive
  - , RemoveTree
  - , RunAtCommand
  - , UnpackTarArchive
  - , UnpackZipArchive
  - , pkg.pristinetar.PristineTar
  - , deb.DpkgCompareVersions

Wraps a shell command, so we don't have to store any kind of command line options in one of the git-buildpackage commands

Instance Methods | [hide private]

__call(self, args) Wraps subprocess.call so we can be verbose and fix python's SIGPIPE handling |

__call__(self, args=`[``]`, quiet=False) Run the command and convert all errors into CommandExecFailed. |

__init__(self, cmd, args=`[``]`, shell=False, extra_env=None, cwd=None, capture_stderr=False) x.__init__(...) initializes x; see help(type(x)) for signature |

__run(self, args, quiet=False) run self.cmd adding args as additional arguments |

call(self, args) Like __call__ but let the caller handle the return status and don't use the logging api for errors. |

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __call__(self, args=`[``]`, quiet=False)
(Call operator)

Run the command and convert all errors into CommandExecFailed. Assumes that the lower levels printed an error message (the command itself and also via our logging api) - only useful if you only expect 0 as result.

Parameters:
  - `quiet` (`bool`

        >>> Command("/bin/true")(["foo", "bar"])
        >>> Command("/foo/bar")(quiet=True)
        Traceback (most recent call last):
        ...
        CommandExecFailed

    ) - don't log failed execution to stderr. Mostly useful during unit testing

### __init__(self, cmd, args=`[``]`, shell=False, extra_env=None, cwd=None, capture_stderr=False)
(Constructor)

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
  (inherited documentation)

### __run(self, args, quiet=False)

run self.cmd adding args as additional arguments

Parameters:
  - `quiet` - don't log errors to stderr Mostly useful during unit testing.

    Be verbose about errors and encode them in the return value, don't pass on exceptions.

### call(self, args)

Like __call__ but let the caller handle the return status and don't use the logging api for errors.

    >>> Command("/bin/true").call(["foo", "bar"])
    0
    >>> Command("/foo/bar").call(["foo", "bar"]) # doctest:+ELLIPSIS
    Traceback (most recent call last):
    ...
    CommandExecFailed: Execution failed: ...