diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-16 21:10:45 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-16 21:10:45 +0000 |
commit | 115bc0308c9384967ed25975aa21a312a2591524 (patch) | |
tree | e99308727aa9fd25712f1ee4c34a6edb0dd34ff0 /lib/thandy/ClientCLI.py | |
parent | f92241888b4dbf4616fa41aab8a92c1c6b37bfbb (diff) |
Make client downloading work. Testing still needed. Glue still needed for installation.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17293 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/ClientCLI.py')
-rw-r--r-- | lib/thandy/ClientCLI.py | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index ad39a2d..7d29de7 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -1,12 +1,14 @@ # Copyright 2008 The Tor Project, Inc. See LICENSE for licensing information. +import getopt +import logging import os import sys -import getopt import thandy.util import thandy.repository import thandy.download +import thandy.master_keys def update(args): repoRoot = thandy.util.userFilename("cache") @@ -21,24 +23,41 @@ def update(args): repo = thandy.repository.LocalRepository(repoRoot) - files = repo.getFilesToUpdate(trackingBundles=args) + while True: + hashes = {} + logging.info("Checking for files to update.") + files = repo.getFilesToUpdate(trackingBundles=args, hashDict=hashes) + logging.info("Files to download are: %s", ", ".join(sorted(files))) + + if not download or not files: + return + + mirrorlist = repo.getMirrorlistFile().get() + if not mirrorlist: + mirrorlist = thandy.master_keys.DEFAULT_MIRRORLIST - if not download: - return + downloader = thandy.download.DownloadManager() - mirrorlist = repo.getMirrorlistFile().get() + for f in files: + dj = thandy.download.ThandyDownloadJob(f, repo.getFilename(f), + mirrorlist, + wantHash=hashes.get(f)) - downloader = thandy.download.Downloads() - downloader.start() + def successCb(rp=f): + rf = repo.getRequestedFile(rp) + if rf != None: + rf.clear() + rf.load() - for f in files: - # XXXX Use hash. - dj = thandy.download.ThandyDownloadJob(f, repo.getFilename(f), - mirrorlist) - downloader.addDownloadJob(dj) - # XXXX replace file in repository if ok; reload; see what changed. + downloader.addDownloadJob(dj) + + logging.info("Launching downloads") + downloader.start() + + logging.info("Waiting for downloads to finish.") + downloader.wait() + logging.info("All downloads finished.") - # Wait for in-progress jobs # Check my repository @@ -55,6 +74,9 @@ def usage(): sys.exit(1) def main(): + #XXXX make this an option. + logging.basicConfig(level=logging.DEBUG) + if len(sys.argv) < 2: usage() cmd = sys.argv[1] |