add multiple repositories support

This commit is contained in:
lilydjwg 2013-08-21 22:19:57 +08:00
parent dd26517106
commit c1fd025c82
2 changed files with 14 additions and 3 deletions

View file

@ -1,3 +1,11 @@
[multi]
# Names of repository config sections, if you have multiple repositories.
# The names should be delimited by commas. And this value is default to
# "repository".
# config names are the same as below, and will act as default if not specified
# in that repository config.
repos: repository
[repository]
# Name of the repository. In below example the Pacman repository db file name
# will be archlinuxcn.db.tar.gz

View file

@ -13,17 +13,20 @@ enable_pretty_logging(logging.DEBUG)
from repomon import repomon
def main(conffile):
config = configparser.ConfigParser()
config = configparser.ConfigParser(default_section='multi')
config.read(conffile)
notifier = repomon(config['repository'])
repos = config['multi'].get('repos', 'repository')
repos = [repo.strip() for repo in repos.split(',')]
notifiers = [repomon(config[repo]) for repo in repos]
ioloop = IOLoop.instance()
try:
ioloop.start()
except KeyboardInterrupt:
ioloop.close()
notifier.stop()
for notifier in notifiers:
notifier.stop()
if __name__ == '__main__':
main(sys.argv[1])