diff rhodecode/lib/utils2.py @ 2869:ccbdff90e5a0 beta

fix for issue #578 git hooks sometimes cannot be executed due to different python they runned under, this commit tries to fix that by altering the PATH env variable using current python that rhodecode is running
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 26 Sep 2012 20:59:37 +0200
parents 6b176c679896
children 12fce5e499d5
line wrap: on
line diff
--- a/rhodecode/lib/utils2.py	Sun Sep 23 23:34:09 2012 +0200
+++ b/rhodecode/lib/utils2.py	Wed Sep 26 20:59:37 2012 +0200
@@ -481,3 +481,19 @@
         return self.get(attr, None)
     __setattr__ = dict.__setitem__
     __delattr__ = dict.__delitem__
+
+
+def fix_PATH(os_=None):
+    """
+    Get current active python path, and append it to PATH variable to fix issues
+    of subprocess calls and different python versions
+    """
+    import sys
+    if os_ is None:
+        import os
+    else:
+        os = os_
+
+    cur_path = os.path.split(sys.executable)[0]
+    if not os.environ['PATH'].startswith(cur_path):
+        os.environ['PATH'] = '%s:%s' % (cur_path, os.environ['PATH'])