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


Python LibraryDatabase.exists_at方法代码示例

本文整理汇总了Python中calibre.db.legacy.LibraryDatabase.exists_at方法的典型用法代码示例。如果您正苦于以下问题:Python LibraryDatabase.exists_at方法的具体用法?Python LibraryDatabase.exists_at怎么用?Python LibraryDatabase.exists_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在calibre.db.legacy.LibraryDatabase的用法示例。


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

示例1: main

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
def main(args=sys.argv):
    opts, args = create_option_parser().parse_args(args)
    libraries = args[1:]
    for lib in libraries:
        if not lib or not LibraryDatabase.exists_at(lib):
            raise SystemExit(_('There is no calibre library at: %s') % lib)
    if not libraries:
        if not prefs['library_path']:
            raise SystemExit(_('You must specify at least one calibre library'))
        libraries = [prefs['library_path']]

    if opts.auto_reload:
        if opts.daemonize:
            raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
        from calibre.srv.auto_reload import auto_reload, NoAutoReload
        try:
            from calibre.utils.logging import default_log
            return auto_reload(default_log)
        except NoAutoReload as e:
            raise SystemExit(e.message)
    server = Server(libraries, opts)
    if opts.daemonize:
        if not opts.log and not iswindows:
            raise SystemExit('In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon')
        daemonize()
    if opts.pidfile:
        with lopen(opts.pidfile, 'wb') as f:
            f.write(str(os.getpid()))
    signal.signal(signal.SIGTERM, lambda s,f: server.stop())
    if not opts.daemonize and not iswindows:
        signal.signal(signal.SIGHUP, lambda s,f: server.stop())
    server.serve_forever()
开发者ID:bartoreebbo,项目名称:calibre,代码行数:34,代码来源:standalone.py

示例2: __init__

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
 def __init__(self, libraries):
     self.lock = Lock()
     self.lmap = OrderedDict()
     self.library_name_map = {}
     self.original_path_map = {}
     seen = set()
     for original_path in libraries:
         path = canonicalize_path(original_path)
         if path in seen:
             continue
         is_samefile = False
         for s in seen:
             if samefile(s, path):
                 is_samefile = True
                 break
         seen.add(path)
         if is_samefile or not LibraryDatabase.exists_at(path):
             continue
         library_id = library_id_from_path(original_path, self.lmap)
         self.lmap[library_id] = path
         self.library_name_map[library_id] = basename(original_path)
         self.original_path_map[path] = original_path
     self.loaded_dbs = {}
     self.category_caches, self.search_caches, self.tag_browser_caches = (
         defaultdict(OrderedDict), defaultdict(OrderedDict),
         defaultdict(OrderedDict))
开发者ID:bwhitenb5e,项目名称:calibre,代码行数:28,代码来源:library_broker.py

示例3: main

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
def main(args=sys.argv):
    opts, args = create_option_parser().parse_args(args)
    if opts.auto_reload:
        if getattr(opts, 'daemonize', False):
            raise SystemExit(
                'Cannot specify --auto-reload and --daemonize at the same time')
        from calibre.srv.auto_reload import auto_reload, NoAutoReload
        try:
            from calibre.utils.logging import default_log
            return auto_reload(default_log, listen_on=opts.listen_on)
        except NoAutoReload as e:
            raise SystemExit(error_message(e))

    ensure_single_instance()
    if opts.userdb:
        opts.userdb = os.path.abspath(os.path.expandvars(os.path.expanduser(opts.userdb)))
        connect(opts.userdb, exc_class=SystemExit).close()
    if opts.manage_users:
        try:
            manage_users_cli(opts.userdb)
        except (KeyboardInterrupt, EOFError):
            raise SystemExit(_('Interrupted by user'))
        raise SystemExit(0)

    libraries = args[1:]
    for lib in libraries:
        if not lib or not LibraryDatabase.exists_at(lib):
            raise SystemExit(_('There is no calibre library at: %s') % lib)
    libraries = libraries or load_gui_libraries()
    if not libraries:
        if not prefs['library_path']:
            raise SystemExit(_('You must specify at least one calibre library'))
        libraries = [prefs['library_path']]

    opts.auto_reload_port = int(os.environ.get('CALIBRE_AUTORELOAD_PORT', 0))
    opts.allow_console_print = 'CALIBRE_ALLOW_CONSOLE_PRINT' in os.environ
    if opts.log and os.path.isdir(opts.log):
        raise SystemExit('The --log option must point to a file, not a directory')
    if opts.access_log and os.path.isdir(opts.access_log):
        raise SystemExit('The --access-log option must point to a file, not a directory')
    server = Server(libraries, opts)
    if getattr(opts, 'daemonize', False):
        if not opts.log and not iswindows:
            raise SystemExit(
                'In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon'
            )
        daemonize()
    if opts.pidfile:
        with lopen(opts.pidfile, 'wb') as f:
            f.write(unicode_type(os.getpid()).encode('ascii'))
    signal.signal(signal.SIGTERM, lambda s, f: server.stop())
    if not getattr(opts, 'daemonize', False) and not iswindows:
        signal.signal(signal.SIGHUP, lambda s, f: server.stop())
    # Needed for dynamic cover generation, which uses Qt for drawing
    from calibre.gui2 import ensure_app, load_builtin_fonts
    ensure_app(), load_builtin_fonts()
    try:
        server.serve_forever()
    finally:
        shutdown_delete_service()
