Example #1
0
    def process_queue(self):
        """
        Handle all the messages currently in the queue (if any).
        """
        self.hgthread.process_dialogs()
        enditer = self.textbuffer.get_end_iter()
        while self.hgthread.geterrqueue().qsize():
            try:
                tags = gtklib.gettags('ui.error')
                msg = hglib.toutf(self.hgthread.geterrqueue().get(0))
                self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
                self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
            except Queue.Empty:
                pass
        while self.stdoutq.qsize():
            try:
                tags = gtklib.gettags('ui.error')
                msg = hglib.toutf(self.stdoutq.get(0))
                self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
                self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
            except Queue.Empty:
                pass
        while self.hgthread.getqueue().qsize():
            try:
                msg, label = self.hgthread.getqueue().get(0)
                msg = hglib.toutf(msg)
                tags = gtklib.gettags(label)
                if tags:
                    self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
                else:
                    self.textbuffer.insert(enditer, msg)
                self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
            except Queue.Empty:
                pass

        self.update_progress()
        if not self.hgthread.isAlive():
            self.returncode = self.hgthread.return_code()
            if self.returncode is None:
                self.write(_('\n[command interrupted]'))
            elif self.returncode == 0 and self.cmdlist:
                cmdline = self.cmdlist.pop(0)
                text = '\n' + hglib.toutf(' '.join(cmdline)) + '\n'
                self.textbuffer.insert(enditer, text)
                self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
                self.hgthread = hgthread.HgThread(cmdline[1:])
                self.hgthread.start()
                return True
            self._button_stop.set_sensitive(False)
            self._button_ok.set_sensitive(True)
            self._button_ok.grab_focus()
            if os.name == 'nt':
                os.dup2(self.oldstdout, sys.__stdout__.fileno())
                os.close(self.oldstdout)
            return False # Stop polling this function
        else:
            return True
Example #2
0
 def process_queue(self):
     """
     Handle all the messages currently in the queue (if any).
     """
     self.hgthread.process_dialogs()
     while self.hgthread.geterrqueue().qsize():
         try:
             msg = self.hgthread.geterrqueue().get(0)
             self.write_err(msg)
         except Queue.Empty:
             pass
     enditer = self.textbuffer.get_end_iter()
     while self.hgthread.getqueue().qsize():
         try:
             msg, label = self.hgthread.getqueue().get(0)
             msg = hglib.toutf(msg)
             tags = gtklib.gettags(label)
             if tags:
                 self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
             else:
                 self.textbuffer.insert(enditer, msg)
             self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
         except Queue.Empty:
             pass
     self.update_progress()
     if self._cmd_running():
         return True
     else:
         self._stop_button.set_sensitive(False)
         if self.hgthread.return_code() is None:
             self.write_err(_('[command interrupted]'))
         return False # Stop polling this function
Example #3
0
    def append(self, text, error=False):
        """
        Insert text at the end of the TextView.

        text: string you want to append.
        error: if True, append text with 'error' tag. (default: False)
        """
        enditer = self.buffer.get_end_iter()
        if error:
            tags = gtklib.gettags('ui.error')
            self.buffer.insert_with_tags_by_name(enditer, text, *tags)
        else:
            self.buffer.insert(enditer, text)
        self.textview.scroll_to_mark(self.buffer.get_insert(), 0)
Example #4
0
    def process_queue(self):
        """
        Handle all the messages currently in the queue (if any).
        """
        self.hgthread.process_dialogs()
        enditer = self.textbuffer.get_end_iter()
        while self.hgthread.getqueue().qsize():
            try:
                msg, label = self.hgthread.getqueue().get(0)
                msg = hglib.toutf(msg)
                tags = gtklib.gettags(label)
                if tags:
                    self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
                else:
                    self.textbuffer.insert(enditer, msg)
                self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
            except Queue.Empty:
                pass
        while self.hgthread.geterrqueue().qsize():
            try:
                msg = self.hgthread.geterrqueue().get(0)
                self.write_err(msg)
            except Queue.Empty:
                pass
        while self.stdoutq.qsize():
            try:
                msg = self.stdoutq.get(0)
                self.write_err(msg)
            except Queue.Empty:
                pass

        if self.cmd_running():
            return True
        else:
            # Update button states
            self.update_buttons()
            self.stbar.end()
            self.stop_button.set_sensitive(False)
            if self.hgthread.return_code() is None:
                self.write_err(_('[command interrupted]'))
            if not self.notify_func or self.lastcmd[0] != 'pull':
                return False
            if ' '.join(self.lastcmd[:2]) == 'pull --rebase':
                # disable notification; rebase can be poisonous
                self.notify_func = None
                self.notify_args = None
            else:
                self.notify_func(self.notify_args)
            return False # Stop polling this function
Example #5
0
 def write_err(self, msg):
     tags = gtklib.gettags('ui.error')
     enditer = self.textbuffer.get_end_iter()
     self.textbuffer.insert_with_tags_by_name(enditer, msg, *tags)
     self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)