use os.system instead of subprocess to avoid compressor commands never returning
This commit is contained in:
parent
082a4f359f
commit
74c478567d
1 changed files with 10 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# vim: tabstop=4 shiftwidth=4 expandtab
|
# vim: tabstop=4 shiftwidth=4 expandtab
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import renderlib
|
import renderlib
|
||||||
import argparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -100,21 +99,21 @@ def fmt_command(command, **kwargs):
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
args[key] = shlex.quote(value)
|
args[key] = shlex.quote(value)
|
||||||
|
|
||||||
command = command.format(**args)
|
return command.format(**args)
|
||||||
return shlex.split(command)
|
|
||||||
|
|
||||||
|
|
||||||
def run(command, **kwargs):
|
def run(command, **kwargs):
|
||||||
return subprocess.check_call(
|
os.system(fmt_command(command, **kwargs))
|
||||||
fmt_command(command, **kwargs))
|
|
||||||
|
|
||||||
|
|
||||||
def run_output(command, **kwargs):
|
def run_output(command, **kwargs):
|
||||||
return subprocess.check_output(
|
# Apple Compressor behaves weirdly with its stdout. It will not terminate right when ran through
|
||||||
fmt_command(command, **kwargs),
|
# os.subprocess, but work fine when run via os.system. To still get the output, we pipe it into a
|
||||||
encoding='utf-8',
|
# tempfile. This solution is quite stable.
|
||||||
stderr=subprocess.STDOUT)
|
# see https://twitter.com/mazdermind/status/1588286020121870336
|
||||||
|
with tempfile.NamedTemporaryFile() as t:
|
||||||
|
cmd = fmt_command(command, **kwargs)
|
||||||
|
os.system(f'{cmd} >{t.name} 2>&1')
|
||||||
|
return t.read().decode('utf-8')
|
||||||
|
|
||||||
def enqueue_job(event):
|
def enqueue_job(event):
|
||||||
event_id = str(event['id'])
|
event_id = str(event['id'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue