[py-svn] r13107 - py/dist/py/misc

ggheo at codespeak.net ggheo at codespeak.net
Mon Jun 6 16:02:50 CEST 2005


Author: ggheo
Date: Mon Jun  6 16:02:50 2005
New Revision: 13107

Modified:
   py/dist/py/misc/_dist.py
Log:
Replace %SystemRoot% with actual value when modifying the PATH registry value.


Modified: py/dist/py/misc/_dist.py
==============================================================================
--- py/dist/py/misc/_dist.py	(original)
+++ py/dist/py/misc/_dist.py	Mon Jun  6 16:02:50 2005
@@ -1,5 +1,5 @@
 import py
-import sys, os
+import sys, os, re
 from distutils import sysconfig
 from distutils import core 
 
@@ -100,7 +100,9 @@
     reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
     key = r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
     path = get_registry_value(reg, key, "Path")
-    path += ";" + bindir
+    path += ";" + bindir
+    # Replace %SystemRoot% with actual value
+    path = replace_systemroot(path)
     print "Setting PATH to:", path
     set_registry_value(reg, key, "Path", path)
     #print "Current PATH is:", get_registry_value(reg, key, "Path")
@@ -123,6 +125,18 @@
     k = _winreg.OpenKey(reg, key, 0, _winreg.KEY_WRITE)
     _winreg.SetValueEx(k, value_name, 0, _winreg.REG_SZ, value)
     _winreg.CloseKey(k)
+
+def replace_systemroot(path):
+    dirs = path.split(';')
+    try:
+        systemroot = os.environ['SYSTEMROOT']
+    except KeyError:
+        pass
+    else:
+        dirs = [re.sub('%SystemRoot%', systemroot, dir)
+                for dir in dirs]
+    path = ';'.join(dirs)
+    return path
 
 ### end helpers
 



More information about the pytest-commit mailing list