-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log command being executed #474
Comments
Have you seen the In [1]: from plumbum.cmd import uptime
In [2]: up = uptime['--pretty']
In [3]: up()
Out[3]: 'up 1 day, 23 minutes\n'
In [4]: up.run_fg()
up 1 day, 23 minutes
In [5]: import sys
In [6]: def logrun(cmd, fg=False):
...: print(cmd.formulate(), file=sys.stderr)
...: if not fg:
...: return cmd()
...: cmd.run_fg()
...:
In [7]: logrun(up)
['/bin/uptime', '--pretty']
Out[7]: 'up 1 day, 25 minutes\n'
In [8]: logrun(up, fg=True)
['/bin/uptime', '--pretty']
up 1 day, 28 minutes |
Oh yes, it seems pretty close to what I want. However I'm thinking on a replacement of Bash's For things like CI environments, where you usually want to know at which step a given command has failed, it's very useful. I miss an equivalent in plumbum, which I think could be supported upstream with a logger that always logs the command if instructed. It could be also attached to the machine log level. Something like: import logging
from plumbum import local, SshMachine
local.log_level = logging.DEBUG
remote = SshMachine("example.com")
remote.log_level = logging.INFO |
This is a very important feature. And it's missing. Must be made available as part of the package. Something similar to below could help build the feature into the package: |
I'm not sure if this is what you are looking for, but I've used
that outputs: |
In my bash scripts I can use
set -x
at the beginning, so bash keeps printing the command being executed.I found nothing similar in plumbum. I even tried with:
... no luck.
There should be a standard and documented way to make plumbum print the command it's going to execute. I guess a logger should do the trick. Example:
Thanks!
The text was updated successfully, but these errors were encountered: