Message146155
| Author |
ncoghlan |
| Recipients |
alex, cvrebert, eric.araujo, ncoghlan, pitrou |
| Date |
2011年10月22日.01:10:22 |
| SpamBayes Score |
0.026233213 |
| Marked as misclassified |
No |
| Message-id |
<1319245822.94.0.219383408739.issue13238@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
That's a fair point, but I think it actually *improves* the argument for better helper functions, since we can have them automatically invoke shlex.quote() on all of the arguments:
def _shell_format(cmd, args, kwds):
args = map(shlex.quote, args)
kwds = {k:shlex.quote(v) for k, v in kwds}
return cmd.format(*args, **kwds)
def _invoke_shell(func, cmd, args, kwds):
return func(_shell_format(cmd, args, kwds), shell=True)
def format_shell_call(cmd, *args, kwds):
return _shell_format(cmd, args, kwds)
def shell_call(cmd, *args, **kwds):
return _invoke_shell(subprocess.call, cmds, args, kwds)
def check_shell_call(cmd, *args, **kwds):
return _invoke_shell(subprocess.check_call, cmds, args, kwds)
def check_shell_output(cmd, *args, **kwds):
return _invoke_shell(subprocess.check_output, cmds, args, kwds) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年10月22日 01:10:23 | ncoghlan | set | recipients:
+ ncoghlan, pitrou, eric.araujo, alex, cvrebert |
| 2011年10月22日 01:10:22 | ncoghlan | set | messageid: <1319245822.94.0.219383408739.issue13238@psf.upfronthosting.co.za> |
| 2011年10月22日 01:10:22 | ncoghlan | link | issue13238 messages |
| 2011年10月22日 01:10:22 | ncoghlan | create |
|