diff --git a/Contents/Code/findMedia.py b/Contents/Code/findMedia.py index 98f9874..b6b9011 100644 --- a/Contents/Code/findMedia.py +++ b/Contents/Code/findMedia.py @@ -11,7 +11,7 @@ import urllib import unicodedata import json -import time +import time, sys # Consts used here AmountOfMediasInDatabase = 0 # Int of amount of medias in a database section @@ -152,10 +152,10 @@ def setSetting(self, req): req.clear() req.set_status(200) except Exception, e: - Log.Debug('Fatal error in setSetting: ' + str(e)) + Log.Debug('Fatal error in setSetting: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) - req.finish("Unknown error happened in findMedia-setSetting: " + str(e)) + req.finish("Unknown error happened in findMedia-setSetting: " + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) # Reset settings to default @@ -272,7 +272,7 @@ def scanMedias(sectionNumber, sectionLocations, sectionType, req): except ValueError: Log.Info('Aborted in ScanMedias') except Exception, e: - Log.Critical('Exception happend in scanMedias: ' + str(e)) + Log.Critical('Exception happend in scanMedias: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) statusMsg = 'Idle' # Scan the file system @@ -320,7 +320,7 @@ def getFiles(filePath): runningState = 99 Log.Info('Aborted in getFiles') except Exception, e: - Log.Critical('Exception happend in getFiles: ' + str(e)) + Log.Critical('Exception happend in getFiles: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) runningState = 99 def scanShowDB(sectionNumber=0): @@ -397,7 +397,7 @@ def scanShowDB(sectionNumber=0): runningState = 99 Log.Info('Aborted in ScanShowDB') except Exception, e: - Log.Debug('Fatal error in scanShowDB: ' + str(e)) + Log.Debug('Fatal error in scanShowDB: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) runningState = 99 # End scanShowDB @@ -440,7 +440,7 @@ def scanMovieDb(sectionNumber=0): break return except Exception, e: - Log.Debug('Fatal error in scanMovieDb: ' + str(e)) + Log.Debug('Fatal error in scanMovieDb: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) runningState = 99 # End scanMovieDb @@ -472,7 +472,7 @@ def scanMovieDb(sectionNumber=0): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish('Scanning already in progress') except Exception, ex: - Log.Debug('Fatal error happened in scanSection: ' + str(ex)) + Log.Debug('Fatal error happened in scanSection: ' + str(ex) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') diff --git a/Contents/Code/git.py b/Contents/Code/git.py index 0fdc02f..e3aec82 100644 --- a/Contents/Code/git.py +++ b/Contents/Code/git.py @@ -9,7 +9,7 @@ import datetime # Used for a timestamp in the dict import json -import io, os, shutil +import io, os, shutil, sys import plistlib import pms import tempfile @@ -37,7 +37,7 @@ def __init__(self): Log.Critical('UAS dir was missing the json, so doing a forced download here') self.updateUASCache(None, cliForce = True) except Exception, e: - Log.Critical('Exception happend when trying to force download from UASRes: ' + str(e)) + Log.Critical('Exception happend when trying to force download from UASRes: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) ''' Grap the tornado req, and process it for GET request''' def reqprocess(self, req): @@ -157,7 +157,7 @@ def removeEmptyFolders(path, removeRoot=True): Core.storage.save(path, data) except Exception, e: bError = True - Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e)) + Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) else: # We got a directory here Log.Debug(filename.split('/')[-2]) @@ -169,7 +169,7 @@ def removeEmptyFolders(path, removeRoot=True): Core.storage.ensure_dirs(path) except Exception, e: bError = True - Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e)) + Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) # Now we need to nuke files that should no longer be there! for root, dirs, files in os.walk(bundleName): for fname in files: @@ -188,7 +188,7 @@ def removeEmptyFolders(path, removeRoot=True): except Exception, e: Log.Critical('***************************************************************') Log.Critical('Error when updating WebTools') - Log.Critical('The error was: ' + str(e)) + Log.Critical('The error was: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) Log.Critical('***************************************************************') Log.Critical('DARN....When we tried to upgrade WT, we had an error :-(') Log.Critical('Only option now might be to do a manual install, like you did the first time') @@ -226,7 +226,7 @@ def getUpdateList(self, req): req.clear() req.set_status(204) except Exception, e: - Log.Debug('Fatal error happened in getUpdateList: ' + str(e)) + Log.Critical('Fatal error happened in getUpdateList: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') @@ -252,7 +252,7 @@ def getUASCacheList(): results[title] = git return results except Exception, e: - Log.Debug('Exception in Migrate/getUASCacheList : ' + str(e)) + Log.Critical('Exception in Migrate/getUASCacheList : ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) return '' # Grap indentifier from plist file and timestamp @@ -357,11 +357,11 @@ def getIdentifier(pluginDir): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish(json.dumps(migratedBundles)) except Exception, e: - Log.Critical('Fatal error happened in migrate: ' + str(e)) + Log.Critical('Fatal error happened in migrate: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in migrate: ' + str(e)) + req.finish('Fatal error happened in migrate: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) return req ''' This will return a list of UAS bundle types from the UAS Cache ''' @@ -373,7 +373,7 @@ def uasTypes(self, req): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish(json.dumps(Dict['uasTypes'])) except Exception, e: - Log.Critical('Exception in uasTypes: ' + str(e)) + Log.Critical('Exception in uasTypes: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') @@ -408,7 +408,7 @@ def updateUASCache(self, req, cliForce= False): try: Core.storage.ensure_dirs(targetDir) except Exception, e: - errMsg = str(e) + errMsg = str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno) if 'Errno 13' in errMsg: errMsg = errMsg + '\n\nLooks like permissions are not correct, cuz we where denied access\n' errMsg = errMsg + 'to create a needed directory.\n\n' @@ -416,7 +416,7 @@ def updateUASCache(self, req, cliForce= False): errMsg = errMsg + 'sudo chown plex:plex ./WebTools.bundle -R\n' errMsg = errMsg + 'And if on Synology, the command is:\n' errMsg = errMsg + 'sudo chown plex:users ./WebTools.bundle -R\n' - Log.Critical('Exception in updateUASCache ' + str(e)) + Log.Critical('Exception in updateUASCache ' + errMsg) if not cliForce: req.clear() req.set_status(500) @@ -429,12 +429,12 @@ def updateUASCache(self, req, cliForce= False): try: zipfile = Archive.ZipFromURL(self.UAS_URL+ '/archive/master.zip') except Exception, e: - Log.Critical('Could not download UAS Repo from GitHub') + Log.Critical('Could not download UAS Repo from GitHub' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) if not cliForce: req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Exception in updateUASCache while downloading UAS repo from Github: ' + str(e)) + req.finish('Exception in updateUASCache while downloading UAS repo from Github: ' + str(e)+ ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) return req for filename in zipfile: # Walk contents of the zip, and extract as needed @@ -447,7 +447,7 @@ def updateUASCache(self, req, cliForce= False): Core.storage.save(path, data) except Exception, e: bError = True - Log.Critical("Unexpected Error " + str(e)) + Log.Critical("Unexpected Error " + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) else: # We got a directory here Log.Debug(filename.split('/')[-2]) @@ -459,7 +459,7 @@ def updateUASCache(self, req, cliForce= False): Core.storage.ensure_dirs(path) except Exception, e: bError = True - Log.Critical("Unexpected Error " + str(e)) + Log.Critical("Unexpected Error " + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) # Update the AllBundleInfo as well pms.updateAllBundleInfoFromUAS() pms.updateUASTypesCounters() @@ -473,12 +473,12 @@ def updateUASCache(self, req, cliForce= False): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish('UASCache is up to date') except Exception, e: - Log.Critical('Exception in updateUASCache ' + str(e)) + Log.Critical('Exception in updateUASCache ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) if not cliForce: req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Exception in updateUASCache ' + str(e)) + req.finish('Exception in updateUASCache ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) return req ''' list will return a list of all installed gits from GitHub''' @@ -604,7 +604,7 @@ def removeEmptyFolders(path, removeRoot=True): # Grap file from Github zipfile = Archive.ZipFromURL(zipPath) except Exception, e: - Log.Critical('Exception in downloadBundle2tmp while downloading from GitHub: ' + str(e)) + Log.Critical('Exception in downloadBundle2tmp while downloading from GitHub: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) return False # Create base directory Core.storage.ensure_dirs(Core.storage.join_path(self.PLUGIN_DIR, bundleName)) @@ -633,7 +633,7 @@ def removeEmptyFolders(path, removeRoot=True): Log.Debug('Install is an upgrade') break except Exception, e: - Log.Critical('Exception in downloadBundle2tmp while walking the downloaded file to find the plist: ' + str(e)) + Log.Critical('Exception in downloadBundle2tmp while walking the downloaded file to find the plist: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) return False if bUpgrade: # Since this is an upgrade, we need to check, if the dev wants us to delete the Cache directory @@ -684,7 +684,7 @@ def removeEmptyFolders(path, removeRoot=True): Core.storage.save(path, data) except Exception, e: bError = True - Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e)) + Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) else: if cutStr not in filename: continue @@ -699,7 +699,7 @@ def removeEmptyFolders(path, removeRoot=True): Core.storage.ensure_dirs(path) except Exception, e: bError = True - Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e)) + Log.Critical('Exception happend in downloadBundle2tmp: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) if not bError and bUpgrade: # Copy files that should be kept between upgrades ("keepFiles") @@ -747,7 +747,7 @@ def removeEmptyFolders(path, removeRoot=True): shutil.move(extractDir, bundleName) except Exception, e: bError = True - Log.Critical('Unable to update plugin: ' + str(e)) + Log.Critical('Unable to update plugin: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) # Delete temporary directory try: @@ -776,7 +776,7 @@ def removeEmptyFolders(path, removeRoot=True): pass return True except Exception, e: - Log.Critical('Exception in downloadBundle2tmp: ' + str(e)) + Log.Critical('Exception in downloadBundle2tmp: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) return False # Starting install main @@ -847,11 +847,11 @@ def getLastUpdateTime(self, req, UAS=False, url=''): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish(str(response)) except Exception, e: - Log.Critical('Fatal error happened in getLastUpdateTime for :' + url + ' was: ' + str(e)) + Log.Critical('Fatal error happened in getLastUpdateTime for :' + url + ' was: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in getLastUpdateTime for :' + url + ' was: ' + str(e)) + req.finish('Fatal error happened in getLastUpdateTime for :' + url + ' was: ' + str(e) + ' on line {}'.format(sys.exc_info()[-1].tb_lineno)) ''' Get list of avail bundles in the UAS ''' def getListofBundles(self, req): diff --git a/Contents/Code/logs.py b/Contents/Code/logs.py index 820966c..6ebbc4b 100644 --- a/Contents/Code/logs.py +++ b/Contents/Code/logs.py @@ -31,11 +31,11 @@ def __init__(self): if not os.direxists(self.LOGDIR): self.LOGDIR = os.path.join(Core.app_support_path, 'Logs') except Exception, e: - Log.Debug('Fatal error happened in Logs list: ' + str(e)) + Log.Debug('Fatal error happened in Logs list: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs list: ' + str(e)) + req.finish('Fatal error happened in Logs list: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) Log.Debug('Log Root dir is: ' + self.LOGDIR) ''' Grap the tornado req for a Get, and process it ''' @@ -84,11 +84,11 @@ def entry(self, req): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish('Entry logged') except Exception, e: - Log.Debug('Fatal error happened in Logs entry: ' + str(e)) + Log.Debug('Fatal error happened in Logs entry: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs entry: ' + str(e)) + req.finish('Fatal error happened in Logs entry: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) ''' This metode will return a list of logfiles. accepts a filter parameter ''' def list(self, req): @@ -113,11 +113,11 @@ def list(self, req): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish(json.dumps(sorted(retFiles))) except Exception, e: - Log.Debug('Fatal error happened in Logs list: ' + str(e)) + Log.Debug('Fatal error happened in Logs list: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs list: ' + str(e)) + req.finish('Fatal error happened in Logs list: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) ''' This will return contents of the logfile as an array. Req. a parameter named fileName ''' def show(self, req): @@ -146,11 +146,11 @@ def show(self, req): req.finish(json.dumps(retFile)) return req except Exception, e: - Log.Debug('Fatal error happened in Logs show: ' + str(e)) + Log.Debug('Fatal error happened in Logs show: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs show: ' + str(e)) + req.finish('Fatal error happened in Logs show: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) ''' This will download a zipfile with the complete log directory. if parameter fileName is specified, only that file will be downloaded, and not zipped''' def download(self, req): @@ -186,11 +186,11 @@ def download(self, req): os.remove(zipFileName) return req except Exception, e: - Log.Debug('Fatal error happened in Logs download: ' + str(e)) + Log.Debug('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs download: ' + str(e)) + req.finish('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) else: try: if 'com.plexapp' in fileName: @@ -211,15 +211,15 @@ def download(self, req): req.finish() return req except Exception, e: - Log.Debug('Fatal error happened in Logs download: ' + str(e)) + Log.Debug('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs download: ' + str(e)) + req.finish('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) except Exception, e: - Log.Debug('Fatal error happened in Logs download: ' + str(e)) + Log.Debug('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in Logs download: ' + str(e)) + req.finish('Fatal error happened in Logs download: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) diff --git a/Contents/Code/plex2csv.py b/Contents/Code/plex2csv.py index 9d4cfcc..4ef37d0 100644 --- a/Contents/Code/plex2csv.py +++ b/Contents/Code/plex2csv.py @@ -25,16 +25,44 @@ def reqprocess(self, req): req.set_status(412) req.finish("Missing function parameter") elif function == 'getFields': - # Call scanSection + # Call getFields return self.getFields(req) elif function == 'getFieldListbyIdx': - # Call scanSection + # Call getFieldListbyIdx return self.getFieldListbyIdx(req) + elif function == 'getDefaultLevels': + # Call getDefaultLevels + return self.getDefaultLevels(req) else: req.clear() req.set_status(412) req.finish("Unknown function call") + ''' Returns a jason with the build-in levels + Param needed is type=[movie,show,audio,picture] + ''' + def getDefaultLevels(self, req): + def getMovieDefLevels(req): + myResult = [] + fields = json.dumps(plex2csv_moviefields.movieDefaultLevels, sort_keys=True) + print 'Ged1', fields + print 'Ged2' + for key, value in fields: + print 'Ged2', key + myResult.append(key) + req.clear() + req.set_status(200) + req.finish(json.dumps(myResult)) + + # Main code + type = req.get_argument('type', 'missing') + if type == 'missing': + req.clear() + req.set_status(412) + req.finish("Missing type parameter") + if type=='movie': + getMovieDefLevels(req) + ''' Returns an array of possible fields for a section type. Param needed is type=[movie,show,audio,picture] ''' @@ -53,18 +81,16 @@ def getMovieListbyIdx(req): if type=='movie': getMovieListbyIdx(req) - - ''' This will return a list of fields avail Param needed is type=[movie,show,audio,picture] ''' def getFields(self, req): def getFullMovieFieldsList(req): - print 'Ged 1' req.clear() req.set_status(200) req.finish(json.dumps(plex2csv_moviefields.fields)) + # Main code type = req.get_argument('type', 'missing') if type == 'missing': req.clear() diff --git a/Contents/Code/plextvhelper.py b/Contents/Code/plextvhelper.py index de846fa..5c08cba 100644 --- a/Contents/Code/plextvhelper.py +++ b/Contents/Code/plextvhelper.py @@ -6,6 +6,7 @@ # NAME variable must be defined in the calling unit, and is the name of the application # ###################################################################################################################### +import sys class plexTV(object): # Defaults used by the rest of the class @@ -54,7 +55,7 @@ def login(self, user, pwd): Log.Info('Authenticated towards plex.tv with success') return token except Ex.HTTPError, e: - Log.Critical('Login error: ' + str(e)) + Log.Critical('Login error: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(e.code) req.finish(e) @@ -87,7 +88,7 @@ def isServerOwner(self, token): Log.Debug('Server %s was found @ plex.tv, but user is not the owner' %(PMSId)) return 2 except Ex.HTTPError, e: - Log.Debug('Unknown exception was: %s' %(e)) + Log.Debug('Unknown exception was: %s' %(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) return -1 ''' will return the machineIdentity of this server ''' diff --git a/Contents/Code/pms.py b/Contents/Code/pms.py index 4089f81..38fc759 100644 --- a/Contents/Code/pms.py +++ b/Contents/Code/pms.py @@ -51,7 +51,8 @@ def updateInstallDict(): uasBundles[bundles[bundle]['identifier']] = bundle # Now walk the installed ones try: - for installedBundle in Dict['installed']: + installed = Dict['installed'].copy() + for installedBundle in installed: if not installedBundle.startswith('https://'): Log.Info('Checking unknown bundle: ' + installedBundle + ' to see if it is part of UAS now') if installedBundle in uasBundles: diff --git a/Contents/Code/settings.py b/Contents/Code/settings.py index a30bfe2..cae94e9 100644 --- a/Contents/Code/settings.py +++ b/Contents/Code/settings.py @@ -5,7 +5,7 @@ # ###################################################################################################################### -import json +import json, sys class settings(object): @@ -80,6 +80,7 @@ def setPwd(self, req): req.finish("Old Password did not match") return req except Ex.HTTPError, e: + Log.Critical('Error in setPwd: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(e.code) req.finish(e) @@ -106,6 +107,7 @@ def putSetting(self, req): req.finish("Setting saved") return req except Ex.HTTPError, e: + Log.Critical('Error in putSetting: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(e.code) req.finish(e) @@ -133,6 +135,7 @@ def getSetting(self, req): req.finish(json.dumps('Setting not found')) return req except Ex.HTTPError, e: + Log.Critical('Error in getSetting: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(e.code) req.finish(e) @@ -155,6 +158,7 @@ def getSettings(self, req): req.finish(json.dumps(mySetting)) return req except Ex.HTTPError, e: + Log.Critical('Error in getSettings: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(e.code) req.finish(e) diff --git a/Contents/Code/webSrv.py b/Contents/Code/webSrv.py index 135fed9..ced547f 100644 --- a/Contents/Code/webSrv.py +++ b/Contents/Code/webSrv.py @@ -30,7 +30,7 @@ from wt import wt -import os +import os, sys # Below used to find path of this file from inspect import getsourcefile @@ -177,7 +177,7 @@ def post(self): Log.Critical('Unknown error, when authenticating') self.set_status(403) except Ex.HTTPError, e: - Log.Critical('Exception in Login: ' + str(e)) + Log.Critical('Exception in Login: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) self.clear() self.set_status(e.code) self.finish(e) diff --git a/Contents/Code/wt.py b/Contents/Code/wt.py index f7dc1cf..7b90183 100644 --- a/Contents/Code/wt.py +++ b/Contents/Code/wt.py @@ -10,7 +10,7 @@ import glob import json -import shutil +import shutil, sys class wt(object): @@ -52,9 +52,7 @@ def reset(self, req): shutil.rmtree(cachePath) try: # shutil.rmtree(dataPath) - print 'GED1' Dict.Reset() - print 'GED2' except: Log.Critical('Fatal error in clearing dict during reset') # Restart system bundle @@ -64,11 +62,11 @@ def reset(self, req): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish('WebTools has been reset') except Exception, e: - Log.Debug('Fatal error happened in wt.reset: ' + str(e)) + Log.Debug('Fatal error happened in wt.reset: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in wt.reset: ' + str(e)) + req.finish('Fatal error happened in wt.reset: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) # Get a list of all css files in http/custom_themes def getCSS(self,req): @@ -89,11 +87,11 @@ def getCSS(self,req): req.set_header('Content-Type', 'application/json; charset=utf-8') req.finish(json.dumps(myList)) except Exception, e: - Log.Debug('Fatal error happened in getCSS: ' + str(e)) + Log.Debug('Fatal error happened in getCSS: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno)) req.clear() req.set_status(500) req.set_header('Content-Type', 'application/json; charset=utf-8') - req.finish('Fatal error happened in getCSS: ' + str(e)) + req.finish('Fatal error happened in getCSS: ' + str(e) + 'on line {}'.format(sys.exc_info()[-1].tb_lineno))