Add additional logging to services
This commit is contained in:
@@ -194,11 +194,13 @@ class Character(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def backupSkills(path, saveFmt, activeFit, callback):
|
def backupSkills(path, saveFmt, activeFit, callback):
|
||||||
thread = SkillBackupThread(path, saveFmt, activeFit, callback)
|
thread = SkillBackupThread(path, saveFmt, activeFit, callback)
|
||||||
|
pyfalog.debug("Starting backup skills thread.")
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def importCharacter(path, callback):
|
def importCharacter(path, callback):
|
||||||
thread = CharacterImportThread(path, callback)
|
thread = CharacterImportThread(path, callback)
|
||||||
|
pyfalog.debug("Starting import character thread.")
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ class Fit(object):
|
|||||||
try:
|
try:
|
||||||
implant = es_Implant(item)
|
implant = es_Implant(item)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
pyfalog.warning("Invalid item: {0}", itemID)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
fit.implants.append(implant)
|
fit.implants.append(implant)
|
||||||
@@ -272,6 +273,7 @@ class Fit(object):
|
|||||||
try:
|
try:
|
||||||
booster = es_Booster(item)
|
booster = es_Booster(item)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
pyfalog.warning("Invalid item: {0}", itemID)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
fit.boosters.append(booster)
|
fit.boosters.append(booster)
|
||||||
@@ -432,6 +434,7 @@ class Fit(object):
|
|||||||
try:
|
try:
|
||||||
m = es_Module(item)
|
m = es_Module(item)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
pyfalog.warning("Invalid item: {0}", itemID)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if m.item.category.name == "Subsystem":
|
if m.item.category.name == "Subsystem":
|
||||||
@@ -479,6 +482,7 @@ class Fit(object):
|
|||||||
try:
|
try:
|
||||||
m = es_Module(item)
|
m = es_Module(item)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
pyfalog.warning("Invalid item: {0}", newItemID)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if m.fits(fit):
|
if m.fits(fit):
|
||||||
@@ -519,6 +523,7 @@ class Fit(object):
|
|||||||
if cargoP.isValidState(State.ACTIVE):
|
if cargoP.isValidState(State.ACTIVE):
|
||||||
cargoP.state = State.ACTIVE
|
cargoP.state = State.ACTIVE
|
||||||
except:
|
except:
|
||||||
|
pyfalog.warning("Invalid item: {0}", cargo.item)
|
||||||
return
|
return
|
||||||
|
|
||||||
if cargoP.slot != module.slot: # can't swap modules to different racks
|
if cargoP.slot != module.slot: # can't swap modules to different racks
|
||||||
|
|||||||
@@ -21,10 +21,13 @@
|
|||||||
import urllib2
|
import urllib2
|
||||||
import urllib
|
import urllib
|
||||||
import socket
|
import socket
|
||||||
|
from logbook import Logger
|
||||||
|
|
||||||
import config
|
import config
|
||||||
from service.settings import NetworkSettings
|
from service.settings import NetworkSettings
|
||||||
|
|
||||||
|
pyfalog = Logger(__name__)
|
||||||
|
|
||||||
# network timeout, otherwise pyfa hangs for a long while if no internet connection
|
# network timeout, otherwise pyfa hangs for a long while if no internet connection
|
||||||
timeout = 3
|
timeout = 3
|
||||||
socket.setdefaulttimeout(timeout)
|
socket.setdefaulttimeout(timeout)
|
||||||
@@ -76,6 +79,7 @@ class Network(object):
|
|||||||
access = NetworkSettings.getInstance().getAccess()
|
access = NetworkSettings.getInstance().getAccess()
|
||||||
|
|
||||||
if not self.ENABLED & access or not type & access:
|
if not self.ENABLED & access or not type & access:
|
||||||
|
pyfalog.warning("Access not enabled - please enable in Preferences > Network")
|
||||||
raise Error("Access not enabled - please enable in Preferences > Network")
|
raise Error("Access not enabled - please enable in Preferences > Network")
|
||||||
|
|
||||||
# Set up some things for the request
|
# Set up some things for the request
|
||||||
@@ -113,6 +117,8 @@ class Network(object):
|
|||||||
try:
|
try:
|
||||||
return urllib2.urlopen(request)
|
return urllib2.urlopen(request)
|
||||||
except urllib2.HTTPError as error:
|
except urllib2.HTTPError as error:
|
||||||
|
pyfalog.warning("HTTPError:")
|
||||||
|
pyfalog.warning(error)
|
||||||
if error.code == 404:
|
if error.code == 404:
|
||||||
raise RequestError()
|
raise RequestError()
|
||||||
elif error.code == 403:
|
elif error.code == 403:
|
||||||
@@ -120,6 +126,8 @@ class Network(object):
|
|||||||
elif error.code >= 500:
|
elif error.code >= 500:
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
except urllib2.URLError as error:
|
except urllib2.URLError as error:
|
||||||
|
pyfalog.warning("Timed out or other URL error:")
|
||||||
|
pyfalog.warning(error)
|
||||||
if "timed out" in error.reason:
|
if "timed out" in error.reason:
|
||||||
raise TimeoutError()
|
raise TimeoutError()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -83,11 +83,13 @@ class Port(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def backupFits(path, callback):
|
def backupFits(path, callback):
|
||||||
|
pyfalog.debug("Starting backup fits thread.")
|
||||||
thread = FitBackupThread(path, callback)
|
thread = FitBackupThread(path, callback)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def importFitsThreaded(paths, callback):
|
def importFitsThreaded(paths, callback):
|
||||||
|
pyfalog.debug("Starting import fits thread.")
|
||||||
thread = FitImportThread(paths, callback)
|
thread = FitImportThread(paths, callback)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@@ -105,12 +107,14 @@ class Port(object):
|
|||||||
fits = []
|
fits = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if callback: # Pulse
|
if callback: # Pulse
|
||||||
|
pyfalog.debug("Processing file:\n{0}", path)
|
||||||
wx.CallAfter(callback, 1, "Processing file:\n%s" % path)
|
wx.CallAfter(callback, 1, "Processing file:\n%s" % path)
|
||||||
|
|
||||||
file_ = open(path, "r")
|
file_ = open(path, "r")
|
||||||
srcString = file_.read()
|
srcString = file_.read()
|
||||||
|
|
||||||
if len(srcString) == 0: # ignore blank files
|
if len(srcString) == 0: # ignore blank files
|
||||||
|
pyfalog.debug("File is blank.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
codec_found = None
|
codec_found = None
|
||||||
@@ -165,6 +169,7 @@ class Port(object):
|
|||||||
_, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
|
_, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
|
||||||
fits += fitsImport
|
fits += fitsImport
|
||||||
except xml.parsers.expat.ExpatError:
|
except xml.parsers.expat.ExpatError:
|
||||||
|
pyfalog.warning("Malformed XML in:\n{0}", path)
|
||||||
return False, "Malformed XML in %s" % path
|
return False, "Malformed XML in %s" % path
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pyfalog.critical("Unknown exception processing: {0}", path)
|
pyfalog.critical("Unknown exception processing: {0}", path)
|
||||||
@@ -181,6 +186,7 @@ class Port(object):
|
|||||||
db.save(fit)
|
db.save(fit)
|
||||||
IDs.append(fit.ID)
|
IDs.append(fit.ID)
|
||||||
if callback: # Pulse
|
if callback: # Pulse
|
||||||
|
pyfalog.debug("Processing complete, saving fits to database: {0}/{1}", i + 1, numFits)
|
||||||
wx.CallAfter(
|
wx.CallAfter(
|
||||||
callback, 1,
|
callback, 1,
|
||||||
"Processing complete, saving fits to database\n(%d/%d)" %
|
"Processing complete, saving fits to database\n(%d/%d)" %
|
||||||
@@ -612,7 +618,7 @@ class Port(object):
|
|||||||
if m.fits(fit):
|
if m.fits(fit):
|
||||||
m.owner = fit
|
m.owner = fit
|
||||||
if not m.isValidState(m.state):
|
if not m.isValidState(m.state):
|
||||||
print("Error: Module", m, "cannot have state", m.state)
|
pyfalog.warning("Error: Module {0} cannot have state {1}", m, m.state)
|
||||||
|
|
||||||
fit.modules.append(m)
|
fit.modules.append(m)
|
||||||
|
|
||||||
@@ -810,8 +816,9 @@ class Port(object):
|
|||||||
if callback:
|
if callback:
|
||||||
wx.CallAfter(callback, None)
|
wx.CallAfter(callback, None)
|
||||||
# Skip fit silently if we get an exception
|
# Skip fit silently if we get an exception
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pyfalog.error("Caught exception on fit.")
|
pyfalog.error("Caught exception on fit.")
|
||||||
|
pyfalog.error(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return fits
|
return fits
|
||||||
@@ -835,8 +842,9 @@ class Port(object):
|
|||||||
f.ship = Ship(sMkt.getItem(shipType))
|
f.ship = Ship(sMkt.getItem(shipType))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
f.ship = Citadel(sMkt.getItem(shipType))
|
f.ship = Citadel(sMkt.getItem(shipType))
|
||||||
except:
|
except Exception as e:
|
||||||
pyfalog.warning("Caught exception on importXml")
|
pyfalog.warning("Caught exception on importXml")
|
||||||
|
pyfalog.error(e)
|
||||||
continue
|
continue
|
||||||
hardwares = fitting.getElementsByTagName("hardware")
|
hardwares = fitting.getElementsByTagName("hardware")
|
||||||
moduleList = []
|
moduleList = []
|
||||||
@@ -845,8 +853,9 @@ class Port(object):
|
|||||||
moduleName = hardware.getAttribute("type")
|
moduleName = hardware.getAttribute("type")
|
||||||
try:
|
try:
|
||||||
item = sMkt.getItem(moduleName, eager="group.category")
|
item = sMkt.getItem(moduleName, eager="group.category")
|
||||||
except:
|
except Exception as e:
|
||||||
pyfalog.warning("Caught exception on importXml")
|
pyfalog.warning("Caught exception on importXml")
|
||||||
|
pyfalog.error(e)
|
||||||
continue
|
continue
|
||||||
if item:
|
if item:
|
||||||
if item.category.name == "Drone":
|
if item.category.name == "Drone":
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ if config.saveDB and os.path.isfile(config.saveDB):
|
|||||||
else:
|
else:
|
||||||
# If database does not exist, do not worry about migration. Simply
|
# If database does not exist, do not worry about migration. Simply
|
||||||
# create and set version
|
# create and set version
|
||||||
|
pyfalog.debug("Existing database not found, creating new database.")
|
||||||
db.saveddata_meta.create_all()
|
db.saveddata_meta.create_all()
|
||||||
db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
|
db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
|
||||||
# Import default database values
|
# Import default database values
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class Price(object):
|
|||||||
try:
|
try:
|
||||||
percprice = float(sell.getElementsByTagName("percentile").item(0).firstChild.data)
|
percprice = float(sell.getElementsByTagName("percentile").item(0).firstChild.data)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
|
pyfalog.warning("Failed to get price for: {0}", type_)
|
||||||
percprice = 0
|
percprice = 0
|
||||||
|
|
||||||
# Fill price data
|
# Fill price data
|
||||||
|
|||||||
@@ -82,11 +82,15 @@ class AuthHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
try:
|
try:
|
||||||
if step2:
|
if step2:
|
||||||
self.server.callback(parts)
|
self.server.callback(parts)
|
||||||
|
pyfalog.info("Successfully logged into CREST.")
|
||||||
msg = "If you see this message then it means you should be logged into CREST. You may close this window and return to the application."
|
msg = "If you see this message then it means you should be logged into CREST. You may close this window and return to the application."
|
||||||
else:
|
else:
|
||||||
# For implicit mode, we have to serve up the page which will take the hash and redirect useing a querystring
|
# For implicit mode, we have to serve up the page which will take the hash and redirect useing a querystring
|
||||||
|
pyfalog.info("Processing response from EVE Online.")
|
||||||
msg = "Processing response from EVE Online"
|
msg = "Processing response from EVE Online"
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
|
pyfalog.error("Error in CREST AuthHandler")
|
||||||
|
pyfalog.error(ex)
|
||||||
msg = "<h2>Error</h2>\n<p>{}</p>".format(ex.message)
|
msg = "<h2>Error</h2>\n<p>{}</p>".format(ex.message)
|
||||||
finally:
|
finally:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
@@ -127,6 +131,7 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
pyfalog.warning("Setting CREST server to stop.")
|
||||||
self.run = False
|
self.run = False
|
||||||
|
|
||||||
def handle_timeout(self):
|
def handle_timeout(self):
|
||||||
|
|||||||
@@ -85,8 +85,9 @@ class CheckUpdateThread(threading.Thread):
|
|||||||
if release['prerelease'] and rVersion > config.expansionVersion:
|
if release['prerelease'] and rVersion > config.expansionVersion:
|
||||||
wx.CallAfter(self.callback, release) # Singularity -> Singularity
|
wx.CallAfter(self.callback, release) # Singularity -> Singularity
|
||||||
break
|
break
|
||||||
except:
|
except Exception as e:
|
||||||
pyfalog.warning("Caught exception in run")
|
pyfalog.error("Caught exception in run")
|
||||||
|
pyfalog.error(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -100,6 +101,7 @@ class Update(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def CheckUpdate(callback):
|
def CheckUpdate(callback):
|
||||||
thread = CheckUpdateThread(callback)
|
thread = CheckUpdateThread(callback)
|
||||||
|
pyfalog.debug("Starting Check Update Thread.")
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user