Message146155
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) |
|
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 | |
|