summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-08-09 23:12:25 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-08-09 23:12:25 +0000
commit664a59fce6ccbf275f6936cf320e0ee412f4184e (patch)
tree4b607bd7842e6d09d07d605600cc7389b355c4ab /fs
parentc4c2e16099a1379ddb31c878ee13f4ff85c29adc (diff)
downloadpyfilesystem-664a59fce6ccbf275f6936cf320e0ee412f4184e.tar.gz
dokan: remove silent-install functionality, it really doesn't belong in this framework
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@409 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs')
-rw-r--r--fs/expose/dokan/__init__.py2
-rw-r--r--fs/expose/dokan/installer.py102
-rw-r--r--fs/osfs/watch_win32.py2
3 files changed, 3 insertions, 103 deletions
diff --git a/fs/expose/dokan/__init__.py b/fs/expose/dokan/__init__.py
index 55a8f55..e682877 100644
--- a/fs/expose/dokan/__init__.py
+++ b/fs/expose/dokan/__init__.py
@@ -72,7 +72,7 @@ from fs.functools import wraps
try:
import libdokan
-except NotImplementedError:
+except (NotImplementedError,EnvironmentError):
raise ImportError("Dokan found but not usable")
diff --git a/fs/expose/dokan/installer.py b/fs/expose/dokan/installer.py
deleted file mode 100644
index 94dd89a..0000000
--- a/fs/expose/dokan/installer.py
+++ /dev/null
@@ -1,102 +0,0 @@
-
-import os
-import shutil
-import subprocess
-import ctypes
-
-kernel32 = ctypes.windll.kernel32
-
-def GetSystemDirectory():
- buf = ctypes.create_unicode_buffer(260)
- if not kernel32.GetSystemDirectoryW(ctypes.byref(buf),260):
- raise ctypes.WinError()
- return buf.value
-
-
-def _tag2vertup(tag):
- bits = []
- for bit in tag.split("-"):
- for bit2 in bit.split("."):
- try:
- bits.append(int(bit2.strip()))
- except ValueError:
- pass
- return tuple(bits)
-
-def install_dokan(release_dir,vendorid="pyfilesystem"):
- """Install dokan from the given release directory."""
- reltag = os.path.basename(release_dir)
- newver = _tag2vertup(reltag)
- sysdir = GetSystemDirectory()
- pfdir = os.path.join(os.environ["PROGRAMFILES"],"Dokan")
- # Is Dokan already installed, and is it safe to upgrade?
- old_reltag = None
- if os.path.exists(os.path.join(sysdir,"drivers","dokan.sys")):
- for nm in os.listdir(pfdir):
- if nm.startswith(vendorid):
- old_reltag = nm[len(vendorid)+1:-4]
- oldver = _tag2vertup(old_reltag)
- if oldver >= newver:
- raise OSError("dokan already at version " + reltag)
- break
- else:
- raise OSError("dokan already installed from another source")
- # Device what version to install based on windows version.
- wver = sys.getwindowsversion()
- if wver < (5,1):
- raise OSError("windows is too old to install dokan")
- if wver < (6,0):
- wtyp = "wxp"
- elif wver < (6,1):
- wtyp = "wlh"
- else:
- wtyp = "win7"
- srcdir = os.path.join(release_dir,wtyp)
- # Terminate the existing install and remove it
- if old_reltag:
- uninstall_dokan(old_reltag)
- # Copy new files to the appropriate place
- if not os.path.exists(pfdir):
- os.makedirs(pfdir)
- f = open(os.path.join(pfdir,vendorid+"-"+reltag+".txt"),"wt")
- try:
- f.write("Dokan automatically installed by " + vendorid + "\n")
- finally:
- f.close()
- shutil.copy2(os.path.join(srcdir,"dll","dokan.dll"),
- os.path.join(sysdir,"dokan.dll"))
- shutil.copy2(os.path.join(srcdir,"sys","dokan.sys"),
- os.path.join(sysdir,"drivers","dokan.sys"))
- shutil.copy2(os.path.join(srcdir,"mounter","mounter.exe"),
- os.path.join(pfdir,"mounter.exe"))
- shutil.copy2(os.path.join(srcdir,"dokanctrl","dokanctl.exe"),
- os.path.join(pfdir,"dokanctl.exe"))
- # Invoke dokanctl to install the drivers
- _dokanctl(pfdir,"/i","a")
-
-
-def uninstall_dokan(release_dir):
- reltag = os.path.basename(release_dir)
- newver = _tag2vertup(reltag)
- sysdir = GetSystemDirectory()
- pfdir = os.path.join(os.environ["PROGRAMFILES"],"Dokan")
- if dokan_installed:
- _dokanctl(pfdir,"/r","a")
- os.unlink(os.path.join(sysdir,"drivers","dokan.sys"))
- os.unlink(os.path.join(sysdir,"dokan.dll"))
- for nm in os.listdir(pfdir):
- os.unlink(os.path.join(pfdir,nm))
-
-def _dokanctl(pfdir,*args):
- dokanctl = os.path.join(pfdir,"dokanctl.exe")
- startupinfo = subprocess.STARTUPINFO()
- startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
- p = subprocess.Popen([dokanctl]+list(args),startupinfo=startupinfo,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- if p.wait() != 0:
- raise OSError("dokanctl failed: " + p.stdout.read())
-
-
-if __name__ == "__main__":
- import sys
- install_dokan(sys.argv[1])
-
diff --git a/fs/osfs/watch_win32.py b/fs/osfs/watch_win32.py
index c587a1b..fa2a350 100644
--- a/fs/osfs/watch_win32.py
+++ b/fs/osfs/watch_win32.py
@@ -237,6 +237,8 @@ class WatchedDirectory(object):
pos = 0
while pos < len(buffer):
jump, action, namelen = struct.unpack("iii",buffer[pos:pos+12])
+ # TODO: this may return a shortname or a longname, with no way
+ # to tell which. Normalise them somehow?
name = buffer[pos+12:pos+12+namelen].decode("utf16")
yield (name,action)
if not jump: