当前位置: 首页>>代码示例>>Python>>正文


Python log.error函数代码示例

本文整理汇总了Python中mcomix.log.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_book

    def add_book(self, path, collection=None):
        """Add the archive at <path> to the library. If <collection> is
        not None, it is the collection that the books should be put in.
        Return True if the book was successfully added (or was already
        added).
        """
        path = os.path.abspath(path)
        name = os.path.basename(path)
        info = archive_tools.get_archive_info(path)
        if info is None:
            return False
        format, pages, size = info

        # Thumbnail for the newly added book will be generated once it
        # is actually needed with get_book_thumbnail().
        old = self._con.execute('''select id from Book
            where path = ?''', (path,)).fetchone()
        try:
            if old is not None:
                self._con.execute('''update Book set
                    name = ?, pages = ?, format = ?, size = ?
                    where path = ?''', (name, pages, format, size, path))
            else:
                self._con.execute('''insert into Book
                    (name, path, pages, format, size)
                    values (?, ?, ?, ?, ?)''',
                    (name, path, pages, format, size))
        except dbapi2.Error:
            log.error( _('! Could not add book "%s" to the library'), path )
            return False
        if collection is not None:
            book = self._con.execute('''select id from Book
                where path = ?''', (path,)).fetchone()
            self.add_book_to_collection(book, collection)
        return True
开发者ID:brambg,项目名称:mcomix,代码行数:35,代码来源:backend.py

示例2: __init__

    def __init__(self):
        self._initialized = False
        self._window = None
        self._file_handler = None
        self._image_handler = None
        self._bookmarks = []

        if os.path.isfile(constants.BOOKMARK_PICKLE_PATH):

            try:
                fd = open(constants.BOOKMARK_PICKLE_PATH, 'rb')
                version = cPickle.load(fd)
                packs = cPickle.load(fd)

                for pack in packs:
                    # Handle old bookmarks without date_added attribute
                    if len(pack) == 5:
                        pack = pack + (datetime.datetime.now(),)

                    self.add_bookmark_by_values(*pack)

                fd.close()

            except Exception:
                log.error(_('! Could not parse bookmarks file %s'),
                          constants.BOOKMARK_PICKLE_PATH)
                log.error(_('! Deleting corrupt bookmarks file.'))
                fd.close()
                os.remove(constants.BOOKMARK_PICKLE_PATH)
                self.clear_bookmarks()
开发者ID:brambg,项目名称:mcomix,代码行数:30,代码来源:bookmark_backend.py

示例3: add_collection

 def add_collection(self, name):
     """Add a new collection with <name> to the library. Return True
     if the collection was successfully added.
     """
     try:
         # The Recent pseudo collection initializes the lowest rowid
         # with -2, meaning that instead of starting from 1,
         # auto-incremental will start from -1. Avoid this.
         cur = self._con.execute("""select max(id) from collection""")
         maxid = cur.fetchone()
         if maxid is not None and maxid < 1:
             self._con.execute(
                 """insert into collection
                 (id, name) values (?, ?)""",
                 (1, name),
             )
         else:
             self._con.execute(
                 """insert into Collection
                 (name) values (?)""",
                 (name,),
             )
         return True
     except dbapi2.Error:
         log.error(_('! Could not add collection "%s"'), name)
     return False
开发者ID:Gosha,项目名称:mcomix,代码行数:26,代码来源:backend.py

示例4: delete

 def delete(self, filepath):
     """ Deletes the thumbnail for <filepath> (if it exists) """
     thumbpath = self._path_to_thumbpath(filepath)
     if os.path.isfile(thumbpath):
         try:
             os.remove(thumbpath)
         except IOError, error:
             log.error(_("! Could not remove file \"%s\""), thumbpath)
             log.error(error)
开发者ID:HoverHell,项目名称:mcomix,代码行数:9,代码来源:thumbnail_tools.py

示例5: _initialize

 def _initialize(self):
     """ Restore keybindings from disk. """
     try:
         fp = file(constants.KEYBINDINGS_CONF_PATH, "r")
         stored_action_bindings = json.load(fp)
         fp.close()
     except Exception, e:
         log.error(_("Couldn't load keybindings: %s"), e)
         stored_action_bindings = {}
开发者ID:drdrpyan,项目名称:mcomix,代码行数:9,代码来源:keybindings.py

示例6: add_book_to_collection

 def add_book_to_collection(self, book, collection):
     """Put <book> into <collection>."""
     try:
         self._con.execute('''insert into Contain
             (collection, book) values (?, ?)''', (collection, book))
     except dbapi2.DatabaseError: # E.g. book already in collection.
         pass
     except dbapi2.Error:
         log.error( _('! Could not add book %(book)s to collection %(collection)s'),
             {"book" : book, "collection" : collection} )
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:10,代码来源:backend.py

示例7: add_collection

 def add_collection(self, name):
     """Add a new collection with <name> to the library. Return True
     if the collection was successfully added.
     """
     try:
         self._con.execute('''insert into Collection
             (name) values (?)''', (name,))
         return True
     except dbapi2.Error:
         log.error( _('! Could not add collection "%s"'), name )
     return False
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:11,代码来源:backend.py

示例8: get_book_cover

    def get_book_cover(self, book):
        """Return a pixbuf with a thumbnail of the cover of <book>, or
        None if the cover can not be fetched.
        """
        try:
            path = self._con.execute('''select path from Book
                where id = ?''', (book,)).fetchone()
        except Exception:
            log.error( _('! Non-existant book #%i'), book )
            return None

        return self.get_book_thumbnail(path)
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:12,代码来源:backend.py

