quick_frontend: use of new logging system
This commit is contained in:
parent
233d4b4268
commit
468206e529
1 changed files with 62 additions and 58 deletions
|
|
@ -18,7 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from logging import debug, info, warning, error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from sat.tools.jid import JID
|
||||
from sat_frontends.quick_frontend.quick_utils import unescapePrivate
|
||||
from sat_frontends.quick_frontend.constants import Const
|
||||
|
|
@ -44,17 +45,17 @@ class QuickChat(object):
|
|||
"""Set the users presents in the contact list for a group chat
|
||||
@param nicks: list of nicknames
|
||||
"""
|
||||
debug (_("Adding users %s to room") % nicks)
|
||||
log.debug (_("Adding users %s to room") % nicks)
|
||||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
|
||||
log.error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
self.occupants.update(nicks)
|
||||
|
||||
def replaceUser(self, nick, show_info=True):
|
||||
"""Add user if it is not in the group list"""
|
||||
debug (_("Replacing user %s") % nick)
|
||||
log.debug (_("Replacing user %s") % nick)
|
||||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to replace user for a non group chat window"))
|
||||
log.error (_("[INTERNAL] trying to replace user for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
len_before = len(self.occupants)
|
||||
self.occupants.add(nick)
|
||||
|
|
@ -63,9 +64,9 @@ class QuickChat(object):
|
|||
|
||||
def removeUser(self, nick, show_info=True):
|
||||
"""Remove a user from the group list"""
|
||||
debug(_("Removing user %s") % nick)
|
||||
log.debug(_("Removing user %s") % nick)
|
||||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to remove user for a non group chat window"))
|
||||
log.error (_("[INTERNAL] trying to remove user for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
self.occupants.remove(nick)
|
||||
if show_info:
|
||||
|
|
@ -80,9 +81,9 @@ class QuickChat(object):
|
|||
|
||||
def changeUserNick(self, old_nick, new_nick):
|
||||
"""Change nick of a user in group list"""
|
||||
debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
|
||||
log.debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
|
||||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to change user nick for a non group chat window"))
|
||||
log.error (_("[INTERNAL] trying to change user nick for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
self.removeUser(old_nick, show_info=False)
|
||||
self.replaceUser(new_nick, show_info=False)
|
||||
|
|
@ -90,14 +91,14 @@ class QuickChat(object):
|
|||
|
||||
def setSubject(self, subject):
|
||||
"""Set title for a group chat"""
|
||||
debug(_("Setting subject to %s") % subject)
|
||||
log.debug(_("Setting subject to %s") % subject)
|
||||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to set subject for a non group chat window"))
|
||||
log.error (_("[INTERNAL] trying to set subject for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
|
||||
def historyPrint(self, size=20, profile='@NONE@'):
|
||||
"""Print the initial history"""
|
||||
debug (_("now we print history"))
|
||||
log.debug (_("now we print history"))
|
||||
def onHistory(history):
|
||||
for line in history:
|
||||
timestamp, from_jid, to_jid, message, _type, extra = line
|
||||
|
|
@ -107,7 +108,7 @@ class QuickChat(object):
|
|||
self.printMessage(JID(from_jid), message, profile, timestamp)
|
||||
|
||||
def onHistoryError(err):
|
||||
error (_("Can't get history"))
|
||||
log.error (_("Can't get history"))
|
||||
|
||||
if self.target.startswith(Const.PRIVATE_PREFIX):
|
||||
target = unescapePrivate(self.target)
|
||||
|
|
@ -146,12 +147,12 @@ class QuickChat(object):
|
|||
def startGame(self, game_type, referee, players):
|
||||
"""Configure the chat window to start a game"""
|
||||
#No need to raise an error as game are not mandatory
|
||||
warning(_('startGame is not implemented in this frontend'))
|
||||
log.warning(_('startGame is not implemented in this frontend'))
|
||||
|
||||
def getGame(self, game_type):
|
||||
"""Return class managing the game type"""
|
||||
#No need to raise an error as game are not mandatory
|
||||
warning(_('getGame is not implemented in this frontend'))
|
||||
log.warning(_('getGame is not implemented in this frontend'))
|
||||
|
||||
def updateChatState(self, state, nick=None):
|
||||
"""Set the chat state (XEP-0085) of the contact. Leave nick to None
|
||||
|
|
|
|||
Loading…
Reference in a new issue