Fix logging

This commit is contained in:
angelblue05 2016-06-19 23:09:07 -05:00
parent 423a4c9c40
commit f47ead1ddc

View file

@ -24,12 +24,11 @@ import playlist
import playbackutils as pbutils import playbackutils as pbutils
import playutils import playutils
import api import api
from utils import Logging, window, settings from utils import Logging, window, settings, language as lang
log = Logging('Entrypoint').log
################################################################################################# #################################################################################################
log = Logging('Entrypoint').log
def doPlayback(itemid, dbid): def doPlayback(itemid, dbid):
@ -46,7 +45,7 @@ def resetAuth():
"Emby might lock your account if you fail to log in too many times. " "Emby might lock your account if you fail to log in too many times. "
"Proceed anyway?")) "Proceed anyway?"))
if resp == 1: if resp == 1:
log("EMBY", "Reset login attempts.", 1) log("Reset login attempts.", 1)
window('emby_serverStatus', value="Auth") window('emby_serverStatus', value="Auth")
else: else:
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
@ -108,16 +107,15 @@ def resetDeviceId():
window('emby_deviceId', clear=True) window('emby_deviceId', clear=True)
deviceId = clientinfo.ClientInfo().getDeviceId(reset=True) deviceId = clientinfo.ClientInfo().getDeviceId(reset=True)
except Exception as e: except Exception as e:
log("EMBY", "Failed to generate a new device Id: %s" % e, 1) log("Failed to generate a new device Id: %s" % e, 1)
dialog.ok( dialog.ok(
heading="Emby for Kodi", heading="Emby for Kodi",
line1=language(33032)) line1=language(33032))
else: else:
log("EMBY", "Successfully removed old deviceId: %s New deviceId: %s" log("Successfully removed old deviceId: %s New deviceId: %s" % (deviceId_old, deviceId), 1)
% (deviceId_old, deviceId), 1)
dialog.ok( dialog.ok(
heading="Emby for Kodi", heading=lang(29999),
line1=language(33033)) line1=lang(33033))
xbmc.executebuiltin('RestartApp') xbmc.executebuiltin('RestartApp')
##### Delete Item ##### Delete Item
@ -141,7 +139,7 @@ def deleteItem():
elif xbmc.getCondVisibility('Container.Content(pictures)'): elif xbmc.getCondVisibility('Container.Content(pictures)'):
itemtype = "picture" itemtype = "picture"
else: else:
log("EMBY delete", "Unknown type, unable to proceed.", 1) log("Unknown type, unable to proceed.", 1)
return return
embyconn = utils.kodiSQL('emby') embyconn = utils.kodiSQL('emby')
@ -153,7 +151,7 @@ def deleteItem():
try: try:
embyid = item[0] embyid = item[0]
except TypeError: except TypeError:
log("EMBY delete", "Unknown embyId, unable to proceed.", 1) log("Unknown embyId, unable to proceed.", 1)
return return
if settings('skipContextMenu') != "true": if settings('skipContextMenu') != "true":
@ -162,12 +160,12 @@ def deleteItem():
line1=("Delete file from Emby Server? This will " line1=("Delete file from Emby Server? This will "
"also delete the file(s) from disk!")) "also delete the file(s) from disk!"))
if not resp: if not resp:
log("EMBY delete", "User skipped deletion for: %s." % embyid, 1) log("User skipped deletion for: %s." % embyid, 1)
return return
doUtils = downloadutils.DownloadUtils() doUtils = downloadutils.DownloadUtils()
url = "{server}/emby/Items/%s?format=json" % embyid url = "{server}/emby/Items/%s?format=json" % embyid
log("EMBY delete", "Deleting request: %s" % embyid, 0) log("Deleting request: %s" % embyid, 0)
doUtils.downloadUrl(url, action_type="DELETE") doUtils.downloadUrl(url, action_type="DELETE")
##### ADD ADDITIONAL USERS ##### ##### ADD ADDITIONAL USERS #####
@ -249,7 +247,7 @@ def addUser():
return return
# Subtract any additional users # Subtract any additional users
log("EMBY", "Displaying list of users: %s" % users) log("Displaying list of users: %s" % users)
resp = dialog.select("Add user to the session", users) resp = dialog.select("Add user to the session", users)
# post additional user # post additional user
if resp > -1: if resp > -1:
@ -264,7 +262,7 @@ def addUser():
time=1000) time=1000)
except: except:
log("EMBY", "Failed to add user to session.") log("Failed to add user to session.")
dialog.notification( dialog.notification(
heading="Error", heading="Error",
message="Unable to add/remove user from the session.", message="Unable to add/remove user from the session.",
@ -320,7 +318,7 @@ def getThemeMedia():
tvtunes = xbmcaddon.Addon(id="script.tvtunes") tvtunes = xbmcaddon.Addon(id="script.tvtunes")
tvtunes.setSetting('custom_path_enable', "true") tvtunes.setSetting('custom_path_enable', "true")
tvtunes.setSetting('custom_path', library) tvtunes.setSetting('custom_path', library)
log("EMBY", "TV Tunes custom path is enabled and set.", 1) log("TV Tunes custom path is enabled and set.", 1)
else: else:
# if it does not exist this will not work so warn user # if it does not exist this will not work so warn user
# often they need to edit the settings first for it to be created. # often they need to edit the settings first for it to be created.
@ -470,7 +468,7 @@ def refreshPlaylist():
sound=False) sound=False)
except Exception as e: except Exception as e:
log("EMBY", "Refresh playlists/nodes failed: %s" % e, 1) log("Refresh playlists/nodes failed: %s" % e, 1)
dialog.notification( dialog.notification(
heading="Emby for Kodi", heading="Emby for Kodi",
message="Emby playlists/nodes refresh failed", message="Emby playlists/nodes refresh failed",
@ -512,7 +510,7 @@ def BrowseContent(viewname, browse_type="", folderid=""):
break break
if viewname is not None: if viewname is not None:
log("BrowseContent","viewname: %s - type: %s - folderid: %s - filter: %s" %(viewname.decode('utf-8'), browse_type.decode('utf-8'), folderid.decode('utf-8'), filter_type.decode('utf-8'))) log("viewname: %s - type: %s - folderid: %s - filter: %s" %(viewname.decode('utf-8'), browse_type.decode('utf-8'), folderid.decode('utf-8'), filter_type.decode('utf-8')))
#set the correct params for the content type #set the correct params for the content type
#only proceed if we have a folderid #only proceed if we have a folderid
if folderid: if folderid:
@ -1045,7 +1043,7 @@ def getExtraFanArt(embyId,embyPath):
if embyId: if embyId:
#only proceed if we actually have a emby id #only proceed if we actually have a emby id
log("EMBY", "Requesting extrafanart for Id: %s" % embyId, 0) log("Requesting extrafanart for Id: %s" % embyId, 0)
# We need to store the images locally for this to work # We need to store the images locally for this to work
# because of the caching system in xbmc # because of the caching system in xbmc
@ -1074,7 +1072,7 @@ def getExtraFanArt(embyId,embyPath):
xbmcvfs.copy(backdrop, fanartFile) xbmcvfs.copy(backdrop, fanartFile)
count += 1 count += 1
else: else:
log("EMBY", "Found cached backdrop.", 2) log("Found cached backdrop.", 2)
# Use existing cached images # Use existing cached images
dirs, files = xbmcvfs.listdir(fanartDir) dirs, files = xbmcvfs.listdir(fanartDir)
for file in files: for file in files:
@ -1085,7 +1083,7 @@ def getExtraFanArt(embyId,embyPath):
url=fanartFile, url=fanartFile,
listitem=li) listitem=li)
except Exception as e: except Exception as e:
log("EMBY", "Error getting extrafanart: %s" % e, 0) log("Error getting extrafanart: %s" % e, 0)
# Always do endofdirectory to prevent errors in the logs # Always do endofdirectory to prevent errors in the logs
xbmcplugin.endOfDirectory(int(sys.argv[1])) xbmcplugin.endOfDirectory(int(sys.argv[1]))