(testing)
This commit is contained in:
angelblue05 2016-08-21 21:51:23 -05:00
parent 8cd4cb903e
commit 8b9b0821c0
3 changed files with 44 additions and 42 deletions

View file

@ -254,7 +254,7 @@ class Artwork():
while len(self.imageCacheThreads): while len(self.imageCacheThreads):
for thread in self.imageCacheThreads: for thread in self.imageCacheThreads:
if thread.isFinished: if thread.is_finished:
self.imageCacheThreads.remove(thread) self.imageCacheThreads.remove(thread)
pdialog.update(100, "%s %s" % (lang(33046), len(self.imageCacheThreads))) pdialog.update(100, "%s %s" % (lang(33046), len(self.imageCacheThreads)))
log.info("Waiting for all threads to exit: %s" % len(self.imageCacheThreads)) log.info("Waiting for all threads to exit: %s" % len(self.imageCacheThreads))
@ -267,15 +267,15 @@ class Artwork():
while True: while True:
# removed finished # removed finished
for thread in self.imageCacheThreads: for thread in self.imageCacheThreads:
if thread.isFinished: if thread.is_finished:
self.imageCacheThreads.remove(thread) self.imageCacheThreads.remove(thread)
# add a new thread or wait and retry if we hit our limit # add a new thread or wait and retry if we hit our limit
if len(self.imageCacheThreads) < self.imageCacheLimitThreads: if len(self.imageCacheThreads) < self.imageCacheLimitThreads:
newThread = image_cache_thread.image_cache_thread() newThread = image_cache_thread.ImageCacheThread()
newThread.setUrl(self.double_urlencode(url)) newThread.set_url(self.double_urlencode(url))
newThread.setHost(self.xbmc_host, self.xbmc_port) newThread.set_host(self.xbmc_host, self.xbmc_port)
newThread.setAuth(self.xbmc_username, self.xbmc_password) newThread.set_auth(self.xbmc_username, self.xbmc_password)
newThread.start() newThread.start()
self.imageCacheThreads.append(newThread) self.imageCacheThreads.append(newThread)
return return

View file

@ -3,8 +3,8 @@
################################################################################################# #################################################################################################
import logging import logging
import requests
import threading 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 url_to_process = None
isFinished = False is_finished = False
xbmc_host = "" xbmc_host = ""
xbmc_port = "" xbmc_port = ""
@ -28,33 +28,34 @@ class image_cache_thread(threading.Thread):
threading.Thread.__init__(self) 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_host = host
self.xbmc_port = port self.xbmc_port = port
def setAuth(self, user, pwd): def set_auth(self, username, password):
self.xbmc_username = user self.xbmc_username = username
self.xbmc_password = pwd self.xbmc_password = password
def run(self): def run(self):
log.debug("Image Caching Thread Processing: %s" % self.urlToProcess) log.debug("Image Caching Thread Processing: %s" % self.url_to_process)
try: try:
response = requests.head( requests.head(
url=( url=(
"http://%s:%s/image/image://%s" "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), auth=(self.xbmc_username, self.xbmc_password),
timeout=(35.1, 35.1)) timeout=(35.1, 35.1))
# We don't need the result # We don't need the result
except: pass except:
pass
log.debug("Image Caching Thread Exited") log.debug("Image Caching Thread Exited")
self.isFinished = True self.is_finished = True

View file

@ -26,13 +26,14 @@ class LogHandler(logging.StreamHandler):
def emit(self, record): def emit(self, record):
if self._getLogLevel(record.levelno): if self._get_log_level(record.levelno):
try: try:
xbmc.log(self.format(record), level=xbmc.LOGNOTICE) xbmc.log(self.format(record), level=xbmc.LOGNOTICE)
except UnicodeEncodeError: except UnicodeEncodeError:
xbmc.log(self.format(record).encode('utf-8'), level=xbmc.LOGNOTICE) xbmc.log(self.format(record).encode('utf-8'), level=xbmc.LOGNOTICE)
def _getLogLevel(self, level): @classmethod
def _get_log_level(cls, level):
levels = { levels = {
logging.ERROR: 0, logging.ERROR: 0,
@ -41,11 +42,11 @@ class LogHandler(logging.StreamHandler):
logging.DEBUG: 2 logging.DEBUG: 2
} }
try: try:
logLevel = int(window('emby_logLevel')) log_level = int(window('emby_logLevel'))
except ValueError: except ValueError:
logLevel = 0 log_level = 0
return logLevel >= levels[level] return log_level >= levels[level]
class MyFormatter(logging.Formatter): class MyFormatter(logging.Formatter):