示例9: add_book

    def add_book(self, path, collection=None):
        """Add the archive at <path> to the library. If <collection> is
        not None, it is the collection that the books should be put in.
        Return True if the book was successfully added (or was already
        added).
        """
        path = os.path.abspath(path)
        name = os.path.basename(path)
        info = archive_tools.get_archive_info(path)
        if info is None:
            return False
        format, pages, size = info

        # Thumbnail for the newly added book will be generated once it
        # is actually needed with get_book_thumbnail().
        old = self._con.execute(
            """select id from Book
            where path = ?""",
            (path,),
        ).fetchone()
        try:
            cursor = self._con.cursor()
            if old is not None:
                cursor.execute(
                    """update Book set
                    name = ?, pages = ?, format = ?, size = ?
                    where path = ?""",
                    (name, pages, format, size, path),
                )
                book_id = old
            else:
                cursor.execute(
                    """insert into Book
                    (name, path, pages, format, size)
                    values (?, ?, ?, ?, ?)""",
                    (name, path, pages, format, size),
                )
                book_id = cursor.lastrowid

                book = backend_types._Book(
                    book_id, name, path, pages, format, size, datetime.datetime.now().isoformat()
                )
                self.book_added(book)

            cursor.close()

            if collection is not None:
                self.add_book_to_collection(book_id, collection)

            return True
        except dbapi2.Error:
            log.error(_('! Could not add book "%s" to the library'), path)
            return False
开发者ID:Gosha,项目名称:mcomix,代码行数:53,代码来源:backend.py

示例10: get_book_path

    def get_book_path(self, book):
        """Return the filesystem path to <book>, or None if <book> isn't
        in the library.
        """
        try:
            path = self._con.execute('''select path from Book
                where id = ?''', (book,)).fetchone()
        except Exception:
            log.error( _('! Non-existant book #%i'), book )
            return None

        return path
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:12,代码来源:backend.py

示例11: open_dialog

def open_dialog(action, window):
    global _dialog

    if _dialog is None:

        if library_backend.dbapi2 is None:
            log.error( _('! You need an sqlite wrapper to use the library.') )

        else:
            _dialog = _LibraryDialog(window, window.filehandler)

    else:
        _dialog.present()
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:13,代码来源:main_dialog.py

示例12: rename_collection

 def rename_collection(self, collection, name):
     """Rename the <collection> to <name>. Return True if the renaming
     was successful.
     """
     try:
         self._con.execute('''update Collection set name = ?
             where id = ?''', (name, collection))
         return True
     except dbapi2.DatabaseError: # E.g. name taken.
         pass
     except dbapi2.Error:
         log.error( _('! Could not rename collection to "%s"'), name )
     return False
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:13,代码来源:backend.py

示例13: migrate_database_to_library

    def migrate_database_to_library(self, recent_collection):
        """ Moves all information saved in the legacy database
        constants.LASTPAGE_DATABASE_PATH into the library,
        and deleting the old database. """

        if not self.backend.enabled:
            return

        database = self._init_database(constants.LASTPAGE_DATABASE_PATH)

        if database:
            cursor = database.execute(
                """SELECT path, page, time_set
                                         FROM lastread"""
            )
            rows = cursor.fetchall()
            cursor.close()
            database.close()

            for path, page, time_set in rows:
                book = self.backend.get_book_by_path(path)

                if not book:
                    # The path doesn't exist in the library yet
                    if not os.path.exists(path):
                        # File might no longer be available
                        continue

                    self.backend.add_book(path, recent_collection)
                    book = self.backend.get_book_by_path(path)

                    if not book:
                        # The book could not be added
                        continue
                else:
                    # The book exists, move into recent collection
                    self.backend.add_book_to_collection(book.id, recent_collection)

                # Set recent info on retrieved book
                # XXX: If the book calls get_backend during migrate_database,
                # the library isn't constructed yet and breaks in an
                # endless recursion.
                book.get_backend = lambda: self.backend
                book.set_last_read_page(page, time_set)

            try:
                os.unlink(constants.LASTPAGE_DATABASE_PATH)
            except IOError, e:
                log.error(_('! Could not remove file "%s"'), constants.LASTPAGE_DATABASE_PATH)
开发者ID:drdrpyan,项目名称:mcomix,代码行数:49,代码来源:last_read_page.py

示例14: add_book_to_collection

 def add_book_to_collection(self, book, collection):
     """Put <book> into <collection>."""
     try:
         self._con.execute(
             """insert into Contain
             (collection, book) values (?, ?)""",
             (collection, book),
         )
         self.book_added_to_collection(self.get_book_by_id(book), collection)
     except dbapi2.DatabaseError:  # E.g. book already in collection.
         pass
     except dbapi2.Error:
         log.error(
             _("! Could not add book %(book)s to collection %(collection)s"),
             {"book": book, "collection": collection},
         )
开发者ID:Gosha,项目名称:mcomix,代码行数:16,代码来源:backend.py

示例15: _get_pixbuf

    def _get_pixbuf(self, index):
        """Return the pixbuf indexed by <index> from cache.
        Pixbufs not found in cache are fetched from disk first.
        """
        pixbuf = constants.MISSING_IMAGE_ICON

        if index not in self._raw_pixbufs:
            self._wait_on_page(index + 1)

            try:
                pixbuf = image_tools.load_pixbuf(self._image_files[index])
                self._raw_pixbufs[index] = pixbuf
                tools.garbage_collect()
            except Exception, e:
                self._raw_pixbufs[index] = constants.MISSING_IMAGE_ICON
                log.error("Could not load pixbuf for page %u: %r", index + 1, e)
开发者ID:StylinGreymon,项目名称:mcomix,代码行数:16,代码来源:image_handler.py


注:本文中的mcomix.log.error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。