From 3433ecfc545316e13164de1c8779255a9ea797a5 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Wed, 18 Nov 2015 07:52:49 +0100 Subject: Apply language prefix C to all commands in util.py --- MgaRepo/util.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MgaRepo/util.py b/MgaRepo/util.py index 45d2e4f..b151c7f 100644 --- a/MgaRepo/util.py +++ b/MgaRepo/util.py @@ -17,6 +17,7 @@ import httplib2 def commands_getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" import os + print('Commande : ',cmd) pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') text = pipe.read() sts = pipe.close() @@ -26,11 +27,15 @@ def commands_getstatusoutput(cmd): def execcmd(*cmd, **kwargs): cmdstr = " ".join(cmd) + if kwargs.get('info'): + prefix='LANGUAGE=C LC_TIME=C ' + else: + prefix='LANG=C LANGUAGE=C LC_ALL=C ' if kwargs.get("show"): if kwargs.get("geterr"): err = BytesIO() pstdin = kwargs.get("stdin") if kwargs.get("stdin") else None - p = subprocess.Popen(cmdstr, shell=True, + p = subprocess.Popen(prefix + cmdstr, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=pstdin) of = p.stdout.fileno() @@ -53,13 +58,9 @@ def execcmd(*cmd, **kwargs): break output = err.getvalue() else: - status = os.system(cmdstr) + status = os.system(prefix + cmdstr) output = "" else: - if kwargs.get('info'): - prefix='LANGUAGE=C LC_TIME=C ' - else: - prefix='LANG=C LANGUAGE=C LC_ALL=C ' status, output = commands_getstatusoutput(prefix + cmdstr) verbose = config.getbool("global", "verbose", 0) if status != 0 and not kwargs.get("noerror"): @@ -68,7 +69,6 @@ def execcmd(*cmd, **kwargs): else: raise Error("command failed: %s\n%s\n" % (cmdstr, output)) if verbose: - print(cmdstr) sys.stdout.buffer.write(output) return status, output -- cgit v1.2.1