Mapping URIs as Drives with Python and Win32
March 15, 2005 11:22 AM   Subscribe

I've fallen hard for Python and have been searching for a project to really learn the language with. I'd like to create functionality similar to Windows "Map Network Drive" for URIs using Python, urllib, etc. My questions are: does this seem possible for someone with a decent programming background (but no formal CS training)? Is it a good idea?

The idealized version would be integrated into the Windows shell and turn a directory URI into an accessible directory in Windows Explorer (with proper icons, file info, etc.). Additonal idealization would include abstracting the code enough that it worked with any other OS that cared to use it.

Please pardon, but also correct, any terminology that's not sensible.
posted by yerfatma to Computers & Internet (8 answers total)
 
I don't know much (or, in fact, anything) about integration with Windows Explorer in Python, but I suspect that you'll want Mark Hammond's win32 extensions to do it.
posted by kenko at 11:39 AM on March 15, 2005


Best answer: While not oriented towards the creation of a Windows-mounted filesystem -- which may be rather difficult with Python given Windows' filesystem driver architecture -- this USENIX paper describes the sort of mechanism you're interested in creating: an "HTTP filesystem." The Windows development aspect of it might require some research, but there are some books that might be of interest in helping you get started.

You won't gain a magical portability across OS kernel architectures because of a thoughtful abstraction, but it would make the reuse of your code easier for those other implementations.
posted by majick at 12:31 PM on March 15, 2005


Oh, and as far as it being a good idea: Do you know anything about writing Windows drivers? If not, it might be an interesting if daunting project, although Python may not be the best choice of language for such low-level work. I'm not sure how much of the driver API is available on Python, or how well abstracted it is -- or if you want an entire Python runtime in privileged kernel space. My gut instinct is that the project as you describe it is putting the Python cart in front of the driver-writing horse.

You might, however, have some luck writing it as an Explorer extension, which would not mount as a drive. As far as I know that just involves creating a COM object implementing a certain interface and registering it appropriately. I dunno how well Python excels at COM, but since it otherwise seems to treat Windows as a first class platform it may very well be straightforward.
posted by majick at 3:14 PM on March 15, 2005


You can do Python stuff with COM. But all the Python/Win32 stuff I've done or looked at was pretty messy, mainly because the original Win32 API is so messy. To be honest, anything involving Windows is NOT what I would recommend as a language-learning project. If I had tried even the much more minor Windows stuff (compared to what you're doing) I know now when first learning Python, I probably would have given up.

That said, the win32 extensions are incomplete. ctypes is really nice since it can get to ALL of the Win32 API easily. And any other arbitrary C code.
posted by grouse at 3:43 PM on March 15, 2005


Response by poster: Do you know anything about writing Windows drivers?

Not a thing. Your link to Amazon kinda put me off the whole thing.

anything involving Windows is NOT what I would recommend as a language-learning project

Just to be clear (because I don't want to come across as a complete n00b trying to learn programming), I've already built a small (but robust) application in Python and have done some hacking of others' code. This is more of a long-term relationship project than a first date. And I do have a god bit of COM experience sitting around me at work.
posted by yerfatma at 6:10 PM on March 15, 2005


It depends on the libraries. And it's definetly something someone with no "formal CS traning" can do but

It will be very hard to do, especialy in python because you're going to need to do a lot of low level windows stuff that's designed to operate with C/C++ and languages like that.

Basicaly, it would involve a lot of hackwork, and not really teach you anything about the language.
posted by delmoi at 6:48 PM on March 15, 2005


Oddly enough, something similar came up just recently for me.
I was looking for a webdav implementation in python, so that I could use window's "web folders" to map stuff...
Unfortunately, the existing webdav stuff I could find was either feature-incomplete, relied on a module that had changed significantly, or required me to compile stuff.
I haven't given up completely, but, I haven't gotten anywhere since...
posted by yeoz at 7:11 PM on March 15, 2005


yeoz: so compile some stuff. Cygwin is the easiest way. Other ways (free Microsoft VS.NET compiler) will be faster, but require more work from you.
posted by grouse at 4:05 PM on March 16, 2005


« Older Buying a car   |   What's a good long distance carrier for Toronto? Newer »
This thread is closed to new comments.