开发者ID:j-howell,项目名称:calibre,代码行数:62,代码来源:standalone.py

示例4: main

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
def main(args=sys.argv):
    opts, args = create_option_parser().parse_args(args)
    if opts.manage_users:
        try:
            manage_users(opts.userdb)
        except (KeyboardInterrupt, EOFError):
            raise SystemExit(_("Interrupted by user"))
        raise SystemExit(0)

    libraries = args[1:]
    for lib in libraries:
        if not lib or not LibraryDatabase.exists_at(lib):
            raise SystemExit(_("There is no calibre library at: %s") % lib)
    if not libraries:
        if not prefs["library_path"]:
            raise SystemExit(_("You must specify at least one calibre library"))
        libraries = [prefs["library_path"]]

    if opts.auto_reload:
        if opts.daemonize:
            raise SystemExit("Cannot specify --auto-reload and --daemonize at the same time")
        from calibre.srv.auto_reload import auto_reload, NoAutoReload

        try:
            from calibre.utils.logging import default_log

            return auto_reload(default_log)
        except NoAutoReload as e:
            raise SystemExit(e.message)
    opts.auto_reload_port = int(os.environ.get("CALIBRE_AUTORELOAD_PORT", 0))
    try:
        server = Server(libraries, opts)
    except InvalidCredentials as e:
        raise SystemExit(e.message)
    if opts.daemonize:
        if not opts.log and not iswindows:
            raise SystemExit(
                "In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon"
            )
        daemonize()
    if opts.pidfile:
        with lopen(opts.pidfile, "wb") as f:
            f.write(str(os.getpid()))
    signal.signal(signal.SIGTERM, lambda s, f: server.stop())
    if not opts.daemonize and not iswindows:
        signal.signal(signal.SIGHUP, lambda s, f: server.stop())
    server.serve_forever()
开发者ID:nospy,项目名称:calibre,代码行数:49,代码来源:standalone.py

示例5: main

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
def main(args=sys.argv):
    opts, args=create_option_parser().parse_args(args)
    if opts.manage_users:
        try:
            manage_users(opts.userdb)
        except (KeyboardInterrupt, EOFError):
            raise SystemExit(_('Interrupted by user'))
        raise SystemExit(0)

    libraries=args[1:]
    for lib in libraries:
        if not lib or not LibraryDatabase.exists_at(lib):
            raise SystemExit(_('There is no calibre library at: %s') % lib)
    if not libraries:
        if not prefs['library_path']:
            raise SystemExit(_('You must specify at least one calibre library'))
        libraries=[prefs['library_path']]

    if opts.auto_reload:
        if opts.daemonize:
            raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
        from calibre.srv.auto_reload import auto_reload, NoAutoReload
        try:
            from calibre.utils.logging import default_log
            return auto_reload(default_log, listen_on=opts.listen_on)
        except NoAutoReload as e:
            raise SystemExit(e.message)
    opts.auto_reload_port=int(os.environ.get('CALIBRE_AUTORELOAD_PORT', 0))
    opts.allow_console_print = 'CALIBRE_ALLOW_CONSOLE_PRINT' in os.environ
    server=Server(libraries, opts)
    if opts.daemonize:
        if not opts.log and not iswindows:
            raise SystemExit('In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon')
        daemonize()
    if opts.pidfile:
        with lopen(opts.pidfile, 'wb') as f:
            f.write(str(os.getpid()))
    signal.signal(signal.SIGTERM, lambda s,f: server.stop())
    if not opts.daemonize and not iswindows:
        signal.signal(signal.SIGHUP, lambda s,f: server.stop())
    # Needed for dynamic cover generation, which uses Qt for drawing
    from calibre.gui2 import ensure_app, load_builtin_fonts
    ensure_app(), load_builtin_fonts()
    server.serve_forever()
