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


Python Logger.error方法代码示例

本文整理汇总了Python中logger.logger.Logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error方法的具体用法?Python Logger.error怎么用?Python Logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logger.logger.Logger的用法示例。


在下文中一共展示了Logger.error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_line_received

# 需要导入模块: from logger.logger import Logger [as 别名]
# 或者: from logger.logger.Logger import error [as 别名]
    def on_line_received(self, json_payload):
        Logger.debug('line received: %s', json_payload, 'server')
        payload = json.loads(json_payload)

        if payload and 'type' in payload and payload['type'] == 'user_input':
            user_input = UserInputDataUnit(payload['content']).get_object()
            self.game.apply_user_input_to_player(self.user_id, user_input)
            self.update_game()
            self.send_broadcast_payload_except_self({
                'type': 'user_input',
                'content': payload['content'],
                'user': PlayerDataUnit(self.game.get_player(self.user_id)).get_pdu()
            })

            self.interval_executor.execute_if_interval_elapsed(self, lambda self: self.send_broadcast_payload(
                {'type': 'game_state', 'content': GameDataUnit(self.game).get_pdu()}))

        else:
            Logger.error('Unknown message type: (%s)', json_payload, 'server_protocol')
开发者ID:CorentinLimier,项目名称:Planes,代码行数:21,代码来源:server.py

示例2: __init__

# 需要导入模块: from logger.logger import Logger [as 别名]
# 或者: from logger.logger.Logger import error [as 别名]
class KivaRunner:
	"""
	This class can run kiva with a certain set of parameters
	and different temperture inputs.
	"""

	def __init__(self, working_dir, log_dir, compare_file, parameter_format, logger=None):
		"""
		parameter_format specifies what parameters from which files are needed.
		[file, name, min, max, step]
		"""
		if logger == None:
			self.log = Logger()
		else:
			self.log = logger
		self.error = False
		self.working_dir = working_dir
		self.log_dir = log_dir
		self.kiva_path = '../ext'
		self.kiva_name = 'kiva_0D'
		self.kiva_parameter_files = ['itape17', 'itape5', 'itapeERC', 'itapeRs']
		self.parameter_format = parameter_format
		self.log.debug("Parameter Format: %s" % self.parameter_format)
		# this will later hold all kiva_parameter_files that
		# need to be loaded as ITapeFile objects
		self.itapes = {}
		self.compare_file = compare_file
		# Check if working directory exists and that it is empty
		self.working_dir_indicator = os.path.join(self.working_dir, 'kivagen.working.dir')
		if not os.path.isdir(self.working_dir):
			self.log.error("'%s' does not exist." % self.working_dir)
			self.error = True
			self.working_dir = None
		elif os.listdir(self.working_dir):	# not empty
			if not os.path.isfile(self.working_dir_indicator):
				self.log.error("'%s' does not seem to be a working directory." % self.working_dir)
				self.error = True
				self.working_dir = None
				return
		else:
			open(self.working_dir_indicator, 'a').close()
		# Check that log dir exists
		if not os.path.isdir(self.log_dir):
			self.log.error("'%s' does not exist." % self.log_dir)
			self.error = True
			self.log_dir = None
		# Check if input files exist
		input_files = [self.compare_file]
		input_files.append(os.path.join(self.kiva_path, self.kiva_name))
		for parameter_file in self.kiva_parameter_files:
			input_files.append(os.path.join(self.kiva_path, parameter_file))
		for input_file in input_files:
			if not os.path.isfile(input_file):
				self.log.error("'%s' not found." % input_file)
				self.error = True
		# Parse compare file
		self.compare_values = self._readCompareFile(self.compare_file)
		# self.log.debug("self.compare_values = %s" % self.compare_values)
		# Load Parameters
		self._loadParameters()
		# self.log.debug("self.param_list = %s" % self.param_list)

# --------------- Parameters --------------------------------------------------
	def _loadParameters(self):
		"""
		Loads the start parameters from the itape files.
		Also creates a lookup table to match parameter list index to
		itape file and value id
		"""
		self.param_list = []
		self.param_lookup = {}
		# relaod parameters from file
		for itape in self.itapes.values():
			itape._open(itape.name)
		param_index = 0
		for param in self.parameter_format:
			# if file has not been loaded before
			if param[0] not in self.itapes:
				f = os.path.join(self.kiva_path, param[0])
				if param[0] in self.kiva_parameter_files:
					if param[0] in ['itapeERC', 'itapeRs']:
						self.itapes[param[0]] = ITapeFile(f, self.log)
					else:
						self.log.error("Failed to read %s. Can only read itapeERC and itapeRs." % f)
				else:
					self.log.error("Failed to read %s. Not in self.kiva_parameter_files (%s)" % self.kiva_parameter_files)
			# try to get parameter id
			ii = self.itapes[param[0]].getId(param[1])
			if ii < 0:
				self.log.error("Could not find '%s' in '%s'." % (param[1], param[0]))
				self.param_list.append(None) # append None to get index right
			else:
				value = self.itapes[param[0]].getValue(ii)
				self.param_list.append(self._checkParameter(value, param))
				# remember itap file and value id
				self.param_lookup[param_index] = [self.itapes[param[0]], ii]
			param_index = param_index + 1
		# now we should have collected all parameters
		if len(self.param_list) != len(self.parameter_format):
			sel.log.error("Only found %s elements. Expected %s!"
#.........这里部分代码省略.........
开发者ID:ekiwi,项目名称:kivagen,代码行数:103,代码来源:kiva_runner.py


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