/[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 1 by apollock, Sun Jun 25 17:33:52 2006 UTC revision 14 by apollock, Tue Nov 14 06:10:26 2006 UTC
# Line 27  class DefaultErrorHandler(urllib2.HTTPDe Line 27  class DefaultErrorHandler(urllib2.HTTPDe
27                  return result                  return result
28    
29    
30    class Request2(urllib2.Request):
31    
32            def __init__(self, url, data=None, headers={},
33                            origin_req_host=None, unverifiable=False, method="GET"):
34    
35                    urllib2.Request.__init__(self, url, data, headers, origin_req_host, unverifiable)
36                    self.method = method
37    
38            def get_method(self):
39                    if self.has_data():
40                            return "POST"
41                    else:
42                            return self.method
43    
44    
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.Request(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 39  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.Request(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)
# Line 48  def URLisNewerThan(url, epoch): Line 63  def URLisNewerThan(url, epoch):
63          else:          else:
64                  return True                  return True
65    
66    def isSyncing():
67            """Returns if the upstream mirror has a lock file indicating it is currently syncing with its upstream"""
68    
69            pass
70    
71  def main():  def main():
72          parser = OptionParser()          parser = OptionParser()

Legend:
Removed from v.1  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.22