[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17293: {updater} Make client downloading work. Testing still needed. Glue sti (updater/trunk/lib/thandy)
Author: nickm
Date: 2008-11-16 16:10:45 -0500 (Sun, 16 Nov 2008)
New Revision: 17293
Modified:
updater/trunk/lib/thandy/ClientCLI.py
updater/trunk/lib/thandy/repository.py
Log:
Make client downloading work. Testing still needed. Glue still needed for installation.
Modified: updater/trunk/lib/thandy/ClientCLI.py
===================================================================
--- updater/trunk/lib/thandy/ClientCLI.py 2008-11-16 21:09:48 UTC (rev 17292)
+++ updater/trunk/lib/thandy/ClientCLI.py 2008-11-16 21:10:45 UTC (rev 17293)
@@ -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,25 +23,42 @@
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:
- return
+ if not download or not files:
+ return
- mirrorlist = repo.getMirrorlistFile().get()
+ mirrorlist = repo.getMirrorlistFile().get()
+ if not mirrorlist:
+ mirrorlist = thandy.master_keys.DEFAULT_MIRRORLIST
- downloader = thandy.download.Downloads()
- downloader.start()
+ downloader = thandy.download.DownloadManager()
- 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.
+ for f in files:
+ dj = thandy.download.ThandyDownloadJob(f, repo.getFilename(f),
+ mirrorlist,
+ wantHash=hashes.get(f))
- # Wait for in-progress jobs
+ def successCb(rp=f):
+ rf = repo.getRequestedFile(rp)
+ if rf != None:
+ rf.clear()
+ rf.load()
+ downloader.addDownloadJob(dj)
+
+ logging.info("Launching downloads")
+ downloader.start()
+
+ logging.info("Waiting for downloads to finish.")
+ downloader.wait()
+ logging.info("All downloads finished.")
+
+
# Check my repository
# Tell me what I need to download
@@ -55,6 +74,9 @@
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]
Modified: updater/trunk/lib/thandy/repository.py
===================================================================
--- updater/trunk/lib/thandy/repository.py 2008-11-16 21:09:48 UTC (rev 17292)
+++ updater/trunk/lib/thandy/repository.py 2008-11-16 21:10:45 UTC (rev 17293)
@@ -174,6 +174,9 @@
def clear(self):
self._mtime = None
+ def load(self):
+ pass
+
def getRelativePath(self):
return self._relativePath
@@ -258,7 +261,7 @@
return pkg
def getRequestedFile(self, relPath):
- """ """
+ """DOCDOC"""
for f in self._metafiles:
if f.getRelativePath() == relPath:
return f
@@ -274,6 +277,8 @@
if rp == relPath:
return PkgFile(self, rp, thandy.formats.parseHash(h))
+ return None
+
def getFilesToUpdate(self, now=None, trackingBundles=(), hashDict=None):
"""Return a set of relative paths for all files that we need
to fetch. Assumes that we care about the bundles