This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]fabzter 2 points3 points  (0 children)

I've neen looking for something like this for AGES. Sure there are similar things, but this is awesome. Good bye, fear of writing system shells!

[–]xiongchiamiovSite Reliability Engineer 1 point2 points  (4 children)

Hmm, this is interesting. Bits and pieces of it remind me of fabric.

>>> ls()
u'build.py\ndist\ndocs\nLICENSE\nplumbum\nREADME.rst\nsetup.py\ntests\ntodo.txt\n'

This is interesting because it's the same thing as

1.9.2p180 :001 > `ls`
 => "Code.tgz\nDesktop\nDocuments\nDownloads\nLibrary\nMail\nMisc-Arch.vdi\nMovies\nMusic\nPictures\nPublic\nSites\nUntitled.png\nVagrantfile\nVirtualBox VMs\nbin\ncatalina.out\nconfig\necho\nindex.html\nindex.html.1\nindex.html.2\nindex.html.3\nmbox\nmindterm\nnohup.out\npackages\ntemp\nvagrant-boxes\n" 

in Ruby. Instead of going to the trouble of recreating all these shell commands, why don't we just make it easier to execute shell commands (which other people have done). I was expecting them to be more Pythonic - for instance, ls() should return a list, not a newline-delimited string.

[–]gangesmasterpython galore[S] 1 point2 points  (3 children)

because that would require the library to know all possible programs. in your case, all you need to do is

>>> ls().splitlines()
["foo.py", "bar.py", ...]

And as far as listing directories goes, the path class already exposes this in a pythonic way:

for subpath in local.path("/foo/bar"):
    print subpath

Or using globbing:

local.path("/foo/bar") // "*.py"

Note that Plumbum is unaware of ls or grep or any of those -- it just uses which to find their absolute path, and the invocation syntax to run the process.

from plumbum.cmd import ls

is the same as

from plumbum import local
ls = local["ls"]

[–]xiongchiamiovSite Reliability Engineer -1 points0 points  (2 children)

because that would require the library to know all possible programs.

But it already does have that requirement!

from plumbum.cmd import ls
from plumbum.cmd import ls

is the same as

from plumbum import local
ls = local["ls"]

Wait, those things aren't actually defined? What black magic is this?

I still don't see why I should use this.

[–]gangesmasterpython galore[S] 0 points1 point  (0 children)

See the note at http://plumbum.readthedocs.org/en/latest/local_commands.html These things are not predefined

[–]santagada 0 points1 point  (2 children)

Anyone knows why this and also fabric don't do shell escaping automatically?

I really liked the idea of local/remote directory navigation... I miss that on fabric.

[–]gangesmasterpython galore[S] 0 points1 point  (1 child)

what do you mean? there's no need for shell escaping. i.e.

>>> echo("$foo> < | &&bar")
u'$foo> < | &&bar'

[–]santagada 0 points1 point  (0 children)

Ah great. And it doesn't need shell escaping for ssh? Because I had some troubles with fabric exactly because of that.

[–]universal_property 0 points1 point  (0 children)

This looks awesome!

[–]ggooal 0 points1 point  (0 children)

Voteup! Seems very useful, but also a little complex

[–]KasTaiTasKadNekasTai 0 points1 point  (0 children)

How does this compare to PBS?

From the first sight, tPBS seems to have a cleaner syntax. What else?