[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17295: {updater} Support socks. (updater/trunk/lib/thandy)
Author: nickm
Date: 2008-11-16 17:47:01 -0500 (Sun, 16 Nov 2008)
New Revision: 17295
Modified:
updater/trunk/lib/thandy/ClientCLI.py
updater/trunk/lib/thandy/download.py
Log:
Support socks.
Modified: updater/trunk/lib/thandy/ClientCLI.py
===================================================================
--- updater/trunk/lib/thandy/ClientCLI.py 2008-11-16 22:27:17 UTC (rev 17294)
+++ updater/trunk/lib/thandy/ClientCLI.py 2008-11-16 22:47:01 UTC (rev 17295)
@@ -12,16 +12,18 @@
import thandy.download
import thandy.master_keys
import thandy.packagesys.PackageSystem
+import thandy.socksurls
def update(args):
repoRoot = thandy.util.userFilename("cache")
options, args = getopt.getopt(args, "", [ "repo=", "no-download",
"loop", "no-packagesys",
- "install"])
+ "install", "socks-port="])
download = True
keep_looping = False
use_packagesys = True
install = False
+ socksPort = None
for o, v in options:
if o == '--repo':
@@ -34,12 +36,20 @@
use_packagesys = False
elif o == '--install':
install = True
+ elif o == "--socks-port":
+ socksPort = int(v)
+ if socksPort:
+ thandy.socksurls.setSocksProxy("127.0.0.1", socksPort)
+
repo = thandy.repository.LocalRepository(repoRoot)
packagesys = None
if use_packagesys:
packagesys = thandy.packagesys.PackageSystem.PackageMetasystem.create(repo)
+ # XXXX We could make this loop way smarter. Right now, it doesn't
+ # back off between failures, and it doesn't notice newly downloadable files
+ # until all downloading files are finished.
while True:
hashes = {}
installable = {}
@@ -87,7 +97,8 @@
for f in files:
dj = thandy.download.ThandyDownloadJob(f, repo.getFilename(f),
mirrorlist,
- wantHash=hashes.get(f))
+ wantHash=hashes.get(f),
+ useTor=(socksPort!=None))
def successCb(rp=f):
rf = repo.getRequestedFile(rp)
@@ -111,7 +122,7 @@
def usage():
print "Known commands:"
print " update [--repo=repository] [--no-download] [--loop]"
- print " [--no-packagesys] [--install]"
+ print " [--no-packagesys] [--install] [--socks-port=port]"
sys.exit(1)
def main():
Modified: updater/trunk/lib/thandy/download.py
===================================================================
--- updater/trunk/lib/thandy/download.py 2008-11-16 22:27:17 UTC (rev 17294)
+++ updater/trunk/lib/thandy/download.py 2008-11-16 22:47:01 UTC (rev 17295)
@@ -185,7 +185,7 @@
tp, val, tb = sys.exc_info()
logging.warn("Internal during download: %s, %s", val,
traceback.format_exc())
- sys.exit(1)
+ return False
def _download(self):
# Implementation function. Unlike download(), can throw exceptions.
@@ -292,7 +292,7 @@
for c in m['contents']:
if self._supportedURLTypes is not None:
- urltype = urllib2.splittype(m['urlbase'][0])
+ urltype = urllib2.splittype(m['urlbase'])[0]
if urltype.lower() not in self._supportedURLTypes:
continue