Skip to content
Snippets Groups Projects
Commit 6a73c286 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Version 2014-05-06 19:07

parent dea6a7ba
Branches
No related tags found
No related merge requests found
......@@ -6,13 +6,18 @@ import re
import sys
import tempfile
import time
import urlgrabber
import urlgrabber.mirror
import urlparse
import urllib
import mio.exception
import socket
try:
import urlgrabber
import urlgrabber.mirror
import pycurl
except ImportError:
import mio.urlgrabber_compat as urlgrabber
import mio.urlgrabber_compat as pycurl
pass
temp = []
cache = {}
......
......
#
# Hackish compat library when urlgrabber is missing (MacOS)
#
import urllib2
import calendar
import time
INFO_FILETIME = object()
class CurlWrapper:
def __init__(self, url):
self.url = url
self.curl_obj = self
self.scheme = self.url.geturl().split(':', 1)[0]
def getinfo(self, what):
if what == INFO_FILETIME:
modified = self.url.info()["Last-Modified"]
mtime = calendar.timegm(time.strptime(modified,
"%a, %d %b %Y %H:%M:%S %Z"))
return mtime
raise Exception('Unknown getifo %s', what)
def __getattr__(self, what):
return getattr(self.url, what)
pass
class Compat:
URLGrabError = Exception()
def URLGrabber(self):
pass
class MirrorGroup:
def __init__(self, grabber, urls):
self.urls = urls
def urlopen(self, path):
for u in self.urls:
url = "%s/%s" % (u, path)
try:
return CurlWrapper(urllib2.urlopen(url))
except IOError, e:
pass
raise IOError("Failed to get '%s' (%s)" % (path, e))
pass
compat = Compat()
grabber = compat
mirror = grabber
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment