Skip to content

Commit 20da9c6

Browse files
authored
Use subprocess.call in emrun. NFC (#25956)
This function is already used on the lines below but for some reason this usage was missed. Also, fix a broken comment and add use f-strings in couple more places.
1 parent 746da8d commit 20da9c6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

emrun.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,15 @@ def kill_browser_process():
389389

390390
if processname_killed_atexit:
391391
if emrun_options.android:
392-
logv("Terminating Android app '" + processname_killed_atexit + "'.")
392+
logv(f"Terminating Android app '{processname_killed_atexit}'.")
393393
subprocess.call([ADB, 'shell', 'am', 'force-stop', processname_killed_atexit])
394394
else:
395-
logv("Terminating all processes that have string '" + processname_killed_atexit + "' in their name.")
395+
logv(f"Terminating all processes that have string '{processname_killed_atexit}' in their name.")
396396
if WINDOWS:
397-
process_image = processname_killed_atexit if '.exe' in processname_killed_atexit else (processname_killed_atexit + '.exe')
398-
process = subprocess.Popen(['taskkill', '/F', '/IM', process_image, '/T'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
399-
process.communicate()
397+
process_image = processname_killed_atexit
398+
if not process_image.endswith('.exe'):
399+
process_image += '.exe'
400+
subprocess.call(['taskkill', '/F', '/IM', process_image, '/T'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
400401
else:
401402
try:
402403
subprocess.call(['pkill', processname_killed_atexit])
@@ -749,7 +750,7 @@ def do_POST(self): # # noqa: DC04
749750
self.wfile.write(b'OK')
750751

751752

752-
# Returns stdout by running command with universal_newlines=True
753+
# Returns stdout by running command with text=True
753754
def check_output(cmd, *args, **kwargs):
754755
return subprocess.run(cmd, text=True, stdout=subprocess.PIPE, check=True, *args, **kwargs).stdout
755756

0 commit comments

Comments
 (0)