remove surplus get_logger calls, tidy up log messages some more
This commit is contained in:
parent
86330e536a
commit
d4248706e4
|
@ -227,7 +227,7 @@ class Database:
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, c, sql = None):
|
def __init__(self, c, sql = None):
|
||||||
log = Configuration.get_logger("logging.conf", "db", log_dir=c.dir_log)
|
#log = Configuration.get_logger("logging.conf", "db", log_dir=c.dir_log)
|
||||||
log.debug("Creating Database instance, sql = %s" % sql)
|
log.debug("Creating Database instance, sql = %s" % sql)
|
||||||
self.config = c
|
self.config = c
|
||||||
self.__connected = False
|
self.__connected = False
|
||||||
|
@ -239,6 +239,7 @@ class Database:
|
||||||
self.db_server = db_params['db-server']
|
self.db_server = db_params['db-server']
|
||||||
self.database = db_params['db-databaseName']
|
self.database = db_params['db-databaseName']
|
||||||
self.host = db_params['db-host']
|
self.host = db_params['db-host']
|
||||||
|
self.db_path = ''
|
||||||
|
|
||||||
# where possible avoid creating new SQL instance by using the global one passed in
|
# where possible avoid creating new SQL instance by using the global one passed in
|
||||||
if sql is None:
|
if sql is None:
|
||||||
|
@ -388,9 +389,9 @@ class Database:
|
||||||
log.info("Creating directory: '%s'" % (self.config.dir_database))
|
log.info("Creating directory: '%s'" % (self.config.dir_database))
|
||||||
os.mkdir(self.config.dir_database)
|
os.mkdir(self.config.dir_database)
|
||||||
database = os.path.join(self.config.dir_database, database)
|
database = os.path.join(self.config.dir_database, database)
|
||||||
log.info("Connecting to SQLite: %(database)s" % {'database':database})
|
self.db_path = database
|
||||||
print "Connecting to SQLite: %(database)s" % {'database':database}
|
log.info("Connecting to SQLite: %(database)s" % {'database':self.db_path})
|
||||||
self.connection = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
|
self.connection = sqlite3.connect(self.db_path, detect_types=sqlite3.PARSE_DECLTYPES )
|
||||||
sqlite3.register_converter("bool", lambda x: bool(int(x)))
|
sqlite3.register_converter("bool", lambda x: bool(int(x)))
|
||||||
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
|
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
|
||||||
self.connection.create_function("floor", 1, math.floor)
|
self.connection.create_function("floor", 1, math.floor)
|
||||||
|
@ -791,11 +792,10 @@ class Database:
|
||||||
|
|
||||||
def get_player_id(self, config, site, player_name):
|
def get_player_id(self, config, site, player_name):
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
print "get_player_id: player_name =", player_name, type(player_name)
|
#print "get_player_id: player_name =", player_name, type(player_name)
|
||||||
p_name = Charset.to_utf8(player_name)
|
p_name = Charset.to_utf8(player_name)
|
||||||
c.execute(self.sql.query['get_player_id'], (p_name, site))
|
c.execute(self.sql.query['get_player_id'], (p_name, site))
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
print "player id =", row
|
|
||||||
if row:
|
if row:
|
||||||
return row[0]
|
return row[0]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -51,9 +51,6 @@ import gobject
|
||||||
# FreePokerTools modules
|
# FreePokerTools modules
|
||||||
import Configuration
|
import Configuration
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", config = 'hud')
|
|
||||||
log.debug("%s logger initialized." % "hud")
|
|
||||||
|
|
||||||
|
|
||||||
import Database
|
import Database
|
||||||
from HandHistoryConverter import getTableTitleRe
|
from HandHistoryConverter import getTableTitleRe
|
||||||
|
@ -66,6 +63,10 @@ elif os.name == 'nt':
|
||||||
import Hud
|
import Hud
|
||||||
|
|
||||||
|
|
||||||
|
# logger is set up in __init__, create temp logger here
|
||||||
|
log = Configuration.get_logger("logging.conf", config = 'hud')
|
||||||
|
|
||||||
|
|
||||||
class HUD_main(object):
|
class HUD_main(object):
|
||||||
"""A main() object to own both the read_stdin thread and the gui."""
|
"""A main() object to own both the read_stdin thread and the gui."""
|
||||||
# This class mainly provides state for controlling the multiple HUDs.
|
# This class mainly provides state for controlling the multiple HUDs.
|
||||||
|
@ -74,9 +75,10 @@ class HUD_main(object):
|
||||||
try:
|
try:
|
||||||
print "HUD_main: starting ..."
|
print "HUD_main: starting ..."
|
||||||
self.db_name = db_name
|
self.db_name = db_name
|
||||||
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
self.config = Configuration.Config(file=options.config, dbname=db_name)
|
||||||
log = Configuration.get_logger("logging.conf", "hud", log_dir=self.config.dir_log)
|
log = Configuration.get_logger("logging.conf", "hud", log_dir=self.config.dir_log)
|
||||||
log.debug("starting ...")
|
log.info("HUD_main starting")
|
||||||
|
log.info("Using db name = %s" % (db_name))
|
||||||
self.hud_dict = {}
|
self.hud_dict = {}
|
||||||
self.hud_params = self.config.get_hud_ui_parameters()
|
self.hud_params = self.config.get_hud_ui_parameters()
|
||||||
|
|
||||||
|
@ -295,9 +297,6 @@ class HUD_main(object):
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
|
|
||||||
log.info("HUD_main starting")
|
|
||||||
log.info("Using db name = %s" % (options.dbname))
|
|
||||||
|
|
||||||
# start the HUD_main object
|
# start the HUD_main object
|
||||||
hm = HUD_main(db_name = options.dbname)
|
hm = HUD_main(db_name = options.dbname)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
@ -30,12 +29,16 @@ import time,datetime
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
|
import logging
|
||||||
|
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||||
|
log = logging.getLogger("parser")
|
||||||
|
|
||||||
|
|
||||||
import Configuration
|
import Configuration
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
import DerivedStats
|
import DerivedStats
|
||||||
import Card
|
import Card
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", "parser")
|
|
||||||
|
|
||||||
class Hand(object):
|
class Hand(object):
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ class Hand(object):
|
||||||
|
|
||||||
def __init__(self, config, sitename, gametype, handText, builtFrom = "HHC"):
|
def __init__(self, config, sitename, gametype, handText, builtFrom = "HHC"):
|
||||||
self.config = config
|
self.config = config
|
||||||
log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
#log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
||||||
self.sitename = sitename
|
self.sitename = sitename
|
||||||
self.siteId = self.SITEIDS[sitename]
|
self.siteId = self.SITEIDS[sitename]
|
||||||
self.stats = DerivedStats.DerivedStats(self)
|
self.stats = DerivedStats.DerivedStats(self)
|
||||||
|
|
|
@ -30,6 +30,11 @@ from xml.dom.minidom import Node
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import logging
|
||||||
|
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||||
|
log = logging.getLogger("parser")
|
||||||
|
|
||||||
|
|
||||||
import Hand
|
import Hand
|
||||||
import Tourney
|
import Tourney
|
||||||
from Exceptions import FpdbParseError
|
from Exceptions import FpdbParseError
|
||||||
|
@ -38,7 +43,6 @@ import Configuration
|
||||||
import gettext
|
import gettext
|
||||||
gettext.install('fpdb')
|
gettext.install('fpdb')
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", "parser")
|
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
import gtk
|
import gtk
|
||||||
|
@ -65,7 +69,7 @@ out_path (default '-' = sys.stdout)
|
||||||
follow : whether to tail -f the input"""
|
follow : whether to tail -f the input"""
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
log = Configuration.get_logger("logging.conf", "parser", log_dir=self.config.dir_log)
|
#log = Configuration.get_logger("logging.conf", "parser", log_dir=self.config.dir_log)
|
||||||
log.info("HandHistory init - %s subclass, in_path '%s'; out_path '%s'" % (self.sitename, in_path, out_path) )
|
log.info("HandHistory init - %s subclass, in_path '%s'; out_path '%s'" % (self.sitename, in_path, out_path) )
|
||||||
|
|
||||||
self.index = index
|
self.index = index
|
||||||
|
|
|
@ -721,6 +721,9 @@ class fpdb:
|
||||||
err_msg = None
|
err_msg = None
|
||||||
try:
|
try:
|
||||||
self.db = Database.Database(self.config, sql = self.sql)
|
self.db = Database.Database(self.config, sql = self.sql)
|
||||||
|
if self.db.get_backend_name() == 'SQLite':
|
||||||
|
# tell sqlite users where the db file is
|
||||||
|
print "Connected to SQLite: %(database)s" % {'database':self.db.db_path}
|
||||||
except Exceptions.FpdbMySQLAccessDenied:
|
except Exceptions.FpdbMySQLAccessDenied:
|
||||||
err_msg = "MySQL Server reports: Access denied. Are your permissions set correctly?"
|
err_msg = "MySQL Server reports: Access denied. Are your permissions set correctly?"
|
||||||
except Exceptions.FpdbMySQLNoDatabase:
|
except Exceptions.FpdbMySQLNoDatabase:
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Importer:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.sql = sql
|
self.sql = sql
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", "importer", log_dir=self.config.dir_log)
|
#log = Configuration.get_logger("logging.conf", "importer", log_dir=self.config.dir_log)
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.dirlist = {}
|
self.dirlist = {}
|
||||||
self.siteIds = {}
|
self.siteIds = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user