From 6971fa553b1232b8faa61cb9545ac0ead78782f6 Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 24 Feb 2018 00:54:16 +0100 Subject: Lots of lots of messages are being logged --- jfr_playoff/settings.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'jfr_playoff/settings.py') diff --git a/jfr_playoff/settings.py b/jfr_playoff/settings.py index 021253f..181e19f 100644 --- a/jfr_playoff/settings.py +++ b/jfr_playoff/settings.py @@ -4,6 +4,8 @@ import readline import requests import sys +from jfr_playoff.logger import PlayoffLogger + def complete_filename(text, state): return (glob.glob(text+'*')+[None])[state] @@ -31,9 +33,9 @@ class PlayoffSettings(object): if (key not in base_config) or overwrite: base_config[key] = value except Exception as e: - print 'WARNING: unable to merge remote config: %s' % (str(e)) - if remote_url is not None: - print 'Offending URL: %s' % (remote_url) + PlayoffLogger.get('settings').warning( + 'unable to merge remote config %s: %s(%s)', + remote_url, type(e).__name__, e.message) return base_config def load(self): @@ -45,16 +47,24 @@ class PlayoffSettings(object): 'JSON settings file: ').decode(sys.stdin.encoding) if self.settings is None: + PlayoffLogger.get('settings').info( + 'loading config file: %s', unicode(self.settings_file)) self.settings = json.loads( open(unicode(self.settings_file)).read().decode('utf-8-sig')) if self.has_section('remotes'): remote_config = {} for remote in self.get('remotes'): + PlayoffLogger.get('settings').info( + 'merging remote config: %s', remote) remote_config = self.__merge_config( remote_config, remote_url=remote) + PlayoffLogger.get('settings').debug( + 'remote config: %s', remote_config) self.settings = self.__merge_config( self.settings, new_config=remote_config, overwrite=False) + PlayoffLogger.get('settings').debug( + 'parsed config: %s', self.settings) def has_section(self, key): self.load() -- cgit v1.2.3 From 8c500a75a6eafd65b332d0f8346d9059d5293cbb Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 24 Feb 2018 11:04:11 +0100 Subject: Extracting text representation of an exception instead of explicit .message property --- jfr_playoff/matchinfo.py | 14 +++++++------- jfr_playoff/settings.py | 2 +- jfr_playoff/tournamentinfo.py | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'jfr_playoff/settings.py') diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index db49b07..8132fe2 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -179,13 +179,13 @@ class MatchInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('matchinfo').warning( 'fetching DB scores for match #%d failed: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) self.info.teams = self.__get_html_teams( self.info.teams, not scores_fetched) except (TypeError, IndexError, KeyError, IOError, ValueError) as e: PlayoffLogger.get('matchinfo').warning( 'fetching HTML scores for match #%d failed: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) self.info.teams = self.__get_config_teams(self.info.teams) def __get_db_board_count(self): @@ -237,7 +237,7 @@ class MatchInfo: except IOError as e: PlayoffLogger.get('matchinfo').info( 'cannot fetch HTML played boards count for segment: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) return 0, False return 0, False @@ -288,13 +288,13 @@ class MatchInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('matchinfo').warning( 'fetching board count from DB for match #%d failed: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) try: boards_played, boards_to_play = self.__get_html_board_count() except (TypeError, IndexError, KeyError, IOError, ValueError) as e: PlayoffLogger.get('matchinfo').warning( 'fetching board count from HTML for match #%d failed: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) pass if boards_played > 0: self.info.running = -1 \ @@ -345,13 +345,13 @@ class MatchInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('matchinfo').warning( 'cannot determine running link from DB for match #%d: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) try: self.info.link = self.__get_html_running_link() except (TypeError, IndexError, KeyError, IOError, ValueError) as e: PlayoffLogger.get('matchinfo').warning( 'cannot determine running link from HTML for match #%d: %s(%s)', - self.info.id, type(e).__name__, e.message) + self.info.id, type(e).__name__, str(e)) def set_phase_link(self, phase_link): if self.info.link is None: diff --git a/jfr_playoff/settings.py b/jfr_playoff/settings.py index 181e19f..58de66c 100644 --- a/jfr_playoff/settings.py +++ b/jfr_playoff/settings.py @@ -35,7 +35,7 @@ class PlayoffSettings(object): except Exception as e: PlayoffLogger.get('settings').warning( 'unable to merge remote config %s: %s(%s)', - remote_url, type(e).__name__, e.message) + remote_url, type(e).__name__, str(e)) return base_config def load(self): diff --git a/jfr_playoff/tournamentinfo.py b/jfr_playoff/tournamentinfo.py index 24440b3..a646d4e 100644 --- a/jfr_playoff/tournamentinfo.py +++ b/jfr_playoff/tournamentinfo.py @@ -162,13 +162,13 @@ class TournamentInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament results from DB: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) try: teams = self.__get_html_results() except (TypeError, IndexError, KeyError, IOError, ValueError) as e: PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament results from HTML: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) if self.is_finished() and 'final_positions' in self.settings: PlayoffLogger.get('tournamentinfo').info( 'setting final positions from tournament results: %s', @@ -184,13 +184,13 @@ class TournamentInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament finished status from DB: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) try: return self.__get_html_finished() except (TypeError, IndexError, KeyError, IOError, ValueError) as e: PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament finished status from HTML: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) PlayoffLogger.get('tournamentinfo').info( 'assuming tournament is finished') return True @@ -201,11 +201,11 @@ class TournamentInfo: except (IOError, TypeError, IndexError, KeyError) as e: PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament link from DB: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) try: return self.__get_html_link(suffix) except (KeyError, ValueError): PlayoffLogger.get('tournamentinfo').warning( 'cannot determine tournament link from HTML: %s(%s)', - type(e).__name__, e.message) + type(e).__name__, str(e)) return None -- cgit v1.2.3