Skip to content

Commit d9f41d3

Browse files
pass list instead of string to subprocess.run()
1 parent 06994e0 commit d9f41d3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apertium/installer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ def _install_package_source() -> None:
113113
install_script_url = 'http://apertium.projectjj.com/apt/install-nightly.sh'
114114
with tempfile.NamedTemporaryFile('w') as install_script:
115115
urlretrieve(install_script_url, install_script.name)
116-
subprocess.call('sudo bash {}'.format(install_script.name), shell=True)
116+
execute = subprocess.run(['sudo', 'bash', install_script.name])
117+
execute.check_returncode()
117118

118119
@staticmethod
119120
def _download_packages(packages: List[str]) -> None:
120-
command = 'sudo apt-get -f --allow-unauthenticated install {}'
121-
for package in packages:
122-
subprocess.run(command.format(package), shell=True, check=True)
121+
command = ['sudo', 'apt-get', 'install'] + packages
122+
execute = subprocess.run(command)
123+
execute.check_returncode()
123124

124125
def install_apertium_language(self, languages: List[str]) -> None:
125126
self._download_packages(languages)

0 commit comments

Comments
 (0)