Questions tagged [plumbum]

Plumbum is a library for shell script-like programs in Python.

Plumbum is a library for shell script-like programs in Python. It attempts to mimic the shell syntax (shell combinators) where it makes sense, while keeping it all Pythonic and cross-platform.

Apart from shell-like syntax and handy shortcuts, the library provides local and remote command execution (over SSH), local and remote file-system paths, easy working-directory and environment manipulation, and a programmatic Command-Line Interface (CLI) application toolkit

20 questions
6
votes
1 answer

Capture the error output of a foreground command using plumbum

I'm using the plumbum python library (http://plumbum.readthedocs.org/) as a replacement for shell scripts. There's a command I want to run that, when it fails it outputs the paths to a file I'm interested in: $ slow_cmd Working.... 0% Working....…
5
votes
2 answers

plumbum.commands.processes.ProcessExecutionError: for commands which return null

The shell command I want to run, which returns nothing: echo helloWorld | grep 'dummy' plumbum version: Following line works: out=(echo["helloWorld"] | grep["h"])().strip() But following line does not, what might be the…
alper
  • 2,919
  • 9
  • 53
  • 102
4
votes
2 answers

Fabric vs Plumbum: differences, use cases, pros and cons

What are pros and cons of Fabric and Plumbum python libraries for local/remote command execution? What are use cases when one library should be used and other is not? What are the differences attention should be drawn to?
walkingpendulum
  • 190
  • 1
  • 11
4
votes
3 answers

Avoid escaping glob expressions in plumbum

Suppose I want to run something like ls a* using plumbum. from plumbum.cmd import ls ls['a*']() ... ProcessExecutionError: Command line: ['/bin/ls', 'a*'] Exit code: 1 Stderr: | ls: a*: No such file or directory I understand plumbum automatically…
shx2
  • 61,779
  • 13
  • 130
  • 153
2
votes
4 answers

Pass parameters to python plumbum command from a list

I'm using Plumbum to run command line utilities in the foreground on Python. if you had a command foo x y z, you would run it from Plumbum like so: from plumbum import cmd, FG cmd.foo['x', 'y', 'z'] & FG In the code I'm writing however, the…
Alok Mysore
  • 606
  • 3
  • 16
2
votes
1 answer

Python plumbum: Passing $ in an cmd argument

I am trying to execute the following command in python using plumbum: sort -u -f -t$'\t' -k1,1 file1 > file2 However, I am having issues passing the -t$'\t' argument. Here is my code: from plumbum.cmd import sort separator = r"-t$'\t'" print…
Steve3p0
  • 2,332
  • 5
  • 22
  • 30
1
vote
1 answer

from plumbum.cmd import git, grep, sed, wc

ImportError: cannot import name 'grep' from 'plumbum.cmd' (unknown location) I tried installing the module in Anaconda using conda install plumbum and it did install. Now what I am missing such that the above import do not work. I used Spyder…
greencar
  • 315
  • 1
  • 4
  • 18
1
vote
1 answer

plumbum: How to send a variable to stdin?

I currently do: (local['echo'][var] | sth)() Which seems inelegant and inefficient.
HappyFace
  • 3,439
  • 2
  • 24
  • 43
1
vote
1 answer

Avoid escaping dollar sign in a subcommand?

I need to process a file and immediately upload it somewhere. Consider the example and imagine we're doing aws s3 cp - s3://some-path/$FILE instead of the dd call: from plumbum.cmd import split, seq, rev, dd my_filter = (rev | dd['of=$FILE']) cmd =…
d33tah
  • 10,999
  • 13
  • 68
  • 158
1
vote
0 answers

How do you redirect stdout and stderr to two different files using plumbum?

I'm running a perl script in a pipeline context through plumbum in a Python3 script. I'd like to redirect the stdout to a .stdout file and stderr to a .stderr file. I tried using the usual >, 2> but it's not supported by plumbum. The .run method…
1
vote
1 answer

Plumbum - Nested SSH Remoting / Jump Host

Is there a good built-in way to connect through a 'jump host' with Plumbum. I've thought about subclassing ParamikoMachine to provide my own SSHClient object. Any other ideas?
Ben DeMott
  • 3,362
  • 1
  • 25
  • 35
1
vote
1 answer

How to do process substitution, e.g. "echo hi | tee >( gzip > /tmp/1 ) > /tmp/2" in plumbum?

I need to figure out how to call pipe substitution in plumbum. Specifically, how to construct chains such as echo hi | tee >( gzip > /tmp/1 ) > /tmp/2? Or, to illustrate the illustrate the idea better, find / | tee >( grep hi > /tmp/grepped ) >…
d33tah
  • 10,999
  • 13
  • 68
  • 158
1
vote
1 answer

How can I automate remote deployment in python?

I want to automate the remote deployment which currently I am doing manually. The process includes Make the tar ball from certain folders SFTP to the remote server Rename the old folders Untar the new tar file Restart apache The remote system is…
user3214546
  • 6,523
  • 13
  • 51
  • 98
1
vote
1 answer

Issue with running sudo command with python on plumbum

I'm using Python 2.7 with the latest plumbum package from mac ports. In general, plumbum works great. Though I'm having a heck of a time getting a sudo'd command to work. I've setup my /etc/sudoers for the commands I want to run without having to…
rlubke
  • 965
  • 5
  • 14
0
votes
2 answers

How to emulate backtick subshells in plumbum

I want to write this command in Plumbum: foo `date +%H%M%S` or, equivalently: foo $(date +%H%M%S) (think of 'foo' as a command like 'mkdir') How can I write this in Plumbum? I want to have this as a Plumbum object that I can reuse - ie each time…
user1908704
  • 168
  • 5
1
2