Commit 17b72215 by rfkelly0

some python2.5 compatability fixes; thanks Andrew Scheller

parent a3a4bd92
...@@ -24,6 +24,8 @@ is, you probably don't want to use it. ...@@ -24,6 +24,8 @@ is, you probably don't want to use it.
""" """
from __future__ import with_statement
import os import os
import stat as statinfo import stat as statinfo
import time import time
......
import json
import urlparse import urlparse
import mimetypes import mimetypes
...@@ -144,4 +144,4 @@ def serve_fs(fs, indexes=True): ...@@ -144,4 +144,4 @@ def serve_fs(fs, indexes=True):
"""Serves an FS object via WSGI""" """Serves an FS object via WSGI"""
application = WSGIServer(fs, indexes) application = WSGIServer(fs, indexes)
return application return application
\ No newline at end of file
...@@ -957,7 +957,7 @@ class FTPFS(FS): ...@@ -957,7 +957,7 @@ class FTPFS(FS):
def _open_ftp(self): def _open_ftp(self):
try: try:
ftp = FTP() ftp = FTP()
if self.default_timeout: if self.default_timeout or sys.version_info < (2,6,):
ftp.connect(self.host, self.port) ftp.connect(self.host, self.port)
else: else:
ftp.connect(self.host, self.port, self.timeout) ftp.connect(self.host, self.port, self.timeout)
......
...@@ -24,6 +24,10 @@ except Exception, e: ...@@ -24,6 +24,10 @@ except Exception, e:
if isinstance(e,ImportError): if isinstance(e,ImportError):
raise raise
raise ImportError("could not import pyinotify") raise ImportError("could not import pyinotify")
try:
pyinotify.WatchManager.get_fd
except AttributeError:
raise ImportError("pyinotify version is too old")
class OSFSWatchMixin(WatchableFSMixin): class OSFSWatchMixin(WatchableFSMixin):
......
...@@ -573,8 +573,8 @@ def iswildcard(path): ...@@ -573,8 +573,8 @@ def iswildcard(path):
""" """
assert path is not None assert path is not None
base_chars = frozenset(basename(path)) base_chars = frozenset(basename(path))
return not base_chars.isdisjoint(_wild_chars) return bool(base_chars.intersection(_wild_chars))
if __name__ == "__main__": if __name__ == "__main__":
print recursepath('a/b/c') print recursepath('a/b/c')
...@@ -36,7 +36,15 @@ class LazyFS(WrapFS): ...@@ -36,7 +36,15 @@ class LazyFS(WrapFS):
try: try:
wrapped_fs = self.__dict__["wrapped_fs"] wrapped_fs = self.__dict__["wrapped_fs"]
except KeyError: except KeyError:
return u"<LazyFS: %s>" % (self._fsclass,) # It appears that python2.5 has trouble printing out
# classes that define a __unicode__ method.
try:
return u"<LazyFS: %s>" % (self._fsclass,)
except TypeError:
try:
return u"<LazyFS: %s>" % (self._fsclass.__name__,)
except AttributeError:
return u"<LazyFS: <unprintable>>"
else: else:
return u"<LazyFS: %s>" % (wrapped_fs,) return u"<LazyFS: %s>" % (wrapped_fs,)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment