Skip to content

Commit

Permalink
Added tests; renamed all modifier methods to add "run_" prefix; fixed
Browse files Browse the repository at this point in the history
circular import
  • Loading branch information
multimeric authored and henryiii committed Apr 14, 2018
1 parent 3e49d7b commit a3cd4e1
Show file tree
Hide file tree
Showing 3 changed files with 433 additions and 21 deletions.
36 changes: 18 additions & 18 deletions plumbum/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,49 +233,49 @@ def _use_modifier(self, modifier, args):
:return:
"""
modifier_instance = modifier(**args)
self & modifier_instance
return self & modifier_instance

def bg(self, **kwargs):
def run_bg(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the BG construct
:py:class: `plumbum.commands.modifiers.BG`
"""
self._use_modifier(plumbum.commands.modifiers.BG, kwargs)
return self._use_modifier(plumbum.commands.modifiers.BG, kwargs)

def fg(self, **kwargs):
def run_fg(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the FG construct
Run this command in the foreground. Uses all arguments from the FG construct
:py:class: `plumbum.commands.modifiers.FG`
"""
self._use_modifier(plumbum.commands.modifiers.FG, kwargs)
return self._use_modifier(plumbum.commands.modifiers.FG, kwargs)

def tee(self, **kwargs):
def run_tee(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the TEE construct
Run this command using the TEE construct. Inherits all arguments from TEE
:py:class: `plumbum.commands.modifiers.TEE`
"""
self._use_modifier(plumbum.commands.modifiers.TEE, kwargs)
return self._use_modifier(plumbum.commands.modifiers.TEE, kwargs)

def tf(self, **kwargs):
def run_tf(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the TF construct
Run this command using the TF construct. Inherits all arguments from TF
:py:class: `plumbum.commands.modifiers.TF`
"""
self._use_modifier(plumbum.commands.modifiers.TF, kwargs)
return self._use_modifier(plumbum.commands.modifiers.TF, kwargs)

def retcode(self, **kwargs):
def run_retcode(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the RETCODE construct
Run this command using the RETCODE construct. Inherits all arguments from RETCODE
:py:class: `plumbum.commands.modifiers.RETCODE`
"""
self._use_modifier(plumbum.commands.modifiers.RETCODE, kwargs)
return self._use_modifier(plumbum.commands.modifiers.RETCODE, kwargs)

def nohup(self, **kwargs):
def run_nohup(self, **kwargs):
"""
Run this command in the background. Uses all arguments from the NOHUP construct
Run this command using the NOHUP construct. Inherits all arguments from NOHUP
:py:class: `plumbum.commands.modifiers.NOHUP`
"""
self._use_modifier(plumbum.commands.modifiers.NOHUP, kwargs)
return self._use_modifier(plumbum.commands.modifiers.NOHUP, kwargs)

class BoundCommand(BaseCommand):
__slots__ = ("cmd", "args")
Expand Down
6 changes: 3 additions & 3 deletions plumbum/commands/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from itertools import chain

from plumbum.commands.processes import run_proc, ProcessExecutionError
from plumbum.commands.base import AppendingStdoutRedirection, StdoutRedirection
import plumbum.commands.base
from plumbum.lib import read_fd_decode_safely


Expand Down Expand Up @@ -310,11 +310,11 @@ def __init__(self, cwd='.', stdout='nohup.out', stderr=None, append=True):
self.append = append

def __rand__(self, cmd):
if isinstance(cmd, StdoutRedirection):
if isinstance(cmd, plumbum.commands.base.StdoutRedirection):
stdout = cmd.file
append = False
cmd = cmd.cmd
elif isinstance(cmd, AppendingStdoutRedirection):
elif isinstance(cmd, plumbum.commands.base.AppendingStdoutRedirection):
stdout = cmd.file
append = True
cmd = cmd.cmd
Expand Down
Loading

0 comments on commit a3cd4e1

Please sign in to comment.