mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace use of magic constant since it is available as a named constant in py3
This commit is contained in:
parent
d8979c20cb
commit
72173970da
@ -22,7 +22,7 @@ PDFTOHTML = 'pdftohtml'
|
||||
|
||||
def popen(cmd, **kw):
|
||||
if iswindows:
|
||||
kw['creationflags'] = 0x08
|
||||
kw['creationflags'] = subprocess.DETACHED_PROCESS
|
||||
return subprocess.Popen(cmd, **kw)
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ def load_jxr_data(data):
|
||||
with lopen(os.path.join(tdir, 'input.jxr'), 'wb') as f:
|
||||
f.write(data)
|
||||
cmd = [get_exe_path('JxrDecApp'), '-i', 'input.jxr', '-o', 'output.tif']
|
||||
creationflags = 0x08 if iswindows else 0
|
||||
creationflags = subprocess.DETACHED_PROCESS if iswindows else 0
|
||||
subprocess.Popen(cmd, cwd=tdir, stdout=lopen(os.devnull, 'wb'), stderr=subprocess.STDOUT, creationflags=creationflags).wait()
|
||||
i = QImage()
|
||||
if not i.load(os.path.join(tdir, 'output.tif')):
|
||||
@ -544,7 +544,7 @@ def run_optimizer(file_path, cmd, as_filter=False, input_data=None):
|
||||
repl(True, iname), repl(False, oname)
|
||||
stdin = subprocess.PIPE if as_filter else None
|
||||
stderr = subprocess.PIPE if as_filter else subprocess.STDOUT
|
||||
creationflags = 0x08 if iswindows else 0
|
||||
creationflags = subprocess.DETACHED_PROCESS if iswindows else 0
|
||||
p = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=stderr, stdin=stdin, creationflags=creationflags)
|
||||
stderr = p.stderr if as_filter else p.stdout
|
||||
if as_filter:
|
||||
@ -644,7 +644,9 @@ def test(): # {{{
|
||||
despeckle_image(img)
|
||||
remove_borders_from_image(img)
|
||||
image_to_data(img, fmt='GIF')
|
||||
raw = subprocess.Popen([get_exe_path('JxrDecApp'), '-h'], creationflags=0x08 if iswindows else 0, stdout=subprocess.PIPE).stdout.read()
|
||||
raw = subprocess.Popen([get_exe_path('JxrDecApp'), '-h'],
|
||||
creationflags=subprocess.DETACHED_PROCESS if iswindows else 0,
|
||||
stdout=subprocess.PIPE).stdout.read()
|
||||
if b'JPEG XR Decoder Utility' not in raw:
|
||||
raise SystemExit('Failed to run JxrDecApp')
|
||||
# }}}
|
||||
|
@ -30,7 +30,7 @@ if iswindows:
|
||||
|
||||
def get_default_route_src_address_external():
|
||||
# Use -6 for IPv6 addresses
|
||||
raw = subprocess.check_output('route -4 print 0.0.0.0'.split(), creationflags=0x08).decode('utf-8', 'replace')
|
||||
raw = subprocess.check_output('route -4 print 0.0.0.0'.split(), creationflags=subprocess.DETACHED_PROCESS).decode('utf-8', 'replace')
|
||||
in_table = False
|
||||
default_gateway = get_address_of_default_gateway()
|
||||
for line in raw.splitlines():
|
||||
|
Loading…
x
Reference in New Issue
Block a user