Esempio n. 1
0
 def gotAnswer(self, rawAnswer):
     """convert the wired answer into something more useful"""
     if isinstance(rawAnswer, tuple):
         answer = nativeString(rawAnswer[0])
         if isinstance(rawAnswer[1], tuple):
             self.args = nativeStringArgs(rawAnswer[1])
         else:
             self.args = nativeStringArgs([rawAnswer[1]])
     else:
         answer = nativeString(rawAnswer)
         self.args = None
     if answer in Message.defined:
         self.answer = Message.defined[answer]
     else:
         if Debug.deferredBlock:
             logDebug(u'Request %s ignores %s' % (self, rawAnswer))
Esempio n. 2
0
File: query.py Progetto: KDE/kajongg
 def __str__(self):
     """the statement"""
     if self.parameters is not None:
         native = nativeStringArgs(self.parameters)
         return "{cmd} [{args}]".format(cmd=self.statement, args=native)
     else:
         return self.statement
Esempio n. 3
0
 def remote_abort(self, tableid, message, *args):
     """the server aborted this game"""
     message = nativeString(message)
     args = nativeStringArgs(args)
     if self.table and self.table.tableid == tableid:
         # translate Robot to Roboter:
         if self.game:
             args = self.game.players.translatePlayerNames(args)
         logWarning(m18n(message, *args))
         if self.game:
             self.game.close()
Esempio n. 4
0
File: rule.py Progetto: KDE/kajongg
 def _initRuleset(self):
     """load ruleset headers but not the rules"""
     if isinstance(self.name, int):
         query = Query(
             "select id,hash,name,description from ruleset where id=?", (self.name,))
     elif isinstance(self.name, list):
         # we got the rules over the wire
         self.rawRules = (nativeStringArgs(x) for x in self.name[1:])
         (self.rulesetId, self.__hash, self.name,
          self.description) = self.name[0]
         self.__hash = nativeString(self.__hash)
         self.load()
                   # load raw rules at once, rules from db only when needed
         return
     else:
         query = Query(
             "select id,hash,name,description from ruleset where hash=?",
             (nativeString(self.name),
             ))
     if len(query.records):
         (self.rulesetId, self.__hash, self.name,
          self.description) = query.records[0]
     else:
         raise Exception('ruleset %s not found' % self.name)