##// 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 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
79 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
80 HTTPBadRequest, HTTPNotAcceptable
80 HTTPBadRequest, HTTPNotAcceptable
81
81
82 from rhodecode.lib.utils2 import safe_str
82 from rhodecode.lib.utils2 import safe_str, fix_PATH
83 from rhodecode.lib.base import BaseVCSController
83 from rhodecode.lib.base import BaseVCSController
84 from rhodecode.lib.auth import get_container_username
84 from rhodecode.lib.auth import get_container_username
85 from rhodecode.lib.utils import is_valid_repo, make_ui
85 from rhodecode.lib.utils import is_valid_repo, make_ui
@@ -220,6 +220,7 b' class SimpleGit(BaseVCSController):'
220 'locked_by': locked_by})
220 'locked_by': locked_by})
221 # set the environ variables for this request
221 # set the environ variables for this request
222 os.environ['RC_SCM_DATA'] = json.dumps(extras)
222 os.environ['RC_SCM_DATA'] = json.dumps(extras)
223 fix_PATH()
223 log.debug('HOOKS extras is %s' % extras)
224 log.debug('HOOKS extras is %s' % extras)
224 baseui = make_ui('db')
225 baseui = make_ui('db')
225 self.__inject_extras(repo_path, baseui, extras)
226 self.__inject_extras(repo_path, baseui, extras)
@@ -27,7 +27,6 b''
27 import os
27 import os
28 import logging
28 import logging
29 import traceback
29 import traceback
30 import urllib
31
30
32 from mercurial.error import RepoError
31 from mercurial.error import RepoError
33 from mercurial.hgweb import hgweb_mod
32 from mercurial.hgweb import hgweb_mod
@@ -36,7 +35,7 b' from paste.httpheaders import REMOTE_USE'
36 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
35 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
37 HTTPBadRequest, HTTPNotAcceptable
36 HTTPBadRequest, HTTPNotAcceptable
38
37
39 from rhodecode.lib.utils2 import safe_str
38 from rhodecode.lib.utils2 import safe_str, fix_PATH
40 from rhodecode.lib.base import BaseVCSController
39 from rhodecode.lib.base import BaseVCSController
41 from rhodecode.lib.auth import get_container_username
40 from rhodecode.lib.auth import get_container_username
42 from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
41 from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
@@ -184,6 +183,7 b' class SimpleHg(BaseVCSController):'
184
183
185 # set the environ variables for this request
184 # set the environ variables for this request
186 os.environ['RC_SCM_DATA'] = json.dumps(extras)
185 os.environ['RC_SCM_DATA'] = json.dumps(extras)
186 fix_PATH()
187 log.debug('HOOKS extras is %s' % extras)
187 log.debug('HOOKS extras is %s' % extras)
188 baseui = make_ui('db')
188 baseui = make_ui('db')
189 self.__inject_extras(repo_path, baseui, extras)
189 self.__inject_extras(repo_path, baseui, extras)
@@ -481,3 +481,19 b' class AttributeDict(dict):'
481 return self.get(attr, None)
481 return self.get(attr, None)
482 __setattr__ = dict.__setitem__
482 __setattr__ = dict.__setitem__
483 __delattr__ = dict.__delitem__
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