aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageialinux-online.org>2015-11-18 07:52:49 +0100
committerPapoteur <papoteur@mageialinux-online.org>2015-11-18 07:52:49 +0100
commit3433ecfc545316e13164de1c8779255a9ea797a5 (patch)
tree5249cf977736171b9dd8845b678d21dc09a4d55f
parent11c8e8abb541f4877a57c284342a6540be8478ae (diff)
downloadmgarepo-3433ecfc545316e13164de1c8779255a9ea797a5.tar
mgarepo-3433ecfc545316e13164de1c8779255a9ea797a5.tar.gz
mgarepo-3433ecfc545316e13164de1c8779255a9ea797a5.tar.bz2
mgarepo-3433ecfc545316e13164de1c8779255a9ea797a5.tar.xz
mgarepo-3433ecfc545316e13164de1c8779255a9ea797a5.zip
Apply language prefix C to all commands in util.py
-rw-r--r--MgaRepo/util.py14
1 files 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