Bug 1471641 - Use subprocess check_call and check_output in mozinstall r=davehunt

We were using more primitive methods before to support python 2.4, but
that's obviously no longer required.

Differential Revision: https://phabricator.services.mozilla.com/D15539

--HG--
extra : moz-landing-system : lando
This commit is contained in:
William Lachance 2019-01-02 09:53:20 +00:00
Родитель 0e4c73be9d
Коммит af30ba4ef7
1 изменённых файлов: 7 добавлений и 14 удалений

Просмотреть файл

@ -285,13 +285,10 @@ def _install_dmg(src, dest):
# According to the Apple doc, the hdiutil output is stable and is based on the tab
# separators
# Therefor, $3 should give us the mounted path
proc = subprocess.Popen('hdiutil attach -nobrowse -noautoopen "%s"'
'|grep /Volumes/'
'|awk \'BEGIN{FS="\t"} {print $3}\'' % src,
shell=True,
stdout=subprocess.PIPE)
appDir = proc.communicate()[0].strip()
appDir = subprocess.check_output('hdiutil attach -nobrowse -noautoopen "%s"'
'|grep /Volumes/'
'|awk \'BEGIN{FS="\t"} {print $3}\'' % str(src),
shell=True).strip()
for appFile in os.listdir(appDir):
if appFile.endswith('.app'):
@ -310,8 +307,8 @@ def _install_dmg(src, dest):
finally:
if appDir:
subprocess.call('hdiutil detach "%s" -quiet' % appDir,
shell=True)
subprocess.check_call('hdiutil detach "%s" -quiet' % appDir,
shell=True)
return dest
@ -334,11 +331,7 @@ def _install_exe(src, dest):
os.environ['__compat_layer'] = 'RunAsInvoker'
cmd = '"%s" /extractdir=%s' % (src, os.path.realpath(dest))
# As long as we support Python 2.4 check_call will not be available.
result = subprocess.call(cmd)
if result is not 0:
raise Exception('Execution of installer failed.')
subprocess.check_call(cmd)
return dest