Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
890ea21
Initial Logbook setup
Ebag333 Jan 30, 2017
146fe1c
Add logbook to requirements
Ebag333 Jan 30, 2017
43d2379
Handle stdout and stderr through logbook. Handle debug mode.
Ebag333 Jan 30, 2017
518c4c8
Convert existing logging to logbook (pass 1)
Ebag333 Jan 30, 2017
2b81ab9
Convert logging (pass 2)
Ebag333 Jan 30, 2017
bb38b69
Remove blackholing crest loging
Ebag333 Jan 30, 2017
83ffe69
Convert logging (pass 3)
Ebag333 Jan 30, 2017
7784290
Convert logging (final?)
Ebag333 Jan 30, 2017
d66c503
Avoid blackholing all exceptions
Ebag333 Jan 30, 2017
0992889
Fix missed logging switch
Ebag333 Jan 30, 2017
53e74ef
Add more logging to blackholed exceptions
Ebag333 Jan 30, 2017
b41f794
Fix logging messages that pass in variables. Add some basic logging f…
Ebag333 Jan 30, 2017
4be0b30
More logging!
Ebag333 Jan 30, 2017
b650140
Catch scenario where the log file is locked by another process
Ebag333 Jan 31, 2017
3d5ec4e
Add logging for when effect handlers are generated
Ebag333 Jan 31, 2017
ef695e5
Better handling for when files are locked or other issues writing to …
Ebag333 Jan 31, 2017
1e99d4f
Update text
Ebag333 Jan 31, 2017
8016e45
remove unneeded check
Ebag333 Jan 31, 2017
c0bcfad
Initial pass to get pyinstaller working
Ebag333 Feb 3, 2017
9be8d6e
don't ignore pyinstaller .spec files
Ebag333 Feb 3, 2017
1a5ed31
Hidden imports for effects and conversions
Ebag333 Feb 3, 2017
0cdea3e
Try init
Ebag333 Feb 3, 2017
6992a15
requirements for build
Ebag333 Feb 4, 2017
b12cbaf
Add cert
Ebag333 Feb 4, 2017
6e226eb
Remove attempt to try and import effects via *
Ebag333 Feb 4, 2017
4500bc1
build improvements
Ebag333 Feb 4, 2017
32755aa
More spec file fixes
Ebag333 Feb 4, 2017
4bd8c5b
missed logging refernce
Ebag333 Feb 4, 2017
881d7db
Readd path
Ebag333 Feb 4, 2017
384a182
Import effects programatically
Ebag333 Feb 6, 2017
0c30dba
Add individual builds
Ebag333 Feb 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Pyfa.egg-info/
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand Down
50 changes: 5 additions & 45 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import os
import sys

# TODO: move all logging back to pyfa.py main loop
# We moved it here just to avoid rebuilding windows skeleton for now (any change to pyfa.py needs it)
import logging
import logging.handlers
from logbook import Logger
logger = Logger(__name__)

# Load variable overrides specific to distribution type
try:
import configforced
except ImportError:
logger.warning("Failed to import: configforced")
configforced = None

# Turns on debug mode
Expand All @@ -29,23 +28,6 @@
saveDB = None
gameDB = None


class StreamToLogger(object):
"""
Fake file-like stream object that redirects writes to a logger instance.
From: http://www.electricmonk.nl/log/2011/08/14/redirect-stdout-and-stderr-to-a-logger-in-python/
"""

def __init__(self, logger, log_level=logging.INFO):
self.logger = logger
self.log_level = log_level
self.linebuf = ''

def write(self, buf):
for line in buf.rstrip().splitlines():
self.logger.log(self.log_level, line.rstrip())


def isFrozen():
if hasattr(sys, 'frozen'):
return True
Expand All @@ -66,10 +48,7 @@ def defPaths(customSavePath):
global gameDB
global saveInRoot

if debug:
logLevel = logging.DEBUG
else:
logLevel = logging.WARN
logger.debug("Configuring Pyfa")

# The main pyfa directory which contains run.py
# Python 2.X uses ANSI by default, so we need to convert the character encoding
Expand Down Expand Up @@ -97,25 +76,6 @@ def defPaths(customSavePath):
os.environ["REQUESTS_CA_BUNDLE"] = getPyfaPath(certName).encode('utf8')
os.environ["SSL_CERT_FILE"] = getPyfaPath(certName).encode('utf8')

loggingFormat = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
logging.basicConfig(format=loggingFormat, level=logLevel)
handler = logging.handlers.RotatingFileHandler(getSavePath("log.txt"), maxBytes=1000000, backupCount=3)
formatter = logging.Formatter(loggingFormat)
handler.setFormatter(formatter)
logging.getLogger('').addHandler(handler)

logging.info("Starting pyfa")

if hasattr(sys, 'frozen'):
stdout_logger = logging.getLogger('STDOUT')
sl = StreamToLogger(stdout_logger, logging.INFO)
sys.stdout = sl

