aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo/util.py')
-rw-r--r--MgaRepo/util.py22
1 files changed, 22 insertions, 0 deletions
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