From 982c70eba7a1cf6da76b40ceed3dab1390856944 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 15 Jun 2014 07:01:14 +0200 Subject: [PATCH] Better handling of getpd when no profile is found, maybe? Honestly I'm not sure about this one but it's better than logging three errors and throwing an exception. --- gamespy_gamestats_server.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/gamespy_gamestats_server.py b/gamespy_gamestats_server.py index 5ddcc49..89fceb6 100644 --- a/gamespy_gamestats_server.py +++ b/gamespy_gamestats_server.py @@ -305,28 +305,29 @@ class Gamestats(LineReceiver): keys = data_parsed['keys'].split('\x01') profile_data = None + data = "" + # Someone figure out if this is actually a good way to handle this when no profile is found if profile != None and 'data' in profile: profile_data = profile['data'] if profile_data.endswith("\\"): profile_data = profile_data[:-1] profile_data = gs_query.parse_gamespy_message("\\prof\\" + profile_data + "\\final\\") - data = "" - if profile_data != None: - profile_data = profile_data[0][0] - else: - self.log(logging.WARNING, "Could not get data section from profile for %d" % pid) + if profile_data != None: + profile_data = profile_data[0][0] + else: + self.log(logging.WARNING, "Could not get data section from profile for %d" % pid) - if len(keys) > 0 and keys[0] != "": - for key in (key for key in keys if key not in ("__cmd__", "__cmd_val__", "")): - data += "\\" + key + "\\" + if len(keys) > 0 and keys[0] != "": + for key in (key for key in keys if key not in ("__cmd__", "__cmd_val__", "")): + data += "\\" + key + "\\" - if profile_data != None and key in profile_data: - data += profile_data[key] - else: - self.log(logging.WARNING, "No keys requested, defaulting to all keys: %s" % (profile['data'])) - data = profile['data'] + if profile_data != None and key in profile_data: + data += profile_data[key] + else: + self.log(logging.WARNING, "No keys requested, defaulting to all keys: %s" % (profile['data'])) + data = profile['data'] modified = int(time.time())