• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python log.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _wait_on_file

    def _wait_on_file(self, path):
        """Block the running (main) thread if the file <path> is from an
        archive and has not yet been extracted. Return when the file is
        ready.
        """
        if self.archive_type == None or path == None:
            return

        try:
            name = self._name_table[path]
            with self._condition:
                while not self._extractor.is_ready(name) and not self._stop_waiting:
                    self._condition.wait()
        except Exception, ex:
            log.error(u'Waiting on extraction of "%s" failed: %s', path, ex)
            return
开发者ID:StylinGreymon,项目名称:mcomix,代码行数:16,代码来源:file_handler.py


示例17: _extract_file

    def _extract_file(self, name):
        """Extract the file named <name> to the destination directory,
        mark the file as "ready", then signal a notify() on the Condition
        returned by setup().
        """

        try:
            log.debug(u'Extracting from "%s" to "%s": "%s"', self._src, self._dst, name)
            self._archive.extract(name, self._dst)

        except Exception, ex:
            # Better to ignore any failed extractions (e.g. from a corrupt
            # archive) than to crash here and leave the main thread in a
            # possible infinite block. Damaged or missing files *should* be
            # handled gracefully by the main program anyway.
            log.error(_('! Extraction error: %s'), ex)
            log.debug('Traceback:\n%s', traceback.format_exc())
开发者ID:drdrpyan,项目名称:mcomix,代码行数:17,代码来源:archive_extractor.py


示例18: _run

 def _run(self):
     order = None
     while True:
         with self._condition:
             if order is not None:
                 self._processing_orders.remove(order)
             while not self._stop and 0 == len(self._waiting_orders):
                 self._condition.wait()
             if self._stop:
                 return
             order = self._waiting_orders.pop(0)
             self._processing_orders.append(order)
         try:
             self._process_order(order)
         except Exception, e:
             log.error(_('! Worker thread processing %(function)r failed: %(error)s'),
                       { 'function' : self._process_order, 'error' : e })
             log.debug('Traceback:\n%s', traceback.format_exc())
开发者ID:drdrpyan,项目名称:mcomix,代码行数:18,代码来源:worker_thread.py


示例19: _extract_file

    def _extract_file(self, name):
        """Extract the file named <name> to the destination directory,
        mark the file as "ready", then signal a notify() on the Condition
        returned by setup().
        """
        if self._stop:
            self.close()
            return

        try:
            dst_path = os.path.join(self._dst, name)
            log.debug(u'Extracting "%s" to "%s"', name, dst_path)
            self._archive.extract(name, dst_path)

        except Exception, ex:
            # Better to ignore any failed extractions (e.g. from a corrupt
            # archive) than to crash here and leave the main thread in a
            # possible infinite block. Damaged or missing files *should* be
            # handled gracefully by the main program anyway.
            log.error(_('! Extraction error: %s'), ex)
开发者ID:brambg,项目名称:mcomix,代码行数:20,代码来源:archive_extractor.py


示例20: _completely_remove_book

    def _completely_remove_book(self, request_response=True, *args):
        """Remove the currently selected books from the library and the
        hard drive.
        """

        if request_response:

            choice_dialog = gtk.MessageDialog(self._library, 0,
                gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO)
            choice_dialog.set_markup('<span weight="bold" size="larger">' +
                _('Remove books from the library?') +
                '</span>'
            )
            choice_dialog.format_secondary_text(
                _('The selected books will be removed from the library and '
                  'permanently deleted. Are you sure that you want to continue?')
            )
            choice_dialog.set_default_response(gtk.RESPONSE_YES)
            response = choice_dialog.run()
            choice_dialog.destroy()

        # if no request is needed or the user has told us they definitely want to delete the book
        if not request_response or (request_response and response == gtk.RESPONSE_YES):

            # get the array of currently selected books in the book window
            selected_books = self._iconview.get_selected_items()
            book_ids = [ self.get_book_at_path(book) for book in selected_books ]
            paths = [ self._library.backend.get_book_path(book_id) for book_id in book_ids ]

            # Remove books from library
            self._remove_books_from_library()

            # Remove from the harddisk
            for book_path in paths:
                try:
                    # try to delete the book.
                    # this can throw an exception if the path points to folder instead
                    # of a single file
                    os.remove(book_path)
                except Exception:
                    log.error(_('! Could not remove file "%s"') % book_path)
开发者ID:HoverHell,项目名称:mcomix-0,代码行数:41,代码来源:book_area.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minecraft.Minecraft类代码示例发布时间:2022-05-27
下一篇:
Python Instrument.Instrument类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap