Dont use win32process for creationflags

This commit is contained in:
Kovid Goyal 2020-10-15 10:15:13 +05:30
parent 511351317f
commit 32bbcd092d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 12 additions and 18 deletions

View File

@ -19,8 +19,7 @@ def run_calibre_debug(*args, **kw):
import subprocess
creationflags = 0
if iswindows:
import win32process
creationflags = win32process.CREATE_NO_WINDOW
creationflags = subprocess.CREATE_NO_WINDOW
cmd = get_debug_executable() + list(args)
kw['creationflags'] = creationflags
return subprocess.Popen(cmd, **kw)

View File

@ -845,8 +845,7 @@ class Device(DeviceConfig, DevicePlugin):
drives.append(x[0].upper())
def do_it(drives):
import win32process
subprocess.Popen([eject_exe()] + drives, creationflags=win32process.CREATE_NO_WINDOW).wait()
subprocess.Popen([eject_exe()] + drives, creationflags=subprocess.CREATE_NO_WINDOW).wait()
t = Thread(target=do_it, args=[drives])
t.daemon = True

View File

@ -87,8 +87,7 @@ def page_images(pdfpath, outputdir='.', first=1, last=1, image_format='jpeg', pr
outputdir = os.path.abspath(outputdir)
args = {}
if iswindows:
import win32process as w
args['creationflags'] = w.HIGH_PRIORITY_CLASS | w.CREATE_NO_WINDOW
args['creationflags'] = subprocess.HIGH_PRIORITY_CLASS | subprocess.CREATE_NO_WINDOW
try:
subprocess.check_call([
pdftoppm, '-cropbox', '-' + image_format, '-f', unicode_type(first),

View File

@ -15,7 +15,6 @@ from polyglot.builtins import string_or_bytes, environ_item, native_string_type,
from polyglot.binary import as_hex_unicode
if iswindows:
import win32process
try:
windows_null_file = open(os.devnull, 'wb')
except:
@ -160,10 +159,10 @@ class Worker(object):
}
if iswindows:
priority = {
'high' : win32process.HIGH_PRIORITY_CLASS,
'normal' : win32process.NORMAL_PRIORITY_CLASS,
'low' : win32process.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = win32process.CREATE_NO_WINDOW|priority
'high' : subprocess.HIGH_PRIORITY_CLASS,
'normal' : subprocess.NORMAL_PRIORITY_CLASS,
'low' : subprocess.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = subprocess.CREATE_NO_WINDOW|priority
else:
niceness = {
'normal' : 0,

View File

@ -147,12 +147,11 @@ def start_pipe_worker(command, env=None, priority='normal', **process_args):
args = {'stdout':subprocess.PIPE, 'stdin':subprocess.PIPE, 'env':w.env}
args.update(process_args)
if iswindows:
import win32process
priority = {
'high' : win32process.HIGH_PRIORITY_CLASS,
'normal' : win32process.NORMAL_PRIORITY_CLASS,
'low' : win32process.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = win32process.CREATE_NO_WINDOW|priority
'high' : subprocess.HIGH_PRIORITY_CLASS,
'normal' : subprocess.NORMAL_PRIORITY_CLASS,
'low' : subprocess.IDLE_PRIORITY_CLASS}[priority]
args['creationflags'] = subprocess.CREATE_NO_WINDOW|priority
else:
niceness = {'normal' : 0, 'low' : 10, 'high' : 20}[priority]
args['env']['CALIBRE_WORKER_NICENESS'] = str(niceness)

View File

@ -50,8 +50,7 @@ def run_worker(mod, func, **kw):
env = kw.get('env', os.environ.copy())
env['CALIBRE_SIMPLE_WORKER'] = mod + ':' + func
if iswindows:
import win32process
kw['creationflags'] = win32process.CREATE_NO_WINDOW
kw['creationflags'] = subprocess.CREATE_NO_WINDOW
kw['env'] = {native_string_type(k): native_string_type(v)
for k, v in iteritems(env)} # windows needs bytes in env
return subprocess.Popen(exe, **kw)