Skip to content

Commit

Permalink
[core] Unify the usage of bot.Willie.debug across core and all modules.
Browse files Browse the repository at this point in the history
Tags like core, [CORE] and so on are useless, and most modules used the module
name as the tag. Now that tag is given a file that exists, it will use the
relative (to willie) path to that file as the tag. Otherwise it will work as
before. This allows for passing __file__ as the tag.
  • Loading branch information
ari-koivula committed Jul 31, 2013
1 parent a73f0b0 commit 9f15c0d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions github.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def issue(bot, trigger):

data = json.loads(raw)
bot.say('Issue #%s posted. %s' % (data['number'], data['html_url']))
bot.debug('GitHub', 'Issue #%s created in %s' % (data['number'], trigger.sender), 'warning')
bot.debug(__file__, 'Issue #%s created in %s' % (data['number'], trigger.sender), 'warning')


@commands('addtrace', 'addtraceback')
Expand Down Expand Up @@ -118,7 +118,7 @@ def add_traceback(bot, trigger):

data = json.loads(raw)
bot.say('Added traceback to issue #%s. %s' % (number, data['html_url']))
bot.debug('GitHub', 'Traceback added to #%s in %s.' % (number, trigger.sender), 'warning')
bot.debug(__file__, 'Traceback added to #%s in %s.' % (number, trigger.sender), 'warning')


@commands('findissue', 'findbug')
Expand Down
6 changes: 3 additions & 3 deletions ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def _find_geoip_db(bot):
os.path.isfile(os.path.join(config.ip.GeoIP_db_path, 'GeoIPASNum.dat'))):
return config.ip.GeoIP_db_path
else:
bot.debug('ip', 'GeoIP path configured but DB not found in configured path', 'warning')
bot.debug(__file__, 'GeoIP path configured but DB not found in configured path', 'warning')
if (os.path.isfile(os.path.join(bot.config.homedir, 'GeoLiteCity.dat')) and
os.path.isfile(os.path.join(bot.config.homedir, 'GeoIPASNum.dat'))):
return bot.config.homedir
elif (os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLiteCity.dat')) and
os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoIPASNum.dat'))):
return '/usr/share/GeoIP'
elif can_download:
bot.debug('ip', 'Downloading GeoIP database', 'always')
bot.debug(__file__, 'Downloading GeoIP database', 'always')
bot.say('Downloading GeoIP database, please wait...')
geolite_city_url = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz'
geolite_ASN_url = 'http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz'
Expand All @@ -86,7 +86,7 @@ def ip(bot, trigger):
query = trigger.group(2)
db_path = _find_geoip_db(bot)
if db_path is False:
bot.debug('ip', 'Can\'t find (or download) usable GeoIP database', 'always')
bot.debug(__file__, 'Can\'t find (or download) usable GeoIP database', 'always')
bot.say('Sorry, I don\'t have a GeoIP database to use for this lookup')
return False
geolite_city_filepath = os.path.join(_find_geoip_db(bot), 'GeoLiteCity.dat')
Expand Down
4 changes: 2 additions & 2 deletions movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def movie(bot, trigger):
if 'Error' in data:
message = '[MOVIE] %s' % data['Error']
else:
bot.debug('movie', 'Got an error from the imdb api, search phrase was %s' % word, 'warning')
bot.debug('movie', str(data), 'warning')
bot.debug(__file__, 'Got an error from the imdb api, search phrase was %s' % word, 'warning')
bot.debug(__file__, str(data), 'warning')
message = '[MOVIE] Got an error from imdbapi'
else:
message = '[MOVIE] Title: ' + data['Title'] + \
Expand Down
6 changes: 3 additions & 3 deletions radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def currentSong(bot, trigger):
song = web.get(radioURL % 'currentsong')
except Exception as e:
bot.say('The radio is not responding to the song request.')
bot.debug('radio', 'Exception while trying to get current song: %s' % e, 'warning')
bot.debug(__file__, 'Exception while trying to get current song: %s' % e, 'warning')
if song:
bot.say('Now playing: ' + song)
else:
Expand All @@ -76,7 +76,7 @@ def nextSong(bot, trigger):
song = web.get(radioURL % 'nextsong')
except Exception as e:
bot.say('The radio is not responding to the song request.')
bot.debug('radio', 'Exception while trying to get next song: %s' % e, 'warning')
bot.debug(__file__, 'Exception while trying to get next song: %s' % e, 'warning')
if song:
bot.say('Next up: ' + song)
else:
Expand Down Expand Up @@ -115,7 +115,7 @@ def radio(bot, trigger):
except Exception as e:
checkSongs -= 1
if checkSongs == 0:
bot.debug('radio', 'Exception while trying to get periodic radio data: %s' % e, 'warning')
bot.debug(__file__, 'Exception while trying to get periodic radio data: %s' % e, 'warning')
bot.say('The radio is not responding to the song request.')
bot.say('Turning off radio data checking.')
break
Expand Down

0 comments on commit 9f15c0d

Please sign in to comment.