mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Don't modify commands when logging them
This commit is contained in:
parent
be79f00dff
commit
1b93ed57ed
@ -20,6 +20,12 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def escape_arg(arg):
|
||||
"Shell-escpae arg, if necessary"
|
||||
if ' ' not in arg:
|
||||
return arg
|
||||
return '"%s"' % arg.replace('\\', r'\\').replace('"', r'\"')
|
||||
|
||||
class Logger(object):
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
verbose = False
|
||||
@ -30,10 +36,9 @@ class Logger(object):
|
||||
@classmethod
|
||||
def command(cls, cmd):
|
||||
if cls.verbose:
|
||||
for i in xrange(len(cmd)):
|
||||
if cmd[i].find(" ") >= 0:
|
||||
cmd[i] = '"' + cmd[i] + '"'
|
||||
print >> cls.stdout, "%s: I: %s" % (cls.script_name, " ".join(cmd))
|
||||
print >> cls.stdout, "%s: I: %s" % (cls.script_name,
|
||||
" ".join(escape_arg(arg)
|
||||
for arg in cmd))
|
||||
|
||||
@classmethod
|
||||
def debug(cls, message, *args):
|
||||
|
Loading…
x
Reference in New Issue
Block a user