开发者ID:Mymei2,项目名称:calibre,代码行数:46,代码来源:standalone.py

示例6: __init__

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
 def __init__(self, libraries):
     self.lock = Lock()
     self.lmap = {}
     seen = set()
     for i, path in enumerate(os.path.abspath(p) for p in libraries):
         if path in seen:
             continue
         seen.add(path)
         if not LibraryDatabase.exists_at(path):
             continue
         bname = library_id = hexlify(os.path.basename(path).encode('utf-8')).decode('ascii')
         c = 0
         while library_id in self.lmap:
             c += 1
             library_id = bname + '%d' % c
         if i == 0:
             self.default_library = library_id
         self.lmap[library_id] = path
     self.category_caches = {lid:OrderedDict() for lid in self.lmap}
     self.search_caches = {lid:OrderedDict() for lid in self.lmap}
开发者ID:KyoYang,项目名称:calibre,代码行数:22,代码来源:handler.py

示例7: __init__

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
 def __init__(self, libraries):
     self.lock = Lock()
     self.lmap = {}
     seen = set()
     for i, path in enumerate(os.path.abspath(p) for p in libraries):
         if path in seen:
             continue
         seen.add(path)
         if not LibraryDatabase.exists_at(path):
             continue
         bname = library_id = force_unicode(os.path.basename(path), filesystem_encoding).replace(' ', '_')
         c = 0
         while library_id in self.lmap:
             c += 1
             library_id = bname + '%d' % c
         if i == 0:
             self.default_library = library_id
         self.lmap[library_id] = path
     self.category_caches = {lid:OrderedDict() for lid in self.lmap}
     self.search_caches = {lid:OrderedDict() for lid in self.lmap}
     self.tag_browser_caches = {lid:OrderedDict() for lid in self.lmap}
开发者ID:Britlantine,项目名称:calibre,代码行数:23,代码来源:handler.py

示例8: main

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
def main(opts, args, dbctx):
    if opts.report is None:
        checks = CHECKS
    else:
        checks = []
        for r in opts.report.split(','):
            found = False
            for c in CHECKS:
                if c[0] == r:
                    checks.append(c)
                    found = True
                    break
            if not found:
                prints(_('Unknown report check'), r)
                return 1

    if opts.names is None:
        names = []
    else:
        names = [f.strip() for f in opts.names.split(',') if f.strip()]
    if opts.exts is None:
        exts = []
    else:
        exts = [f.strip() for f in opts.exts.split(',') if f.strip()]

    if not LibraryDatabase.exists_at(dbctx.library_path):
        prints('No library found at', dbctx.library_path, file=sys.stderr)
        raise SystemExit(1)

    db = LibraryDatabase(dbctx.library_path)
    prints(_('Vacuuming database...'))
    db.new_api.vacuum()
    checker = CheckLibrary(dbctx.library_path, db)
    checker.scan_library(names, exts)
    for check in checks:
        _print_check_library_results(checker, check, as_csv=opts.csv)

    return 0
开发者ID:JimmXinu,项目名称:calibre,代码行数:40,代码来源:cmd_check_library.py

示例9: is_library_dir_suitable

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
 def is_library_dir_suitable(self, x):
     from calibre.db.legacy import LibraryDatabase
     try:
         return LibraryDatabase.exists_at(x) or not os.listdir(x)
     except:
         return False
开发者ID:davidfor,项目名称:calibre,代码行数:8,代码来源:__init__.py

示例10: is_library_dir_suitable

# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import exists_at [as 别名]
 def is_library_dir_suitable(self, x):
     try:
         return LibraryDatabase.exists_at(x) or not os.listdir(x)
     except:
         return False
开发者ID:azmrv,项目名称:calibre,代码行数:7,代码来源:__init__.py


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