示例#1
0
def test_run_watcher():

    urls = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'share', 'urlwatch', 'examples', 'urls.yaml.example')
    config = os.path.join(os.path.dirname(__file__), 'data', 'urlwatch.yaml')
    cache = os.path.join(os.path.dirname(__file__), 'data', 'cache.db')
    hooks = ''

    config_storage = YamlConfigStorage(config)
    cache_storage = CacheMiniDBStorage(cache)
    urls_storage = UrlsYaml(urls)

    urlwatch_config = TestConfig(config, urls, cache, hooks, True)

    urlwatcher = Urlwatch(urlwatch_config, config_storage, cache_storage, urls_storage)
    urlwatcher.run_jobs()
示例#2
0
文件: cli.py 项目: sunk818/urlwatch
def main():
    config_file = os.path.join(urlwatch_dir, CONFIG_FILE)
    urls_file = os.path.join(urlwatch_dir, URLS_FILE)
    hooks_file = os.path.join(urlwatch_dir, HOOKS_FILE)
    new_cache_file = os.path.join(urlwatch_cache_dir, CACHE_FILE)
    old_cache_file = os.path.join(urlwatch_dir, CACHE_FILE)
    cache_file = new_cache_file
    if os.path.exists(old_cache_file) and not os.path.exists(new_cache_file):
        cache_file = old_cache_file

    command_config = CommandConfig(pkgname, urlwatch_dir, bindir, prefix,
                                   config_file, urls_file, hooks_file,
                                   cache_file, False)
    setup_logger(command_config.verbose)

    # setup storage API
    config_storage = YamlConfigStorage(command_config.config)
    cache_storage = CacheMiniDBStorage(command_config.cache)
    urls_storage = UrlsYaml(command_config.urls)

    # setup urlwatcher
    urlwatch = Urlwatch(command_config, config_storage, cache_storage,
                        urls_storage)
    urlwatch_command = UrlwatchCommand(urlwatch)

    # run urlwatcher
    urlwatch_command.run()
示例#3
0
def test_run_watcher():
    urls = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'share', 'urlwatch', 'examples', 'urls.yaml.example')
    config = os.path.join(os.path.dirname(__file__), 'data', 'urlwatch.yaml')
    cache = os.path.join(os.path.dirname(__file__), 'data', 'cache.db')
    hooks = ''

    config_storage = YamlConfigStorage(config)
    urls_storage = UrlsYaml(urls)
    cache_storage = CacheMiniDBStorage(cache)
    try:
        urlwatch_config = TestConfig(config, urls, cache, hooks, True)

        urlwatcher = Urlwatch(urlwatch_config, config_storage, cache_storage, urls_storage)
        urlwatcher.run_jobs()
    finally:
        cache_storage.close()
示例#4
0
def main():
    config_file = os.path.join(urlwatch_dir, CONFIG_FILE)
    urls_file = os.path.join(urlwatch_dir, URLS_FILE)
    hooks_file = os.path.join(urlwatch_dir, HOOKS_FILE)
    new_cache_file = os.path.join(urlwatch_cache_dir, CACHE_FILE)
    old_cache_file = os.path.join(urlwatch_dir, CACHE_FILE)
    cache_file = new_cache_file
    if os.path.exists(old_cache_file) and not os.path.exists(new_cache_file):
        cache_file = old_cache_file

    command_config = CommandConfig(sys.argv[1:], pkgname, urlwatch_dir, bindir,
                                   prefix, config_file, urls_file, hooks_file,
                                   cache_file, False)
    setup_logger(command_config.verbose)

    # setup storage API
    config_storage = YamlConfigStorage(command_config.config)

    if any(
            command_config.cache.startswith(prefix)
            for prefix in ('redis://', 'rediss://')):
        cache_storage = CacheRedisStorage(command_config.cache)
    else:
        cache_storage = CacheMiniDBStorage(command_config.cache)

    urls_storage = UrlsYaml(command_config.urls)

    # setup urlwatcher
    urlwatch = Urlwatch(command_config, config_storage, cache_storage,
                        urls_storage)
    urlwatch_command = UrlwatchCommand(urlwatch)

    # run urlwatcher
    urlwatch_command.run()
示例#5
0
def test_run_watcher():
    with teardown_func():
        urls = os.path.join(root, 'share', 'urlwatch', 'examples', 'urls.yaml.example')
        config = os.path.join(here, 'data', 'urlwatch.yaml')
        cache = os.path.join(here, 'data', 'cache.db')
        hooks = ''

        config_storage = YamlConfigStorage(config)
        urls_storage = UrlsYaml(urls)
        cache_storage = CacheMiniDBStorage(cache)
        try:
            urlwatch_config = ConfigForTest(config, urls, cache, hooks, True)

            urlwatcher = Urlwatch(urlwatch_config, config_storage, cache_storage, urls_storage)
            urlwatcher.run_jobs()
        finally:
            cache_storage.close()
示例#6
0
def prepare_retry_test():
    urls = os.path.join(here, 'data', 'invalid-url.yaml')
    config = os.path.join(here, 'data', 'urlwatch.yaml')
    cache = os.path.join(here, 'data', 'cache.db')
    hooks = ''

    config_storage = YamlConfigStorage(config)
    cache_storage = CacheMiniDBStorage(cache)
    urls_storage = UrlsYaml(urls)

    urlwatch_config = ConfigForTest(config, urls, cache, hooks, True)
    urlwatcher = Urlwatch(urlwatch_config, config_storage, cache_storage, urls_storage)

    return urlwatcher, cache_storage
示例#7
0
        root_logger.info('turning on verbose logging mode')


if __name__ == '__main__':
    config_file = os.path.join(urlwatch_dir, CONFIG_FILE)
    urls_file = os.path.join(urlwatch_dir, URLS_FILE)
    hooks_file = os.path.join(urlwatch_dir, HOOKS_FILE)
    new_cache_file = os.path.join(urlwatch_cache_dir, CACHE_FILE)
    old_cache_file = os.path.join(urlwatch_dir, CACHE_FILE)
    cache_file = new_cache_file
    if os.path.exists(old_cache_file) and not os.path.exists(new_cache_file):
        cache_file = old_cache_file

    command_config = CommandConfig(pkgname, urlwatch_dir, bindir, prefix,
                                   config_file, urls_file, hooks_file,
                                   cache_file, False)
    setup_logger(command_config.verbose)

    # setup storage API
    config_storage = YamlConfigStorage(command_config.config)
    cache_storage = CacheMiniDBStorage(command_config.cache)
    urls_storage = UrlsYaml(command_config.urls)

    # setup urlwatcher
    urlwatch = Urlwatch(command_config, config_storage, cache_storage,
                        urls_storage)
    urlwatch_command = UrlwatchCommand(urlwatch)

    # run urlwatcher
    urlwatch_command.run()