3 import distutils
.sysconfig
7 script_dir
= distutils
.sysconfig
.get_config_var('prefix') + os
.sep
+ 'scripts'
8 environment
= 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
10 k
= winreg
.OpenKey(winreg
.HKEY_LOCAL_MACHINE
, environment
, 0, winreg
.KEY_WRITE | winreg
.KEY_READ
)
12 (path
, type) = winreg
.QueryValueEx(k
, 'Path')
14 if not script_dir
in path
.split(os
.pathsep
):
16 if path
.endswith(os
.pathsep
): # sometimes windows likes to stick an extra ; at the end
17 new_path
= path
+ script_dir
+ os
.pathsep
18 else: # other times it's sane...
19 new_path
= path
+ os
.pathsep
+ script_dir
20 print "adding "+script_dir
+" to your windows %PATH% so switzerland can find its packet sniffer"
21 winreg
.SetValueEx(k
, 'Path', 0, type, new_path
)
22 (path
, type) = winreg
.QueryValueEx(k
, 'Path')
23 if not script_dir
in path
.split(os
.pathsep
):
24 print "... well, I tried, but it didn't work. "\
25 "put " + script_dir
+ " in your path to run switzerland."
27 print "telling open applications that your path changed (so you don't have to reboot)"
28 rc
, dwReturnValue
= win32gui
.SendMessageTimeout(win32con
.HWND_BROADCAST
,\
29 win32con
.WM_SETTINGCHANGE
,\
30 0, "Environment", win32con
.SMTO_ABORTIFHUNG
, 5000)
31 print "ok, I updated your path, you should be good to go"
34 print script_dir
+ " is already in your windows path, should be good to go"
36 loaded_everything
= True
38 import _winreg
as winreg
39 import win32gui
, win32con
, win32pipe
, win32process
40 except ImportError, e
:
41 loaded_everything
= False
42 print "Missing python win32 extensions, please install from:"
43 print "http://sourceforge.net/project/showfiles.php?group_id=78018"
44 print "and then rerun this installer to configure switzerland properly"