예제 #1
0
파일: journal.py 프로젝트: ipeikon/LaBook
    def save_to_disk(self, exit_imminent=False, changing_journal=False, saveas=False):
        #logging.info('Trying to save the journal')

        self.save_old_day()

        try:
            filesystem.make_directory(self.dirs.data_dir)
        except OSError:
            self.frame.show_save_error_dialog(exit_imminent)
            return True

        if not os.path.exists(self.dirs.data_dir):
            logging.error('Save path does not exist')
            self.frame.show_save_error_dialog(exit_imminent)
            return True

        something_saved = storage.save_months_to_disk(self.months,
            self.dirs.data_dir, self.frame, exit_imminent, changing_journal, saveas)

        if something_saved:
            self.show_message(_('The content has been saved to %s') % self.dirs.data_dir, error=False)
            logging.info('The content has been saved to %s' % self.dirs.data_dir)
        else:
            self.show_message(_('Nothing to save'), error=False)

        self.config.save_to_disk()

        if not (exit_imminent or changing_journal) and something_saved:
            # Update cloud
            self.frame.cloud.update(force_update=True)

        # tell gobject to keep saving the content in regular intervals
        return True
예제 #2
0
    def save_to_disk(self, exit_imminent=False, changing_journal=False, saveas=False):
        self.save_old_day()

        try:
            filesystem.make_directory(self.dirs.data_dir)
        except (OSError, IOError):
            self.frame.show_save_error_dialog(exit_imminent)
            return True

        try:
            something_saved = storage.save_months_to_disk(
                self.months, self.dirs.data_dir, exit_imminent, saveas)
        except (IOError, OSError):
            self.frame.show_save_error_dialog(exit_imminent)
            something_saved = None

        if something_saved:
            self.show_message(_('The content has been saved to %s') % self.dirs.data_dir, error=False)
            logging.info('The content has been saved to %r' % self.dirs.data_dir)
        elif something_saved is None:
            # Don't display this as an error, because we already show a dialog.
            self.show_message(_('The journal could not be saved'), error=False)
        else:
            self.show_message(_('Nothing to save'), error=False)

        self.config.save_to_disk()

        if not (exit_imminent or changing_journal) and something_saved:
            # Update cloud
            self.frame.cloud.update(force_update=True)

        # tell gobject to keep saving the content in regular intervals
        return True
예제 #3
0
    def save_to_disk(self):
        if not self.changed():
            return

        lines = []
        for key, value in sorted(self.iteritems()):
            if key not in self.suppressed_keys:
                lines.append("%s=%s" % (key, value))

        try:
            filesystem.make_directory(os.path.dirname(self.filename))
            filesystem.write_file(self.filename, "\n".join(lines))
        except IOError:
            logging.error("Configuration could not be saved. Please check " "your permissions")
        else:
            logging.info("Configuration has been saved to %s" % self.filename)
            self.save_state()
예제 #4
0
    def save_to_disk(self):
        if not self.changed():
            return

        lines = []
        for key, value in sorted(self.iteritems()):
            if key not in self.suppressed_keys:
                lines.append('%s=%s' % (key, value))

        try:
            filesystem.make_directory(os.path.dirname(self.filename))
            filesystem.write_file(self.filename, '\n'.join(lines))
        except IOError:
            logging.error('Configuration could not be saved. Please check '
                          'your permissions')
        else:
            logging.info('Configuration has been saved to %s' % self.filename)
            self.save_state()
예제 #5
0
    def save_to_disk(self,
                     exit_imminent=False,
                     changing_journal=False,
                     saveas=False):
        self.save_old_day()

        try:
            filesystem.make_directory(self.dirs.data_dir)
        except OSError as err:
            logging.error("Creating journal directory failed: {}".format(err))
            self.frame.show_save_error_dialog(exit_imminent)
            return True

        try:
            something_saved = storage.save_months_to_disk(
                self.months, self.dirs.data_dir, exit_imminent, saveas)
        except OSError as err:
            logging.error("Saving month files failed: {}".format(err))
            self.frame.show_save_error_dialog(exit_imminent)
            something_saved = None

        if something_saved:
            self.show_message(_("The content has been saved to %s") %
                              self.dirs.data_dir,
                              error=False)
            logging.info("The content has been saved to %r" %
                         self.dirs.data_dir)
        elif something_saved is None:
            # Don't display this as an error, because we already show a dialog.
            self.show_message(_("The journal could not be saved"), error=False)
        else:
            self.show_message(_("Nothing to save"), error=False)

        self.config.save_to_disk()

        if not (exit_imminent or changing_journal) and something_saved:
            # Update cloud.
            self.frame.cloud.update(force_update=True)
            for tag in self.get_escaped_tags():
                self.frame.search_box.add_entry(tag)

        # tell gobject to keep saving the content in regular intervals
        return True
예제 #6
0
    def save_to_disk(self):
        if not self.changed():
            return

        content = ''
        for key, value in sorted(self.iteritems()):
            if key not in self.suppressed_keys:
                content += ('%s=%s\n' % (key, value))

        try:
            filesystem.make_directory(os.path.dirname(self.file))
            filesystem.write_file(self.file, content)
        except IOError:
            logging.error('Configuration could not be saved. Please check '
                          'your permissions')
            return

        logging.info('Configuration has been saved to %s' % self.file)
        self.save_state()
예제 #7
0
    def save_to_disk(self):
        if not self.changed():
            return

        content = ''
        for key, value in sorted(self.iteritems()):
            if key not in self.suppressed_keys:
                content += ('%s=%s\n' % (key, value))

        try:
            filesystem.make_directory(os.path.dirname(self.file))
            filesystem.write_file(self.file, content)
        except IOError:
            logging.error('Configuration could not be saved. Please check '
                          'your permissions')
            return

        logging.info('Configuration has been saved to %s' % self.file)
        self.save_state()