Tox fixes, and convert all logging string replacement to a standard style.

This commit is contained in:
Ebag333
2017-02-13 13:38:21 -08:00
parent be9eaa0859
commit 159472f82c
21 changed files with 46 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ savePath = None
saveDB = None
gameDB = None
def isFrozen():
if hasattr(sys, 'frozen'):
return True

View File

@@ -37,7 +37,7 @@ def update(saveddata_engine):
for version in xrange(dbVersion, appVersion):
func = migrations.updates[version + 1]
if func:
pyfalog.info("Applying database update: %d", version + 1)
pyfalog.info("Applying database update: {0}", version + 1)
func(saveddata_engine)
# when all is said and done, set version to current

View File

@@ -198,7 +198,7 @@ class HandledImplantBoosterList(HandledList):
# if needed, remove booster that was occupying slot
oldObj = next((m for m in self if m.slot == thing.slot), None)
if oldObj:
pyfalog.info("Slot %d occupied with %s, replacing with %s", thing.slot, oldObj.item.name, thing.item.name)
pyfalog.info("Slot {0} occupied with {1}, replacing with {2}", thing.slot, oldObj.item.name, thing.item.name)
oldObj.itemID = 0 # hack to remove from DB. See GH issue #324
self.remove(oldObj)
@@ -222,7 +222,7 @@ class HandledProjectedModList(HandledList):
oldEffect = next((m for m in self if m.item.group.name == "Effect Beacon"), None)
if oldEffect:
pyfalog.info("System effect occupied with %s, replacing with %s", oldEffect.item.name, proj.item.name)
pyfalog.info("System effect occupied with {0}, replacing with {1}", oldEffect.item.name, proj.item.name)
self.remove(oldEffect)
HandledList.append(self, proj)

View File

@@ -18,7 +18,6 @@
# ===============================================================================
import re
import traceback
from sqlalchemy.orm import reconstructor

View File

