dabo Commit
Revision 4236
Date: 2008-07-04 17:06:29 -0700 (Fri, 04 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4236

Changed:
U   trunk/dabo/dApp.py

Log:
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.


Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2008-07-04 19:46:02 UTC (rev 4235)
+++ trunk/dabo/dApp.py  2008-07-05 00:06:29 UTC (rev 4236)
@@ -622,14 +622,20 @@
                        # Nothing to do
                        return
                u2 = urllib2
-               # os.path.join works great for this; just make sure that the 
+               # os.path.join works great for this; just make sure that any 
Windows
+               # paths are converted to forward slashes, and that the 
                # pth value doesn't begin with a slash
-               url = os.path.join(self.SourceURL, pth.lstrip("/"))
+               pth = pth.lstrip(os.path.sep)
+               urlparts = base.split(os.path.sep) + pth.split(os.path.sep)
+               url = "/".join(urlparts)
                req = u2.Request(url)
                lastmod = self._sourceLastModified.get(url)
                resp = None
                if lastmod:
                        req.add_header("If-Modified-Since", lastmod)
+               elif os.path.exists(pth):
+                       modTime = 
datetime.datetime.fromtimestamp(os.stat(pth)[8])
+                       req.add_header("If-Modified-Since", 
dabo.lib.dates.webHeaderFormat(modTime))
                try:
                        resp = u2.urlopen(req)
                        lm = resp.headers.get("Last-Modified")
@@ -646,6 +652,7 @@
                newFile = resp.read()
                if newFile:
                        file(pth, "w").write(newFile)
+                       dabo.infoLog.write(_("File %s updated") % pth)
 
 
        def getUserSettingKeys(self, spec):




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to