mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont import any pywin32 modules during startup
Also dont import fcntl
This commit is contained in:
parent
21214f9dc3
commit
cbf6e80b08
@ -18,17 +18,15 @@ except EnvironmentError:
|
|||||||
|
|
||||||
from calibre.constants import (iswindows, ismacos, islinux, isfrozen,
|
from calibre.constants import (iswindows, ismacos, islinux, isfrozen,
|
||||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||||
win32event, win32api, winerror, fcntl, plugins,
|
fcntl, plugins, filesystem_encoding, config_dir)
|
||||||
filesystem_encoding, config_dir)
|
from calibre.startup import winutil
|
||||||
from calibre.startup import winutil, winutilerror
|
|
||||||
from calibre.utils.icu import safe_chr
|
from calibre.utils.icu import safe_chr
|
||||||
from calibre.prints import prints
|
from calibre.prints import prints
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# Prevent pyflakes from complaining
|
# Prevent pyflakes from complaining
|
||||||
winutil, winutilerror, __appname__, islinux, __version__
|
winutil, __appname__, islinux, __version__
|
||||||
fcntl, win32event, isfrozen, __author__
|
fcntl, isfrozen, __author__, isbsd, config_dir, plugins
|
||||||
winerror, win32api, isbsd, config_dir, plugins
|
|
||||||
|
|
||||||
_mt_inited = False
|
_mt_inited = False
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv
|
from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv
|
||||||
import sys, locale, codecs, os, importlib, collections
|
import sys, locale, codecs, os, collections
|
||||||
|
|
||||||
__appname__ = 'calibre'
|
__appname__ = 'calibre'
|
||||||
numeric_version = (5, 3, 0)
|
numeric_version = (5, 3, 0)
|
||||||
@ -50,10 +50,6 @@ try:
|
|||||||
except:
|
except:
|
||||||
preferred_encoding = 'utf-8'
|
preferred_encoding = 'utf-8'
|
||||||
|
|
||||||
win32event = importlib.import_module('win32event') if iswindows else None
|
|
||||||
winerror = importlib.import_module('winerror') if iswindows else None
|
|
||||||
win32api = importlib.import_module('win32api') if iswindows else None
|
|
||||||
fcntl = None if iswindows else importlib.import_module('fcntl')
|
|
||||||
dark_link_color = '#6cb4ee'
|
dark_link_color = '#6cb4ee'
|
||||||
builtin_colors_light = {
|
builtin_colors_light = {
|
||||||
'yellow': '#ffeb6b',
|
'yellow': '#ffeb6b',
|
||||||
|
@ -11,7 +11,7 @@ import time
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
__appname__, fcntl, filesystem_encoding, islinux, ismacos, iswindows
|
__appname__, filesystem_encoding, islinux, ismacos, iswindows
|
||||||
)
|
)
|
||||||
from calibre_extensions import speedup
|
from calibre_extensions import speedup
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
@ -23,6 +23,7 @@ if iswindows:
|
|||||||
excl_file_mode = stat.S_IREAD | stat.S_IWRITE
|
excl_file_mode = stat.S_IREAD | stat.S_IWRITE
|
||||||
else:
|
else:
|
||||||
excl_file_mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
excl_file_mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||||
|
import fcntl
|
||||||
|
|
||||||
|
|
||||||
def unix_open(path):
|
def unix_open(path):
|
||||||
|
@ -12,7 +12,7 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre.constants import cache_dir, fcntl, iswindows
|
from calibre.constants import cache_dir, iswindows
|
||||||
from calibre.utils.lock import ExclusiveFile, create_single_instance_mutex, unix_open
|
from calibre.utils.lock import ExclusiveFile, create_single_instance_mutex, unix_open
|
||||||
from calibre.utils.tdir_in_cache import (
|
from calibre.utils.tdir_in_cache import (
|
||||||
clean_tdirs_in, is_tdir_locked, retry_lock_tdir, tdir_in_cache, tdirs_in,
|
clean_tdirs_in, is_tdir_locked, retry_lock_tdir, tdir_in_cache, tdirs_in,
|
||||||
@ -84,6 +84,7 @@ class IPCLockTest(unittest.TestCase):
|
|||||||
t.start(), t.join()
|
t.start(), t.join()
|
||||||
self.assertIs(t.locked, False)
|
self.assertIs(t.locked, False)
|
||||||
if not iswindows:
|
if not iswindows:
|
||||||
|
import fcntl
|
||||||
with unix_open(fname) as f:
|
with unix_open(fname) as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1, fcntl.fcntl(f.fileno(), fcntl.F_GETFD) & fcntl.FD_CLOEXEC
|
1, fcntl.fcntl(f.fileno(), fcntl.F_GETFD) & fcntl.FD_CLOEXEC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user