/[svn.andrew.net.au]/scripts/ready2mirror.py
ViewVC logotype

Diff of /scripts/ready2mirror.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by apollock, Tue Nov 14 06:08:42 2006 UTC revision 15 by apollock, Tue Nov 14 06:12:53 2006 UTC
# Line 32  class Request2(urllib2.Request): Line 32  class Request2(urllib2.Request):
32          def __init__(self, url, data=None, headers={},          def __init__(self, url, data=None, headers={},
33                          origin_req_host=None, unverifiable=False, method="GET"):                          origin_req_host=None, unverifiable=False, method="GET"):
34    
35                  urllib2.Request.__init__(self, url, data, headers, origin_req_host, unverifiable)                  urllib2.Request(self, url, data, headers, origin_req_host, unverifiable)
36                  self.method = method                  self.method = method
37    
38          def get_method(self):          def get_method(self):
# Line 45  class Request2(urllib2.Request): Line 45  class Request2(urllib2.Request):
45  def getLastModifiedTime(url):  def getLastModifiedTime(url):
46          """Makes a request for url and returns the Last-Modified header"""          """Makes a request for url and returns the Last-Modified header"""
47    
48          request = urllib2.Request2(url)          request = Request2(url)
49          opener = urllib2.build_opener()          opener = urllib2.build_opener()
50          data = opener.open(request)          data = opener.open(request)
51          return(data.headers.dict["last-modified"])          return(data.headers.dict["last-modified"])
# Line 54  def getLastModifiedTime(url): Line 54  def getLastModifiedTime(url):
54  def URLisNewerThan(url, epoch):  def URLisNewerThan(url, epoch):
55          """Makes an IMS request for url with epoch as the modification time and returns if URL has changed"""          """Makes an IMS request for url with epoch as the modification time and returns if URL has changed"""
56    
57          request = urllib2.Request2(url)          request = Request2(url)
58          request.add_header('If-Modified-Since', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(epoch)))          request.add_header('If-Modified-Since', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(epoch)))
59          opener = urllib2.build_opener(DefaultErrorHandler())          opener = urllib2.build_opener(DefaultErrorHandler())
60          data = opener.open(request)          data = opener.open(request)

Legend:
Removed from v.13  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC 1.1.22