Esempio n. 1
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename, _selfilter = getsavefilename(self, title,
                 self.historylog_filename, "%s (*.log)" % _("History logs"))
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(unicode(self.get_text_with_eol()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable to save file '%s'</b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (osp.basename(filename),
                                         unicode(error)))
Esempio n. 2
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = translate("ShellBaseWidget", "Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename = QFileDialog.getSaveFileName(self, title,
                         self.historylog_filename, "History logs (*.log)")
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(unicode(filename))
         try:
             encoding.write(unicode(self.text()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(self, title,
                             translate("ShellBaseWidget",
                                       "<b>Unable to save file '%1'</b>"
                                       "<br><br>Error message:<br>%2") \
                             .arg(osp.basename(filename)).arg(str(error)))
Esempio n. 3
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = translate("ShellBaseWidget", "Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename = QFileDialog.getSaveFileName(self, title,
                                            self.historylog_filename,
                                            "History logs (*.log)")
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(unicode(filename))
         try:
             encoding.write(unicode(self.text()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(self, title,
                             translate("ShellBaseWidget",
                                       "<b>Unable to save file '%1'</b>"
                                       "<br><br>Error message:<br>%2") \
                             .arg(osp.basename(filename)).arg(str(error)))
Esempio n. 4
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.redirect_stdio.emit(False)
     filename, _selfilter = getsavefilename(self, title,
                 self.historylog_filename, "%s (*.log)" % _("History logs"))
     self.redirect_stdio.emit(True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(to_text_string(self.get_text_with_eol()),
                            filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError as error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable to save file '%s'</b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (osp.basename(filename),
                                         to_text_string(error)))
Esempio n. 5
0
    def add_to_history(self, command):
        """Add command to history"""
        command = unicode(command)
        if command in ["", "\n"] or command.startswith("Traceback"):
            return
        if command.endswith("\n"):
            command = command[:-1]
        self.histidx = None
        if len(self.history) > 0 and self.history[-1] == command:
            return
        self.history.append(command)
        text = os.linesep + command

        # When the first entry will be written in history file,
        # the separator will be append first:
        if self.history_filename not in HISTORY_FILENAMES:
            HISTORY_FILENAMES.append(self.history_filename)
            text = self.SEPARATOR + text

        encoding.write(text, self.history_filename, mode="ab")
        self.emit(SIGNAL("append_to_history(QString,QString)"), self.history_filename, text)
Esempio n. 6
0
    def add_to_history(self, command):
        """Add command to history"""
        command = to_text_string(command)
        if command in ['', '\n'] or command.startswith('Traceback'):
            return
        if command.endswith('\n'):
            command = command[:-1]
        self.histidx = None
        if len(self.history) > 0 and self.history[-1] == command:
            return
        self.history.append(command)
        text = os.linesep + command

        # When the first entry will be written in history file,
        # the separator will be append first:
        if self.history_filename not in HISTORY_FILENAMES:
            HISTORY_FILENAMES.append(self.history_filename)
            text = self.SEPARATOR + text

        encoding.write(text, self.history_filename, mode='ab')
        self.emit(SIGNAL('append_to_history(QString,QString)'),
                  self.history_filename, text)
Esempio n. 7
0
 def add_to_history(self, command):
     """Add command to history"""
     command = to_text_string(command)
     if command in ['', '\n'] or command.startswith('Traceback'):
         return
     if command.endswith('\n'):
         command = command[:-1]
     self.histidx = None
     if len(self.history)>0 and self.history[-1] == command:
         return
     self.history.append(command)
     text = os.linesep + command
     
     # When the first entry will be written in history file,
     # the separator will be append first:
     if self.history_filename not in HISTORY_FILENAMES:
         HISTORY_FILENAMES.append(self.history_filename)
         text = self.SEPARATOR + text
     
     encoding.write(text, self.history_filename, mode='ab')
     if self.append_to_history is not None:
         self.append_to_history.emit(self.history_filename, text)
Esempio n. 8
0
def create_script(fname):
    """Create a new Python script"""
    text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""])
    encoding.write(to_text_string(text), fname, "utf-8")
Esempio n. 9
0
def create_script(fname):
    """Create a new Python script"""
    text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""])
    encoding.write(to_text_string(text), fname, 'utf-8')
Esempio n. 10
0
def create_script(fname):
    """Create a new Python script"""
    text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""])
    encoding.write(unicode(text), fname, 'utf-8')