import sys
from subprocess import Popen, PIPE
cmd = ['uic', '-g', 'python'] + sys.argv[1:]
proc = Popen(cmd, stderr=PIPE, shell=True)
out, err = proc.communicate()
sys.exit(proc.returncode)

import sys
import subprocess as sp
cmd = ['uic', '-g', 'python'] + sys.argv[1:]
sys.exit(sp.run(cmd, stderr = sp.PIPE, shell = True).returncode)

simplify pyside2-uic.py