@@ -47,11 +47,11 @@ class Booster(HandledItem, ItemAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
if self.isInvalid:
pyfalog.error("Item (id: %d) is not a Booser", self.itemID)
pyfalog.error("Item (id: {0}) is not a Booster", self.itemID)
return
self.build()

View File

@@ -47,7 +47,7 @@ class Cargo(HandledItem, ItemAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
self.__itemModifiedAttributes = ModifiedAttributeDict()

View File

@@ -27,7 +27,7 @@ pyfalog = Logger(__name__)
class Citadel(Ship):
def validate(self, item):
if item.category.name != "Structure":
pyfalog.error("Passed item '{0}' (category: {1}) is not under Structure category",item.name, item.category.name)
pyfalog.error("Passed item '{0}' (category: {1}) is not under Structure category", item.name, item.category.name)
raise ValueError(
'Passed item "%s" (category: (%s)) is not under Structure category' % (item.name, item.category.name))

View File

@@ -53,11 +53,11 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
if self.isInvalid:
pyfalog.error("Item (id: %d) is not a Drone", self.itemID)
pyfalog.error("Item (id: {0}) is not a Drone", self.itemID)
return
self.build()

View File

@@ -61,11 +61,11 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
if self.isInvalid:
pyfalog.error("Item (id: %d) is not a Fighter", self.itemID)
pyfalog.error("Item (id: {0}) is not a Fighter", self.itemID)
return
self.build()

View File

@@ -59,7 +59,7 @@ class FighterAbility(object):
if self.effectID:
self.__effect = next((x for x in self.fighter.item.effects.itervalues() if x.ID == self.effectID), None)
if self.__effect is None:
pyfalog.error("Effect (id: %d) does not exist", self.effectID)
pyfalog.error("Effect (id: {0}) does not exist", self.effectID)
return
self.build()

View File

@@ -46,11 +46,11 @@ class Implant(HandledItem, ItemAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
if self.isInvalid:
pyfalog.error("Item (id: %d) is not an Implant", self.itemID)
pyfalog.error("Item (id: {0}) is not an Implant", self.itemID)
return
self.build()

View File

@@ -94,11 +94,11 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
if self.isInvalid:
pyfalog.error("Item (id: %d) is not a Module", self.itemID)
pyfalog.error("Item (id: {0}) is not a Module", self.itemID)
return
if self.chargeID:

View File

@@ -43,13 +43,13 @@ class Override(EqBase):
if self.attrID:
self.__attr = eos.db.getAttributeInfo(self.attrID)
if self.__attr is None:
pyfalog.error("Attribute (id: %d) does not exist", self.attrID)
pyfalog.error("Attribute (id: {0}) does not exist", self.attrID)
return
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
pyfalog.error("Item (id: %d) does not exist", self.itemID)
pyfalog.error("Item (id: {0}) does not exist", self.itemID)
return
@property

View File

@@ -121,7 +121,7 @@ class ContextMenu(object):
debug_end = len(cls._ids)
if debug_end - debug_start:
pyfalog.debug("%d new IDs created for this menu" % (debug_end - debug_start))
pyfalog.debug("{0} new IDs created for this menu", (debug_end - debug_start))
return rootMenu if empty is False else None

View File

@@ -65,6 +65,7 @@ class LoggerWriter:
# to work properly for me.
self.level(sys.stderr)
# Parse command line options
usage = "usage: %prog [--root]"
parser = PassThroughOptionParser(usage=usage)
@@ -73,7 +74,7 @@ parser.add_option("-w", "--wx28", action="store_true", dest="force28", help="For
parser.add_option("-d", "--debug", action="store_true", dest="debug", help="Set logger to debug level.", default=False)
parser.add_option("-t", "--title", action="store", dest="title", help="Set Window Title", default=None)
parser.add_option("-s", "--savepath", action="store", dest="savepath", help="Set the folder for savedata", default=None)
parser.add_option("-l", "--logginglevel", action="store", dest="logginglevel", help="Set the desired logging level (Critical, Error, Warning, Info, Debug)", default="Error")
parser.add_option("-l", "--logginglevel", action="store", dest="logginglevel", help="Set desired logging level [Critical|Error|Warning|Info|Debug]", default="Error")
(options, args) = parser.parse_args()

View File

@@ -84,11 +84,12 @@ class CharacterImportThread(threading.Thread):
"level": int(skill.getAttribute("level")),
})
else:
pyfalog.error("Attempted to import unknown skill %s (ID: %s) (Level: %s)",
skill.getAttribute("name"),
skill.getAttribute("typeID"),
skill.getAttribute("level"),
)
pyfalog.error(
"Attempted to import unknown skill {0} (ID: {1}) (Level: {2})",
skill.getAttribute("name"),
skill.getAttribute("typeID"),
skill.getAttribute("level"),
)
char = sCharacter.new(name + " (EVEMon)")
sCharacter.apiUpdateCharSheet(char.ID, skills)
except Exception, e:

View File

@@ -182,7 +182,7 @@ class Crest(object):
pyfalog.warn("OAUTH state mismatch")
return
pyfalog.debug("Handling CREST login with: %s" % message)
pyfalog.debug("Handling CREST login with: {0}", message)
if 'access_token' in message: # implicit
eve = copy.deepcopy(self.eve)
@@ -196,7 +196,7 @@ class Crest(object):
eve()
info = eve.whoami()
pyfalog.debug("Got character info: %s" % info)
pyfalog.debug("Got character info: {0}", info)
self.implicitCharacter = CrestChar(info['CharacterID'], info['CharacterName'])
self.implicitCharacter.eve = eve
@@ -209,7 +209,7 @@ class Crest(object):
eve()
info = eve.whoami()
pyfalog.debug("Got character info: %s" % info)
pyfalog.debug("Got character info: {0}", info)
# check if we have character already. If so, simply replace refresh_token
char = self.getCrestCharacter(int(info['CharacterID']))

View File

@@ -447,7 +447,7 @@ class Market(object):
else:
raise TypeError("Need Item object, integer, float or string as argument")
except:
pyfalog.error("Could not get item: %s", identity)
pyfalog.error("Could not get item: {0}", identity)
raise
return item

View File

@@ -134,21 +134,21 @@ class Port(object):
savebom = bom
if codec_found is None:
pyfalog.info("Unicode BOM not found in file %s.", path)
pyfalog.info("Unicode BOM not found in file {0}.", path)
attempt_codecs = (defcodepage, "utf-8", "utf-16", "cp1252")
for page in attempt_codecs:
try:
pyfalog.info("Attempting to decode file %s using %s page.", path, page)
pyfalog.info("Attempting to decode file {0} using {1} page.", path, page)
srcString = unicode(srcString, page)
codec_found = page
pyfalog.info("File %s decoded using %s page.", path, page)
pyfalog.info("File {0} decoded using {1} page.", path, page)
except UnicodeDecodeError:
pyfalog.info("Error unicode decoding %s from page %s, trying next codec", path, page)
pyfalog.info("Error unicode decoding {0} from page {1}, trying next codec", path, page)
else:
break
else:
pyfalog.info("Unicode BOM detected in %s, using %s page.", path, codec_found)
pyfalog.info("Unicode BOM detected in {0}, using {1} page.", path, codec_found)
srcString = unicode(srcString[len(savebom):], codec_found)
else:
@@ -167,9 +167,9 @@ class Port(object):
except xml.parsers.expat.ExpatError:
return False, "Malformed XML in %s" % path
except Exception as e:
pyfalog.critical("Unknown exception processing: %s", path)
pyfalog.critical("Unknown exception processing: {0}", path)
pyfalog.critical(e)
return False, "Unknown Error while processing %s" % path
return False, "Unknown Error while processing {0}" % path
IDs = []
numFits = len(fits)

View File

@@ -119,7 +119,7 @@ class APIConnection(object):
self.cache = DictCache()
def get(self, resource, params=None):
pyfalog.debug('Getting resource %s', resource)
pyfalog.debug('Getting resource {0}', resource)
if params is None:
params = {}
@@ -139,18 +139,18 @@ class APIConnection(object):
key = (resource, frozenset(self._session.headers.items()), frozenset(prms.items()))
cached = self.cache.get(key)
if cached and cached['cached_until'] > time.time():
pyfalog.debug('Cache hit for resource %s (params=%s)', resource, prms)
pyfalog.debug('Cache hit for resource {0} (params={1})', resource, prms)
return cached
elif cached:
pyfalog.debug('Cache stale for resource %s (params=%s)', resource, prms)
pyfalog.debug('Cache stale for resource {0} (params={1})', resource, prms)
self.cache.invalidate(key)
else:
pyfalog.debug('Cache miss for resource %s (params=%s', resource, prms)
pyfalog.debug('Cache miss for resource {0} (params={1})', resource, prms)
pyfalog.debug('Getting resource %s (params=%s)', resource, prms)
pyfalog.debug('Getting resource {0} (params={1})', resource, prms)
res = self._session.get(resource, params=prms)
if res.status_code != 200:
raise APIException("Got unexpected status code from server: %i" % res.status_code)
raise APIException("Got unexpected status code from server: {0}" % res.status_code)
ret = res.json()

View File

@@ -105,7 +105,7 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
self.run = False
def handle_timeout(self):
# pyfalog.debug("Number of tries: %d"%self.tries)
pyfalog.debug("Number of tries: {0}", self.tries)
self.tries += 1
if self.tries == self.max_tries:
pyfalog.debug("Server timed out waiting for connection")