コード例 #1
0
ファイル: chat_commands.py プロジェクト: Ninja-1/Circle2
def do_read(self, params_dummy):
    self.show(_('Displaying unread messages.\n'))
    self.lock.acquire()
    try:
        # [(date, index, actual message, address)]
        list = map((lambda msg,ix: (msg[2], ix, msg[0], msg[1])),
                   self.unread_message_list, range(len(self.unread_message_list)))

        for msg_info in list:
            new_item = (msg_info[2], msg_info[0])
            # request, time
            check.check_matches(new_item,
                                chat.incoming_message_history_item_tmpl)
            # Proof: list taken from self.unread_message_list; @I15.  list unmodified
            # other than sorting, and is local to this method and not passed to any
            # other objects (hence not shared with other threads that could write
            # into the list).
            # Relevance: @R.I16.
            self.incoming_message_history.append(new_item)

        _read_and_repeat_helper(self, list)

        # Don't clear the list of unread messages unless they've all been
        # successfully shown (or at least that no exceptions are thrown
        # in this thread).  Of course, for this to be safe, we must hold the
        # lock from before reading the list until after clearing the list, and
        # all updates to the list must hold the lock.
        self.unread_message_list = [ ]
        self.set_prompt()
    finally:
        self.lock.release()
コード例 #2
0
ファイル: chat_commands.py プロジェクト: Ninja-1/Circle2
def do_logout(self,param):
    check.check_matches(param, ['text'])
    
    if param:
        message = param[0]
    else:
        message = ''
    self.app.shutdown(message, 1)