core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
This commit is contained in:
parent
dc5c042fe7
commit
501bc92528
1 changed files with 707 additions and 941 deletions
|
|
@ -19,11 +19,12 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.constants import Const as C
|
||||
from logging import debug, info, warning, error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.xish import domish
|
||||
from twisted.internet import protocol, defer, threads, reactor
|
||||
from twisted.words.protocols.jabber import client, jid, xmlstream
|
||||
from twisted.words.protocols.jabber import error as jab_error
|
||||
from twisted.words.protocols import jabber
|
||||
from twisted.words.protocols.jabber.xmlstream import IQ
|
||||
import random
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ class Quiz(object):
|
|||
self.__class__ = type(self.__class__.__name__, (self.__class__, RoomGame, object), {})
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Plugin Quiz initialization"))
|
||||
log.info(_("Plugin Quiz initialization"))
|
||||
self.inheritFromRoomGame(host)
|
||||
RoomGame._init_(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0})
|
||||
host.bridge.addMethod("quizGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile
|
||||
|
|
@ -180,9 +181,9 @@ class Quiz(object):
|
|||
"""Called when a player give an answer"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
if not profile:
|
||||
error(_("profile %s is unknown") % profile_key)
|
||||
log.error(_("profile %s is unknown") % profile_key)
|
||||
return
|
||||
debug('new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer})
|
||||
log.debug('new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer})
|
||||
mess = self.createGameElt(jid.JID(referee))
|
||||
answer_elt = mess.firstChildElement().addElement('player_answer')
|
||||
answer_elt['player'] = player
|
||||
|
|
@ -280,7 +281,7 @@ Attention, tu es prêt ?""")}
|
|||
status = self.games[room_jid.userhost()]['status']
|
||||
nb_players = len(self.games[room_jid.userhost()]['players'])
|
||||
status[player] = 'ready'
|
||||
debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
|
||||
log.debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
|
||||
if status.values().count('ready') == nb_players: # everybody is ready, we can start the game
|
||||
self.newGame(room_jid, profile)
|
||||
|
||||
|
|
@ -328,4 +329,4 @@ Attention, tu es prêt ?""")}
|
|||
self.host.bridge.quizGameTimerRestarted(room_jid.userhost(), int(elt['time_left']), profile)
|
||||
|
||||
else:
|
||||
error(_('Unmanaged game element: %s') % elt.name)
|
||||
log.error(_('Unmanaged game element: %s') % elt.name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue