当前位置: 首页>>代码示例>>Python>>正文


Python Log.start方法代码示例

本文整理汇总了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()
开发者ID:ApolloDev,项目名称:apollo-db-python-module,代码行数:51,代码来源:apollo.py


注:本文中的logger.Log.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。