aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageialinux-online.org>2016-02-21 17:42:47 +0100
committerPapoteur <papoteur@mageialinux-online.org>2016-02-21 18:23:39 +0100
commit2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3 (patch)
tree204df9f192203f2b6b661a54d0f3a3b418043bdd
parent5824d1b5524d1d4e214e96fd0ba5cae772742ee4 (diff)
downloadmgarepo-2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3.tar
mgarepo-2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3.tar.gz
mgarepo-2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3.tar.bz2
mgarepo-2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3.tar.xz
mgarepo-2a16f0bd7ac38041f4a86995ebaa4c8a18aedec3.zip
move a command svn from log.py to util.py
Retablish a output after a svn command Revert "Retablish a output after a svn command" This reverts commit 3e5db62c699cbbf4120de2d7f68539ec388a8765.
-rw-r--r--MgaRepo/log.py23
-rw-r--r--MgaRepo/util.py22
2 files changed, 24 insertions, 21 deletions
diff --git a/MgaRepo/log.py b/MgaRepo/log.py
index 692e3d2..e02547f 100644
--- a/MgaRepo/log.py
+++ b/MgaRepo/log.py
@@ -2,6 +2,7 @@
from MgaRepo import Error, config, layout
from MgaRepo.svn import SVN
from MgaRepo.util import execcmd
+from MgaRepo.util import get_output_exec
from io import StringIO
@@ -14,7 +15,6 @@ import glob
import tempfile
import shutil
import subprocess
-import select
locale.setlocale(locale.LC_ALL, "C")
@@ -44,26 +44,7 @@ def getrelease(pkgdirurl, rev=None, macros=[], exported=None):
command = (("rpm -q --qf '%%{EPOCH}:%%{VERSION}-%%{RELEASE}\n' "
"--specfile %s %s") %
(specpath, options))
- output = StringIO()
- err = StringIO()
- p = subprocess.Popen(command, shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- of = p.stdout.fileno()
- ef = p.stderr.fileno()
- while True:
- r,w,x = select.select((of,ef), (), ())
- odata = None
- if of in r:
- odata = (os.read(of, 8192)).decode('utf8')
- output.write(odata)
- edata = None
- if ef in r:
- edata = (os.read(ef, 8192)).decode('utf8')
- err.write(edata)
- status = p.poll()
- if status is not None and odata == '' and edata == '':
- break
- output = output.getvalue()
+ output = get_output_exec(command)
releases = output.split()
try:
epoch, vr = releases[0].split(":", 1)
diff --git a/MgaRepo/util.py b/MgaRepo/util.py
index 28f950f..4b1308a 100644
--- a/MgaRepo/util.py
+++ b/MgaRepo/util.py
@@ -78,6 +78,28 @@ def execcmd(*cmd, **kwargs):
sys.stdout.write(output)
return status, output
+def get_output_exec(cmdstr):
+ output = StringIO()
+ err = StringIO()
+ p = subprocess.Popen(cmdstr, shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ of = p.stdout.fileno()
+ ef = p.stderr.fileno()
+ while True:
+ r,w,x = select.select((of,ef), (), ())
+ odata = None
+ if of in r:
+ odata = (os.read(of, 8192)).decode('utf8')
+ output.write(odata)
+ edata = None
+ if ef in r:
+ edata = (os.read(ef, 8192)).decode('utf8')
+ err.write(edata)
+ status = p.poll()
+ if status is not None and odata == '' and edata == '':
+ break
+ return output.getvalue()
+
def get_auth(username=None, password=None):
set_username = 1
set_password = 1