Skip to content

Commit 97758ef

Browse files
committed
Don't use shell expansions and refactor.
1 parent 1fd90ec commit 97758ef

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

install-qt.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
'''
55
import os
66
import sys
7+
import subprocess
78

8-
def run(cmd):
9-
print(cmd)
10-
r = os.system(cmd)
11-
if r != 0:
12-
sys.exit('command %s failed with status %s' % (cmd, r))
9+
10+
def install(packages):
11+
print('Installing %s...' % ', '.join(packages))
12+
subprocess.check_call(['sudo', 'apt-get', 'install', '-qq'] + packages)
1313

1414
py3k = sys.version_info[0] == 3
1515
if os.environ['PYTEST_QT_API'] in ('pyqt4', 'pyqt5'):
1616
pyqt_ver = os.environ['PYTEST_QT_API'][-1]
1717
if py3k:
18-
run('sudo apt-get install -qq python3-pyqt%s{,-dbg}' % pyqt_ver)
18+
pkg = 'python3-pyqt%s' % pyqt_ver
1919
else:
20-
run('sudo apt-get install -qq python-qt%s{,-dbg}' % pyqt_ver)
20+
pkg = 'python-qt%s' % pyqt_ver
21+
install([pkg, pkg + '-dbg'])
2122
else:
2223
if py3k:
23-
run('sudo apt-get install -qq python3-pyside{,-dbg}')
24+
pkg = 'python3-pyside'
2425
else:
25-
run('sudo apt-get install -qq python-pyside{,-dbg}')
26-
26+
pkg = 'python-pyside'
27+
install([pkg, pkg + '-dbg'])

0 commit comments

Comments
 (0)