Пример #1
0
		def run(self):
			res = []
			with open(self._log_file, "r") as fd:
				while True:
					line = fd.readline()
					if line == "":
						break
					if self._pattern.match(line):
						self.logger.debug("find one")
						m = Const.LOG_DATE_PATTERN.match(line)
						if m:
							year, month, day, hour, minute, sec, mill_sec = \
								int(m.group(1)), int(m.group(2)), int(m.group(3)), \
								int(m.group(4)), int(m.group(5)), int(m.group(6)), int(m.group(7))

							t = Utility.convert_time_int(datetime.datetime(year, month, day, hour, minute, sec)) \
								+ mill_sec
						else:
							self.logger.error("can not find date")
							t = 0
						res.append((t, line, ))

			self.logger.debug("after scan file")
			while self._lock.acquire():
				try:
					self._finder.add_result(res)
				finally:
					self._lock.release()
				break
Пример #2
0
	def query_all_entities(self):
		self._telnet_client.read_until("^] -> set crlf :")
		self._telnet_client.write("\r\n")
		self._telnet_client.expect([r"[\]r[\]r[\]nHello,.*[>][>][>] [>][>][>]"])
		self._telnet_client.write("from common.EntityManager import EntityManager\r\n".encode())
		self._telnet_client.read_until(">>>")
		self._telnet_client.write("print EntityManager._entities\r\n".encode())
		read_result = self._telnet_client.expect([r"{(.*)}"])
		match_pattern = read_result[1]
		if match_pattern is not None and match_pattern.groups():
			logger.debug("found entity: {0}".format(match_pattern.groups()[0]))
			self._set_found_entities(Utility.parse_found_entities_str(match_pattern.groups()[0]))
Пример #3
0
		logger.debug("Usage: python list_all_entities.py server.conf target_ip output.txt")
		exit(0)

	server_conf = sys.argv[1]
	if not os.path.exists(server_conf):
		logger.error("can not find {0}".format(server_conf))
		exit(0)

	target_ip = sys.argv[2].strip()

	with open(server_conf, "r") as fd:
		conf = json.load(fd)

	logger.debug("target server's ip: {0}".format(target_ip))

	all_target_game_conf = Utility.parse_conf(conf, target_ip)

	logger.debug("target server's ports: {0}".format(all_target_game_conf))

	if not all_target_game_conf:
		logger.error("no target port found")
		exit(0)

	all_result = {}

	with open(sys.argv[3].strip(), "w") as fd:
		for game_conf in all_target_game_conf:
			query = ServerDataQuery("localhost", game_conf[1], game_conf[0])
			all_result[game_conf] = query
			query.query_all_entities()
			query.close()