Changeset 4236

Show
Ignore:
Timestamp:
07/04/2008 05:06:29 PM (2 months ago)
Author:
ed
Message:

Fixed some more stupid Windows path quirks in urlFetch(). Also added a check to see if the file being fetched exists on the local machine, and is newer than the web version.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dApp.py

    r4234 r4236  
    623623            return 
    624624        u2 = urllib2 
    625         # os.path.join works great for this; just make sure that the  
     625        # os.path.join works great for this; just make sure that any Windows 
     626        # paths are converted to forward slashes, and that the  
    626627        # pth value doesn't begin with a slash 
    627         url = os.path.join(self.SourceURL, pth.lstrip("/")) 
     628        pth = pth.lstrip(os.path.sep) 
     629        urlparts = base.split(os.path.sep) + pth.split(os.path.sep) 
     630        url = "/".join(urlparts) 
    628631        req = u2.Request(url) 
    629632        lastmod = self._sourceLastModified.get(url) 
     
    631634        if lastmod: 
    632635            req.add_header("If-Modified-Since", lastmod) 
     636        elif os.path.exists(pth): 
     637            modTime = datetime.datetime.fromtimestamp(os.stat(pth)[8]) 
     638            req.add_header("If-Modified-Since", dabo.lib.dates.webHeaderFormat(modTime)) 
    633639        try: 
    634640            resp = u2.urlopen(req) 
     
    647653        if newFile: 
    648654            file(pth, "w").write(newFile) 
     655            dabo.infoLog.write(_("File %s updated") % pth) 
    649656 
    650657