mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
45 lines
1.1 KiB
Python
Executable file
45 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# vim:fileencoding=utf-8
|
|
|
|
import sys
|
|
import configparser
|
|
import logging
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
from myutils import enable_pretty_logging
|
|
enable_pretty_logging(logging.DEBUG)
|
|
|
|
from repomon import repomon
|
|
|
|
def check_and_get_repos(config):
|
|
repos = config['multi'].get('repos', 'repository')
|
|
for field in ('name', 'path'):
|
|
if config['multi'].get(field, None) is not None:
|
|
raise ValueError('config %r cannot have default value.' % field)
|
|
|
|
repos = {repo.strip() for repo in repos.split(',')}
|
|
for field in ('name', 'path'):
|
|
vals = [config[repo].get(field) for repo in repos]
|
|
if len(vals) != len(set(vals)):
|
|
raise ValueError('duplicate %s in different repositories.' % field)
|
|
|
|
return repos
|
|
|
|
def main(conffile):
|
|
config = configparser.ConfigParser(default_section='multi')
|
|
config.read(conffile)
|
|
repos = check_and_get_repos(config)
|
|
|
|
notifiers = [repomon(config[repo]) for repo in repos]
|
|
|
|
ioloop = IOLoop.instance()
|
|
try:
|
|
ioloop.start()
|
|
except KeyboardInterrupt:
|
|
ioloop.close()
|
|
for notifier in notifiers:
|
|
notifier.stop()
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1])
|