mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Pylint
(testing)
This commit is contained in:
parent
8cd4cb903e
commit
8b9b0821c0
3 changed files with 44 additions and 42 deletions
|
@ -254,7 +254,7 @@ class Artwork():
|
|||
|
||||
while len(self.imageCacheThreads):
|
||||
for thread in self.imageCacheThreads:
|
||||
if thread.isFinished:
|
||||
if thread.is_finished:
|
||||
self.imageCacheThreads.remove(thread)
|
||||
pdialog.update(100, "%s %s" % (lang(33046), len(self.imageCacheThreads)))
|
||||
log.info("Waiting for all threads to exit: %s" % len(self.imageCacheThreads))
|
||||
|
@ -267,15 +267,15 @@ class Artwork():
|
|||
while True:
|
||||
# removed finished
|
||||
for thread in self.imageCacheThreads:
|
||||
if thread.isFinished:
|
||||
if thread.is_finished:
|
||||
self.imageCacheThreads.remove(thread)
|
||||
|
||||
# add a new thread or wait and retry if we hit our limit
|
||||
if len(self.imageCacheThreads) < self.imageCacheLimitThreads:
|
||||
newThread = image_cache_thread.image_cache_thread()
|
||||
newThread.setUrl(self.double_urlencode(url))
|
||||
newThread.setHost(self.xbmc_host, self.xbmc_port)
|
||||
newThread.setAuth(self.xbmc_username, self.xbmc_password)
|
||||
newThread = image_cache_thread.ImageCacheThread()
|
||||
newThread.set_url(self.double_urlencode(url))
|
||||
newThread.set_host(self.xbmc_host, self.xbmc_port)
|
||||
newThread.set_auth(self.xbmc_username, self.xbmc_password)
|
||||
newThread.start()
|
||||
self.imageCacheThreads.append(newThread)
|
||||
return
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import requests
|
||||
import threading
|
||||
import requests
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -12,10 +12,10 @@ log = logging.getLogger("EMBY."+__name__)
|
|||
|
||||
#################################################################################################
|
||||
|
||||
class image_cache_thread(threading.Thread):
|
||||
class ImageCacheThread(threading.Thread):
|
||||
|
||||
urlToProcess = None
|
||||
isFinished = False
|
||||
url_to_process = None
|
||||
is_finished = False
|
||||
|
||||
xbmc_host = ""
|
||||
xbmc_port = ""
|
||||
|
@ -28,33 +28,34 @@ class image_cache_thread(threading.Thread):
|
|||
threading.Thread.__init__(self)
|
||||
|
||||
|
||||
def setUrl(self, url):
|
||||
def set_url(self, url):
|
||||
|
||||
self.urlToProcess = url
|
||||
self.url_to_process = url
|
||||
|
||||
def setHost(self, host, port):
|
||||
def set_host(self, host, port):
|
||||
|
||||
self.xbmc_host = host
|
||||
self.xbmc_port = port
|
||||
|
||||
def setAuth(self, user, pwd):
|
||||
def set_auth(self, username, password):
|
||||
|
||||
self.xbmc_username = user
|
||||
self.xbmc_password = pwd
|
||||
self.xbmc_username = username
|
||||
self.xbmc_password = password
|
||||
|
||||
def run(self):
|
||||
|
||||
log.debug("Image Caching Thread Processing: %s" % self.urlToProcess)
|
||||
log.debug("Image Caching Thread Processing: %s" % self.url_to_process)
|
||||
|
||||
try:
|
||||
response = requests.head(
|
||||
requests.head(
|
||||
url=(
|
||||
"http://%s:%s/image/image://%s"
|
||||
% (self.xbmc_host, self.xbmc_port, self.urlToProcess)),
|
||||
% (self.xbmc_host, self.xbmc_port, self.url_to_process)),
|
||||
auth=(self.xbmc_username, self.xbmc_password),
|
||||
timeout=(35.1, 35.1))
|
||||
# We don't need the result
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
|
||||
log.debug("Image Caching Thread Exited")
|
||||
self.isFinished = True
|
||||
self.is_finished = True
|
||||
|
|
|
@ -26,13 +26,14 @@ class LogHandler(logging.StreamHandler):
|
|||
|
||||
def emit(self, record):
|
||||
|
||||
if self._getLogLevel(record.levelno):
|
||||
if self._get_log_level(record.levelno):
|
||||
try:
|
||||
xbmc.log(self.format(record), level=xbmc.LOGNOTICE)
|
||||
except UnicodeEncodeError:
|
||||
xbmc.log(self.format(record).encode('utf-8'), level=xbmc.LOGNOTICE)
|
||||
|
||||
def _getLogLevel(self, level):
|
||||
@classmethod
|
||||
def _get_log_level(cls, level):
|
||||
|
||||
levels = {
|
||||
logging.ERROR: 0,
|
||||
|
@ -41,11 +42,11 @@ class LogHandler(logging.StreamHandler):
|
|||
logging.DEBUG: 2
|
||||
}
|
||||
try:
|
||||
logLevel = int(window('emby_logLevel'))
|
||||
log_level = int(window('emby_logLevel'))
|
||||
except ValueError:
|
||||
logLevel = 0
|
||||
log_level = 0
|
||||
|
||||
return logLevel >= levels[level]
|
||||
return log_level >= levels[level]
|
||||
|
||||
|
||||
class MyFormatter(logging.Formatter):
|
||||
|
|
Loading…
Reference in a new issue