mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
runcmd(): Run program and check return code
This commit is contained in:
parent
165f0defa7
commit
3f1edd2791
@ -20,6 +20,7 @@
|
||||
import socket
|
||||
import os
|
||||
import pwd
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@ -83,3 +84,16 @@ def mk_homedir_path(username, homedir_path):
|
||||
os.chown(homedir, uid=uid, gid=gid)
|
||||
longer_path = os.path.join(longer_path, elem)
|
||||
|
||||
def runcmd(command_name):
|
||||
'''
|
||||
Run application.
|
||||
'''
|
||||
try:
|
||||
with subprocess.Popen(command_name, stdout=subprocess.PIPE) as proc:
|
||||
value = proc.stdout.read().decode('utf-8')
|
||||
proc.wait()
|
||||
rc = proc.returncode
|
||||
return (rc, value)
|
||||
except Exception as exc:
|
||||
print(str(exc))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user