# This interferes with cx_Freeze's own handling of exceptions. Find a way to fix this.
# stderr_logger = logging.getLogger('STDERR')
# sl = StreamToLogger(stderr_logger, logging.ERROR)
# sys.stderr = sl

# The database where we store all the fits etc
saveDB = getSavePath("saveddata.db")

Expand All @@ -135,7 +95,7 @@ def defPaths(customSavePath):


def getPyfaPath(Append=None):
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
base = sys.argv[0]
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))

if Append:
Expand Down
5,666 changes: 5,666 additions & 0 deletions dist_assets/cacert.pem

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions eos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version = "0.2.3"
tag = "git"


def test():
import tests.runTests
import unittest
unittest.main(defaultTest="discover", testLoader=tests.runTests.loader)
version = "0.2.3"
tag = "git"

'''
def test():
import tests.runTests
import unittest
unittest.main(defaultTest="discover", testLoader=tests.runTests.loader)
'''
4 changes: 3 additions & 1 deletion eos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
gamedataCache = True
saveddataCache = True
gamedata_version = ""
# TODO: Removed this as it's already specified in config.py
'''
gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "eve.db")),
sys.getfilesystemencoding())
saveddata_connectionstring = 'sqlite:///' + unicode(
realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())

'''

# Autodetect path, only change if the autodetection bugs out.
path = dirname(unicode(__file__, sys.getfilesystemencoding()))
9 changes: 7 additions & 2 deletions eos/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import pool
from logbook import Logger

logger = Logger(__name__)
logger.debug("Initializing")

import migration
from eos import config
Expand All @@ -50,6 +53,7 @@ class ReadOnlyException(Exception):
"SELECT `field_value` FROM `metadata` WHERE `field_name` LIKE 'client_build'"
).fetchone()[0]
except:
logger.warning("Missing gamedata version.")
config.gamedata_version = None

saveddata_connectionstring = config.saveddata_connectionstring
Expand All @@ -67,8 +71,9 @@ class ReadOnlyException(Exception):
sd_lock = threading.Lock()

# Import all the definitions for all our database stuff
from eos.db.gamedata import *
from eos.db.saveddata import *
#from eos.db.gamedata import *
from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, queries, traits, unit
from eos.db.saveddata import booster, cargo, character, crest, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, miscData, module, override, price, queries, skill, targetResists, user

# Import queries
from eos.db.gamedata.queries import *
Expand Down
8 changes: 4 additions & 4 deletions eos/db/migration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
from logbook import Logger
logger = Logger(__name__)

import shutil
import time

import config
import migrations

logger = logging.getLogger(__name__)


def getVersion(db):
cursor = db.execute('PRAGMA user_version')
Expand Down Expand Up @@ -37,7 +37,7 @@ def update(saveddata_engine):
for version in xrange(dbVersion, appVersion):
func = migrations.updates[version + 1]
if func:
logger.info("Applying database update: %d", version + 1)
logger.info("Applying database update: {0}", version + 1)
func(saveddata_engine)

# when all is said and done, set version to current
Expand Down
11 changes: 5 additions & 6 deletions eos/db/saveddata/databaseRepair.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
# ===============================================================================

import sqlalchemy
import logging

logger = logging.getLogger(__name__)
from logbook import Logger
logger = Logger(__name__)


class DatabaseCleanup:
Expand All @@ -43,7 +42,7 @@ def OrphanedCharacterSkills(saveddata_engine):

if row and row['num']:
delete = saveddata_engine.execute("DELETE FROM characterSkills WHERE characterID NOT IN (SELECT ID from characters)")
logger.error("Database corruption found. Cleaning up %d records.", delete.rowcount)
logger.error("Database corruption found. Cleaning up {0} records.", delete.rowcount)

except sqlalchemy.exc.DatabaseError:
logger.error("Failed to connect to database.")
Expand Down Expand Up @@ -73,7 +72,7 @@ def OrphanedFitDamagePatterns(saveddata_engine):
update = saveddata_engine.execute("UPDATE 'fits' SET 'damagePatternID' = ? "
"WHERE damagePatternID NOT IN (SELECT ID FROM damagePatterns) OR damagePatternID IS NULL",
uniform_damage_pattern_id)
logger.error("Database corruption found. Cleaning up %d records.", update.rowcount)
logger.error("Database corruption found. Cleaning up {0} records.", update.rowcount)
except sqlalchemy.exc.DatabaseError:
logger.error("Failed to connect to database.")

Expand All @@ -99,6 +98,6 @@ def OrphanedFitCharacterIDs(saveddata_engine):
update = saveddata_engine.execute("UPDATE 'fits' SET 'characterID' = ? "
"WHERE characterID not in (select ID from characters) OR characterID IS NULL",
all5_id)
logger.error("Database corruption found. Cleaning up %d records.", update.rowcount)
logger.error("Database corruption found. Cleaning up {0} records.", update.rowcount)
except sqlalchemy.exc.DatabaseError:
logger.error("Failed to connect to database.")
5 changes: 2 additions & 3 deletions eos/effectHandlerHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
# ===============================================================================

