plumbum
plumbum copied to clipboard
run() takes from 1 to 2 positional arguments but 3 were given
I'm trying to capture error messages from the process I'm running and (not for the first time), I can't figure out the right way pass a command line switch and a parameter.
>>> command
LocalCommand(/bin/ls)
>>> print(command.run('-l', '*'))
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
TypeError: run() takes from 1 to 2 positional arguments but 3 were given
(I assume self
is the invisible positional argument, but my question remains.]
Thanks again
Just pretend a Command is a function.
from plumbum.cmd import ls
print(ls('-l', '*'))
Though, * will not be expanded so that will probably give you an error unless you have a file named *
. You can expand *
yourself:
from plumbum import local
filelist = local.cwd // '*'
print(ls('-l', filelist))
//
expands globs.