SIGINT seems to work as expected on my WinXP box here (see attached test script).
Need to be careful to only call it from the main thread, but AFAIK that's not a Win32-specific issue.
As far as finding the user's profile directory, tehre about a bajillion and one way sto do it, but I think the most foolproof is something like this:
(also attached in case of tab-mangling)
===BEGIN
def get_current_user_profile():
import win32api
import win32security
import win32profile
PROCESS_QUERY_INFORMATION = 1024
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
token = win32security.OpenProcessToken(handle, win32security.TOKEN_QUERY)
profile_dir = win32profile.GetUserProfileDirectory(token)
return profile_dir
print get_current_user_profile()
====END
This should work on Win2K and up, as long as the user has sufficient rights, which I don't _THINK_ will be a problem for this.
If that doesn't work for some reason, a query on the pywin32 mailing list might turn up something better.
Kevin HornOn Thu, Oct 23, 2008 at 10:57 AM, Christian Vest Hansen
<address@hidden> wrote:
On Thu, Oct 23, 2008 at 12:15 AM, Kevin Horn <
address@hidden> wrote:
> I've applied the following patch (diffed against v0.0.9) to get Fabric
> working on win32.
Ok. I'll apply it once I'm through Niklas Linströms changes.
>
> Not sure if it covers every compatibility area, but it works for me. Are
> there any other areas that are Unixy-specific?
There's a SIGINT trap in _connect(). I don't have access to a windows
machine so I don't know how compatible that is.
There might also be an issue with the user-wide configuration file.
Fabric uses `os.path.expanduser("~/.fabric")` to find that file, but
there's some windows specific issues with that as detailed here:
http://mail.python.org/pipermail/python-list/2006-July/393819.html
>
> Thanks for this tool, its horrifically useful.
>
> Kevin Horn
>
> ==============================
>
> --- fabricold.py Wed Oct 22 17:02:43 2008
> +++ fabric.py Wed Oct 22 17:02:33 2008
> @@ -21,7 +21,12 @@
> import getpass
> import os
> import os.path
> -import pwd
> +try:
> + import pwd
> + _username = pwd.getpwuid(os.getuid())[0]
> +except ImportError:
> + import win32api
> + _username = win32api.GetUserName()
> import re
> import signal
> import subprocess
> @@ -54,7 +59,7 @@
> 'fab_author': __author__,
> 'fab_mode': 'rolling',
> 'fab_port': 22,
> - 'fab_user': pwd.getpwuid(os.getuid())[0],
> + 'fab_user': _username,
> 'fab_password': None,
> 'fab_pkey': None,
> 'fab_key_filename': None,
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.