# from sqlalchemy.orm.attributes import flag_modified
import logging
from logbook import Logger
logger = Logger(__name__)

import eos.db

logger = logging.getLogger(__name__)


class HandledList(list):
def filteredItemPreAssign(self, filter, *args, **kwargs):
Expand Down
19 changes: 0 additions & 19 deletions eos/effects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
# ===============================================================================
# Copyright (C) 2010 Diego Duclos
# 2010 Anton Vorobyov
#
# This file, as well as all files in this folder, are part of eos.
#
# eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# eos is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================
7 changes: 3 additions & 4 deletions eos/effects/adaptivearmorhardener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#
# Used by:
# Module: Reactive Armor Hardener
import logging

logger = logging.getLogger(__name__)
from logbook import Logger
logger = Logger(__name__)

runTime = "late"
type = "active"
Expand Down Expand Up @@ -98,7 +97,7 @@ def handler(fit, module, context):
cycleList.append(list(RAHResistance))

if loopStart < 0:
logger.error("Reactive Armor Hardener failed to find equilibrium. Damage profile after armor: %f/%f/%f/%f",
logger.error("Reactive Armor Hardener failed to find equilibrium. Damage profile after armor: {0}/{1}/{2}/{3}",
baseDamageTaken[0], baseDamageTaken[1], baseDamageTaken[2], baseDamageTaken[3])

# Average the profiles in the RAH loop, or the last 20 if it didn't find a loop.
Expand Down
7 changes: 6 additions & 1 deletion eos/gamedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
except ImportError:
from utils.compat import OrderedDict

from logbook import Logger
logger = Logger(__name__)


class Effect(EqBase):
"""
Expand Down Expand Up @@ -64,6 +67,8 @@ def handler(self):
if not self.__generated:
self.__generateHandler()

logger.debug("Generating effect: {0} ({1}) [runTime: {2}]", self.name, self.effectID, self.runTime)

return self.__handler

@property
Expand Down Expand Up @@ -138,7 +143,7 @@ def type(self):
@property
def isImplemented(self):
"""
Wether this effect is implemented in code or not,
Whether this effect is implemented in code or not,
unimplemented effects simply do nothing at all when run
"""
return self.handler != effectDummy
Expand Down
4 changes: 4 additions & 0 deletions eos/graph/fitDps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from eos.graph import Graph
from eos.types import Hardpoint, State

from logbook import Logger
logger = Logger(__name__)


class FitDpsGraph(Graph):
defaults = {"angle": 0,
Expand Down Expand Up @@ -66,6 +69,7 @@ def calcDps(self, data):
val *= 1 + (bonus - 1) * exp(- i ** 2 / 7.1289)
data[attr] = val
except:
logger.warning("Caught exception in calcDPS.")
pass

for mod in fit.modules:
Expand Down
9 changes: 4 additions & 5 deletions eos/saveddata/booster.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
# along with eos. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================

import logging
from logbook import Logger
logger = Logger(__name__)

from sqlalchemy.orm import reconstructor, validates

import eos.db
from eos.effectHandlerHelpers import HandledItem
from eos.modifiedAttributeDict import ModifiedAttributeDict, ItemAttrShortcut

logger = logging.getLogger(__name__)


class Booster(HandledItem, ItemAttrShortcut):
def __init__(self, item):
Expand All @@ -47,11 +46,11 @@ def init(self):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
logger.error("Item (id: %d) does not exist", self.itemID)
logger.error("Item (id: {0}) does not exist", self.itemID)
return

if self.isInvalid:
logger.error("Item (id: %d) is not a Booser", self.itemID)
logger.error("Item (id: {0}) is not a Booser", self.itemID)
return

self.build()
Expand Down
7 changes: 3 additions & 4 deletions eos/saveddata/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
# along with eos. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================

import logging
from logbook import Logger
logger = Logger(__name__)

from sqlalchemy.orm import validates, reconstructor

import eos.db
from eos.effectHandlerHelpers import HandledItem
from eos.modifiedAttributeDict import ModifiedAttributeDict, ItemAttrShortcut

logger = logging.getLogger(__name__)


class Cargo(HandledItem, ItemAttrShortcut):
def __init__(self, item):
Expand All @@ -46,7 +45,7 @@ def init(self):
if self.itemID:
self.__item = eos.db.getItem(self.itemID)
if self.__item is None:
logger.error("Item (id: %d) does not exist", self.itemID)
logger.error("Item (id: {0}) does not exist", self.itemID)
return

self.__itemModifiedAttributes = ModifiedAttributeDict()
Expand Down
Loading