##// END OF EJS Templates
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
marcink -
r2869:ccbdff90 beta
parent child Browse files
Show More
@@ -79,7 +79,7 b' from paste.httpheaders import REMOTE_USE'
79 79 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
80 80 HTTPBadRequest, HTTPNotAcceptable
81 81
82 from rhodecode.lib.utils2 import safe_str
82 from rhodecode.lib.utils2 import safe_str, fix_PATH
83 83 from rhodecode.lib.base import BaseVCSController
84 84 from rhodecode.lib.auth import get_container_username
85 85 from rhodecode.lib.utils import is_valid_repo, make_ui
@@ -220,6 +220,7 b' class SimpleGit(BaseVCSController):'
220 220 'locked_by': locked_by})
221 221 # set the environ variables for this request
222 222 os.environ['RC_SCM_DATA'] = json.dumps(extras)
223 fix_PATH()
223 224 log.debug('HOOKS extras is %s' % extras)
224 225 baseui = make_ui('db')
225 226 self.__inject_extras(repo_path, baseui, extras)
@@ -27,7 +27,6 b''
27 27 import os
28 28 import logging
29 29 import traceback
30 import urllib
31 30
32 31 from mercurial.error import RepoError
33 32 from mercurial.hgweb import hgweb_mod
@@ -36,7 +35,7 b' from paste.httpheaders import REMOTE_USE'
36 35 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
37 36 HTTPBadRequest, HTTPNotAcceptable
38 37
39 from rhodecode.lib.utils2 import safe_str
38 from rhodecode.lib.utils2 import safe_str, fix_PATH
40 39 from rhodecode.lib.base import BaseVCSController
41 40 from rhodecode.lib.auth import get_container_username
42 41 from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
@@ -184,6 +183,7 b' class SimpleHg(BaseVCSController):'
184 183
185 184 # set the environ variables for this request
186 185 os.environ['RC_SCM_DATA'] = json.dumps(extras)
186 fix_PATH()
187 187 log.debug('HOOKS extras is %s' % extras)
188 188 baseui = make_ui('db')
189 189 self.__inject_extras(repo_path, baseui, extras)
@@ -481,3 +481,19 b' class AttributeDict(dict):'
481 481 return self.get(attr, None)
482 482 __setattr__ = dict.__setitem__
483 483 __delattr__ = dict.__delitem__
484
485
486 def fix_PATH(os_=None):
487 """
488 Get current active python path, and append it to PATH variable to fix issues
489 of subprocess calls and different python versions
490 """
491 import sys
492 if os_ is None:
493 import os
494 else:
495 os = os_
496
497 cur_path = os.path.split(sys.executable)[0]
498 if not os.environ['PATH'].startswith(cur_path):
499 os.environ['PATH'] = '%s:%s' % (cur_path, os.environ['PATH'])
General Comments 0
You need to be logged in to leave comments. Login now