diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-16 22:27:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-16 22:27:17 +0000 |
commit | 48adf40595f127c2bd167aa6774f4ba67e191c0f (patch) | |
tree | 8f200231a5f2a6f4f45a3f964f847457c5da5f00 /lib/thandy/ClientCLI.py | |
parent | 115bc0308c9384967ed25975aa21a312a2591524 (diff) |
attach per-file type-specific metainfo to packages. use metainfo to tell what is already installed. use database to track things we have installed with not attacked version. notice when we have installable files and optionally install them.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17294 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/ClientCLI.py')
-rw-r--r-- | lib/thandy/ClientCLI.py | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index 7d29de7..7818c6d 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -4,32 +4,78 @@ import getopt import logging import os import sys +import time +import thandy.formats import thandy.util import thandy.repository import thandy.download import thandy.master_keys +import thandy.packagesys.PackageSystem def update(args): repoRoot = thandy.util.userFilename("cache") - options, args = getopt.getopt(args, "", [ "repo=", "no-download" ]) + options, args = getopt.getopt(args, "", [ "repo=", "no-download", + "loop", "no-packagesys", + "install"]) download = True + keep_looping = False + use_packagesys = True + install = False for o, v in options: if o == '--repo': repoRoot = v elif o == "--no-download": download = False + elif o == '--loop': + keep_looping = True + elif o == '--no-packagesys': + use_packagesys = False + elif o == '--install': + install = True repo = thandy.repository.LocalRepository(repoRoot) + packagesys = None + if use_packagesys: + packagesys = thandy.packagesys.PackageSystem.PackageMetasystem.create(repo) while True: hashes = {} + installable = {} logging.info("Checking for files to update.") - files = repo.getFilesToUpdate(trackingBundles=args, hashDict=hashes) + files = repo.getFilesToUpdate(trackingBundles=args, hashDict=hashes, + pkgSystems=packagesys, + installableDict=installable) + + if installable and not files: + logging.notice("Ready to install files: %s", + ", ".join(sorted(installable.keys()))) + if install: + # XXXX handle ordering + for h in installable.values(): + h.install() + return + + elif not files: + logging.info("No files to download") + if not keep_looping: + return + + ts = repo.getTimestampFile().get() + age = time.time() - thandy.formats.parseTime(ts['at']) + delay = thandy.repository.MAX_TIMESTAMP_AGE - age + if delay > 3600: + delay = 3600 + elif delay < 0: + delay = 300 + logging.info("Will check again in %s seconds", delay) + time.sleep(delay) + continue + logging.info("Files to download are: %s", ", ".join(sorted(files))) - if not download or not files: + if not download: return mirrorlist = repo.getMirrorlistFile().get() @@ -59,18 +105,13 @@ def update(args): logging.info("All downloads finished.") -# Check my repository - -# Tell me what I need to download - -# Download stuff - # Tell me what to install. def usage(): print "Known commands:" - print " update [--repo=repository] [--no-download]" + print " update [--repo=repository] [--no-download] [--loop]" + print " [--no-packagesys] [--install]" sys.exit(1) def main(): @@ -81,7 +122,7 @@ def main(): usage() cmd = sys.argv[1] args = sys.argv[2:] - if cmd in [ "update", "geturls" ]: + if cmd in [ "update" ]: globals()[cmd](args) else: usage() |