Skip to content

Commit

Permalink
Merge b432917 into 8333fc4
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Dec 27, 2016
2 parents 8333fc4 + b432917 commit 091db3f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions plumbum/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,22 @@ def __lshift__(self, data):
return StdinDataRedirection(self, data)

def __getitem__(self, args):
"""Creates a bound-command with the given arguments"""
"""Creates a bound-command with the given arguments. Shortcut for
bound_command."""
if not isinstance(args, (tuple, list)):
args = [args, ]
return self.bound_command(*args)

def bound_command(self, *args):
"""Creates a bound-command with the given arguments"""
if not args:
return self
if isinstance(self, BoundCommand):
return BoundCommand(self.cmd, self.args + list(args))
else:
return BoundCommand(self, args)


def __call__(self, *args, **kwargs):
"""A shortcut for `run(args)`, returning only the process' stdout"""
return self.run(args, **kwargs)[1]
Expand Down Expand Up @@ -135,7 +141,7 @@ def popen(self, args = (), **kwargs):
:returns: A ``Popen``-like object
"""
raise NotImplementedError()

def nohup(self, command, cwd='.', stdout='nohup.out', stderr=None, append=True):
"""Runs a command detached."""
return self.machine.daemonic_popen(self, cwd, stdout, stderr, append)
Expand Down Expand Up @@ -423,13 +429,13 @@ def __init__(self, executable, encoding):
self.encoding = encoding
self.cwd = None
self.env = None

def __str__(self):
return str(self.executable)

def __repr__(self):
return "{0}({1})".format(type(self).__name__, self.executable)
return "{0}({1})".format(type(self).__name__, self.executable)

def _get_encoding(self):
return self.encoding

Expand All @@ -451,8 +457,8 @@ def formulate(self, level = 0, args = ()):
# argv = [a.encode(self.encoding) for a in argv if isinstance(a, six.string_types)]
return argv






Expand Down

0 comments on commit 091db3f

Please sign in to comment.