mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Merge branch 'feature/UpdateScandir' into develop
This commit is contained in:
commit
b6ae9f529d
5 changed files with 724 additions and 672 deletions
|
@ -8,7 +8,9 @@
|
|||
* Update profilehooks module 1.10.0 (0ce1e29) to 1.10.1 (fdbf19d)
|
||||
* Update PySocks 1.6.8 (524ceb4) to 1.6.8 (b687a34)
|
||||
* Update Requests library 2.15.1 (282b01a) to 2.19.1 (33b41c7)
|
||||
* Update scandir module 1.6 (c3592ee) to 1.9.0 (9ab3d1f)
|
||||
* Add urllib3 release 1.23 (7c216f4)
|
||||
* Change if old scandir binary module is installed, fallback to slow Python module and inform user to upgrade binary
|
||||
|
||||
|
||||
[develop changelog]
|
||||
|
|
|
@ -10,6 +10,7 @@ Libs with customisations...
|
|||
/lib/hachoir_parser/guess.py
|
||||
/lib/hachoir_parser/misc/torrent.py
|
||||
/lib/lockfile/mkdirlockfile.py
|
||||
/lib/scandir/scandir.py
|
||||
/lib/tmdb_api/tmdb_api.py
|
||||
/lib/tornado
|
||||
/lib/tvdb_api/tvdb_api.py
|
||||
|
|
|
@ -265,6 +265,11 @@
|
|||
<span>$sg_str('NEWEST_VERSION_STRING')</span>
|
||||
</div>
|
||||
#end if
|
||||
#if $sg_str('MODULE_UPDATE_STRING')
|
||||
<div class="alert alert-success upgrade-notification" role="alert">
|
||||
<span>$sg_str('MODULE_UPDATE_STRING')</span>
|
||||
</div>
|
||||
#end if
|
||||
##
|
||||
#set $items = []
|
||||
#try
|
||||
|
|
|
@ -23,7 +23,6 @@ from os import listdir, lstat, stat, strerror
|
|||
from os.path import join, islink
|
||||
from stat import S_IFDIR, S_IFLNK, S_IFREG
|
||||
import collections
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
@ -36,12 +35,16 @@ try:
|
|||
except ImportError:
|
||||
ctypes = None
|
||||
|
||||
if _scandir is None and ctypes is None:
|
||||
import warnings
|
||||
warnings.warn("scandir can't find the compiled _scandir C module "
|
||||
"or ctypes, using slow generic fallback")
|
||||
|
||||
__version__ = '1.6'
|
||||
if None is not _scandir and None is not ctypes and not getattr(_scandir, 'DirEntry', None):
|
||||
import warnings
|
||||
warnings.warn("scandir compiled _scandir C module is too old, using slow generic fallback")
|
||||
_scandir = None
|
||||
elif _scandir is None and ctypes is None:
|
||||
import warnings
|
||||
warnings.warn("scandir can't find the compiled _scandir C module or ctypes, using slow generic fallback")
|
||||
|
||||
__version__ = '1.9.0'
|
||||
__all__ = ['scandir', 'walk']
|
||||
|
||||
# Windows FILE_ATTRIBUTE constants for interpreting the
|
||||
|
@ -96,6 +99,10 @@ class GenericDirEntry(object):
|
|||
self._lstat = lstat(self.path)
|
||||
return self._lstat
|
||||
|
||||
# The code duplication below is intentional: this is for slightly
|
||||
# better performance on systems that fall back to GenericDirEntry.
|
||||
# It avoids an additional attribute lookup and method call, which
|
||||
# are relatively slow on CPython.
|
||||
def is_dir(self, follow_symlinks=True):
|
||||
try:
|
||||
st = self.stat(follow_symlinks=follow_symlinks)
|
||||
|
@ -386,13 +393,17 @@ if sys.platform == 'win32':
|
|||
|
||||
if _scandir is not None:
|
||||
scandir_c = _scandir.scandir
|
||||
DirEntry_c = _scandir.DirEntry
|
||||
|
||||
if _scandir is not None:
|
||||
scandir = scandir_c
|
||||
DirEntry = DirEntry_c
|
||||
elif ctypes is not None:
|
||||
scandir = scandir_python
|
||||
DirEntry = Win32DirEntryPython
|
||||
else:
|
||||
scandir = scandir_generic
|
||||
DirEntry = GenericDirEntry
|
||||
|
||||
|
||||
# Linux, OS X, and BSD implementation
|
||||
|
@ -415,6 +426,16 @@ elif sys.platform.startswith(('linux', 'darwin', 'sunos5')) or 'bsd' in sys.plat
|
|||
('d_type', ctypes.c_byte),
|
||||
('d_name', ctypes.c_char * 256),
|
||||
)
|
||||
elif 'openbsd' in sys.platform:
|
||||
_fields_ = (
|
||||
('d_ino', ctypes.c_uint64),
|
||||
('d_off', ctypes.c_uint64),
|
||||
('d_reclen', ctypes.c_uint16),
|
||||
('d_type', ctypes.c_uint8),
|
||||
('d_namlen', ctypes.c_uint8),
|
||||
('__d_padding', ctypes.c_uint8 * 4),
|
||||
('d_name', ctypes.c_char * 256),
|
||||
)
|
||||
else:
|
||||
_fields_ = (
|
||||
('d_ino', ctypes.c_uint32), # must be uint32, not ulong
|
||||
|
@ -564,18 +585,23 @@ elif sys.platform.startswith(('linux', 'darwin', 'sunos5')) or 'bsd' in sys.plat
|
|||
|
||||
if _scandir is not None:
|
||||
scandir_c = _scandir.scandir
|
||||
DirEntry_c = _scandir.DirEntry
|
||||
|
||||
if _scandir is not None:
|
||||
scandir = scandir_c
|
||||
elif ctypes is not None:
|
||||
DirEntry = DirEntry_c
|
||||
elif ctypes is not None and have_dirent_d_type:
|
||||
scandir = scandir_python
|
||||
DirEntry = PosixDirEntry
|
||||
else:
|
||||
scandir = scandir_generic
|
||||
DirEntry = GenericDirEntry
|
||||
|
||||
|
||||
# Some other system -- no d_type or stat information
|
||||
else:
|
||||
scandir = scandir_generic
|
||||
DirEntry = GenericDirEntry
|
||||
|
||||
|
||||
def _walk(top, topdown=True, onerror=None, followlinks=False):
|
||||
|
|
|
@ -108,6 +108,7 @@ newznabProviderList = []
|
|||
torrentRssProviderList = []
|
||||
metadata_provider_dict = {}
|
||||
|
||||
MODULE_UPDATE_STRING = None
|
||||
NEWEST_VERSION_STRING = None
|
||||
VERSION_NOTIFY = False
|
||||
AUTO_UPDATE = False
|
||||
|
@ -572,7 +573,7 @@ def initialize(console_logging=True):
|
|||
global __INITIALIZED__, showList, providerList, newznabProviderList, torrentRssProviderList, \
|
||||
WEB_HOST, WEB_ROOT, ACTUAL_CACHE_DIR, CACHE_DIR, ZONEINFO_DIR, ADD_SHOWS_WO_DIR, CREATE_MISSING_SHOW_DIRS, \
|
||||
RECENTSEARCH_STARTUP, NAMING_FORCE_FOLDERS, SOCKET_TIMEOUT, DEBUG, INDEXER_DEFAULT, CONFIG_FILE, \
|
||||
REMOVE_FILENAME_CHARS, IMPORT_DEFAULT_CHECKED_SHOWS, WANTEDLIST_CACHE
|
||||
REMOVE_FILENAME_CHARS, IMPORT_DEFAULT_CHECKED_SHOWS, WANTEDLIST_CACHE, MODULE_UPDATE_STRING
|
||||
# Schedulers
|
||||
# global traktCheckerScheduler
|
||||
global recentSearchScheduler, backlogSearchScheduler, showUpdateScheduler, \
|
||||
|
@ -1460,6 +1461,23 @@ def initialize(console_logging=True):
|
|||
run_delay=datetime.timedelta(minutes=5),
|
||||
threadName='PLEXWATCHEDSTATE')
|
||||
|
||||
try:
|
||||
import _scandir
|
||||
except ImportError:
|
||||
_scandir = None
|
||||
|
||||
try:
|
||||
import ctypes
|
||||
except ImportError:
|
||||
ctypes = None
|
||||
|
||||
if None is not _scandir and None is not ctypes and not getattr(_scandir, 'DirEntry', None):
|
||||
MODULE_UPDATE_STRING = \
|
||||
'Your scandir binary module is outdated, using the slow but newer Python module.' \
|
||||
'<br>Upgrade the binary at a command prompt with' \
|
||||
' # <span class="boldest">python -m pip install -U scandir</span>' \
|
||||
'<br>Important: You <span class="boldest">must</span> Shutdown SickGear before upgrading'
|
||||
|
||||
__INITIALIZED__ = True
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in a new issue