本文整理汇总了Python中logger.Log.start方法的典型用法代码示例。如果您正苦于以下问题:Python Log.start方法的具体用法?Python Log.start怎么用?Python Log.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.Log
的用法示例。
在下文中一共展示了Log.start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import start [as 别名]
class ApolloDB:
def __init__(self, host_="warhol-fred.psc.edu",
user_="apolloext", dbname_="apollo201", password_=None, logger_=None):
self._host = host_
self._user = user_
self._dbname = dbname_
self._password = password_
self._conn = None
self._DictCursor = None
self._RegularCursor = None
self.populationAxis = None
if logger_ is None:
self.logger = Log("./db.test.log")
self.logger.start()
else:
self.logger = logger_
self.stateToPopulationDict = {'S':'susceptible', 'E':'exposed', 'I':'infectious',
'R':'recovered', 'C':'newly exposed', 'V':'received vaccine control measure',
'Av':'received antiviral control measure', 'ScCl':'school that is closed'}
self.stateToDataFileDict = {'S':'susceptible.txt', 'E':'exposed.txt', 'I':'infectious.txt',
'R':'recovered.txt', 'C':'newly_exposed.txt', 'V':'vacc_administered.txt',
'Av':'av_administered.txt'}
def connect(self):
if self._conn is not None:
print "Connection to Apollo Database has already been established"
return
try:
if self._password is None:
self._conn = MySQLdb.connect(host=self._host, user=self._user, db=self._dbname)
else:
self._conn = MySQLdb.connect(host=self._host,
user=self._user,
passwd=self._password,
db=self._dbname)
self._conn.autocommit(True)
self.logger.update('DB_CONNECT_SUCCESS')
except MySQLdb.Error, e:
print "Problem connecting to Apollo database: %d %s" % (e.args[0], e.args[1])
self.logger.update('DB_CONNECT_FAILED')
raise e
self._cursor = self._conn.cursor(MySQLdb.cursors.DictCursor)
self.populationAxis = self._populationAxis()