add without-db config: not actually update databases

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

View file

@ -28,3 +28,6 @@ wait-time: 3
notification-type: simple-udp
notification-address: 127.0.0.1:9900
notification-secret: JiUHuGY987G76djItfOskOj
# If for any reason, you don't want actual database creation or update:
#without-db: true

View file

@ -57,6 +57,7 @@ class RepoMan:
self._command_add = config.get('command-add', 'repo-add')
self._command_remove = config.get('command-remove', 'repo-remove')
self._wait_time = config.getint('wait-time', 10)
self._without_db = config.getboolean('without-db', False)
notification_type = config.get('notification-type', 'null')
if notification_type != 'null':
@ -110,12 +111,22 @@ class RepoMan:
def _do_add(self, toadd):
if toadd:
files, callbacks = zip(*toadd)
self._do_cmd(self._command_add, files, callbacks)
if self._without_db:
self._do_callbacks(callbacks)
else:
self._do_cmd(self._command_add, files, callbacks)
def _do_remove(self, toremove):
if toremove:
files, callbacks = zip(*toremove)
self._do_cmd(self._command_remove, files, callbacks)
if self._without_db:
self._do_callbacks(callbacks)
else:
self._do_cmd(self._command_remove, files, callbacks)
def _do_callbacks(self, callbacks):
for cb in callbacks:
cb()
def add_action(self, action):
logger.info('Adding action %r to db %r', action, self._db_name)