diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-08 13:19:59 -0700 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-08 13:19:59 -0700 |
commit | 5cca83df91aec3e22758bf48683a966c9fc00204 (patch) | |
tree | c7c34da29ffbb92ee49bf68888e0341843835695 | |
parent | e591fb06b06b5a74893b378b94ee459a56737498 (diff) | |
parent | 3fa2c37bd48ef22937c5644995ac443f557c0871 (diff) |
Merge pull request #310 from benediktb/update-runonce
Added "runonce" option to updater
-rw-r--r-- | bin/updater.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/updater.py b/bin/updater.py index 4ada726f3..dab7f6f45 100644 --- a/bin/updater.py +++ b/bin/updater.py @@ -79,13 +79,14 @@ class UpdateThread(threading.Thread): class Updater: - def __init__(self, base_url, thread_num, interval, user, password, timeout): + def __init__(self, base_url, thread_num, interval, user, password, timeout, runonce): self.thread_num = thread_num self.interval = interval self.base_url = base_url self.user = user self.password = password self.timeout = timeout + self.runonce = runonce if self.base_url[-1] != '/': self.base_url += '/' @@ -117,9 +118,10 @@ class Updater: for thread in threads: thread.join() - # wait until the interval finished to run again - time.sleep(self.interval) - self.run() + if self.runonce != True: + # wait until the interval finished to run again + time.sleep(self.interval) + self.run() except (ValueError, urllib.error.HTTPError) as e: print('%s: %s' % (self.base_url, e)) @@ -127,6 +129,8 @@ class Updater: def main(): parser = argparse.ArgumentParser() + parser.add_argument('--runonce', + help='Run update only once', action='store_true') parser.add_argument('--threads', help='How many feeds should be fetched in paralell, defaults to 10', default=10, |