##// END OF EJS Templates
fix(core): don't rely on pkgutil to extract the version info of project
super-admin -
r1188:dc28b397 default
parent child Browse files
Show More
@@ -15,10 +15,16 b''
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 import pkgutil
18 import os
19 19
20 20
21 __version__ = pkgutil.get_data('vcsserver', 'VERSION').strip().decode()
21 def get_version():
22 here = os.path.abspath(os.path.dirname(__file__))
23 ver_file = os.path.join(here, "VERSION")
24 with open(ver_file, "rt") as f:
25 version = f.read().strip()
26
27 return version
22 28
23 29 # link to config for pyramid
24 30 CONFIG = {}
@@ -87,7 +87,7 b' def install_git_hooks(repo_path, bare, e'
87 87 log.debug('writing git %s hook file at %s !', h_type, _hook_file)
88 88 try:
89 89 with open(_hook_file, 'wb') as f:
90 template = template.replace(b'_TMPL_', safe_bytes(vcsserver.__version__))
90 template = template.replace(b'_TMPL_', safe_bytes(vcsserver.get_version()))
91 91 template = template.replace(b'_DATE_', safe_bytes(timestamp))
92 92 template = template.replace(b'_ENV_', safe_bytes(executable))
93 93 template = template.replace(b'_PATH_', safe_bytes(path))
@@ -140,7 +140,7 b' def install_svn_hooks(repo_path, executa'
140 140
141 141 try:
142 142 with open(_hook_file, 'wb') as f:
143 template = template.replace(b'_TMPL_', safe_bytes(vcsserver.__version__))
143 template = template.replace(b'_TMPL_', safe_bytes(vcsserver.get_version()))
144 144 template = template.replace(b'_DATE_', safe_bytes(timestamp))
145 145 template = template.replace(b'_ENV_', safe_bytes(executable))
146 146 template = template.replace(b'_PATH_', safe_bytes(path))
@@ -465,7 +465,7 b' class HTTPApplication:'
465 465
466 466 return {
467 467 "status": "OK",
468 "vcsserver_version": vcsserver.__version__,
468 "vcsserver_version": vcsserver.get_version(),
469 469 "platform": _platform_id,
470 470 "pid": os.getpid(),
471 471 }
@@ -495,7 +495,7 b' class HTTPApplication:'
495 495 resp = {
496 496 'id': payload.get('id'),
497 497 'result': dict(
498 version=vcsserver.__version__,
498 version=vcsserver.get_version(),
499 499 config=server_config,
500 500 app_config=app_config,
501 501 environ=environ,
@@ -1178,8 +1178,8 b' class HgRemote(RemoteBase):'
1178 1178 @reraise_safe_exceptions
1179 1179 def get_hooks_info(self, wire):
1180 1180 return {
1181 'pre_version': vcsserver.__version__,
1182 'post_version': vcsserver.__version__,
1181 'pre_version': vcsserver.get_version(),
1182 'post_version': vcsserver.get_version(),
1183 1183 }
1184 1184
1185 1185 @reraise_safe_exceptions
@@ -82,7 +82,7 b' class BaseInstallHooks:'
82 82 content = hook_file.read()
83 83
84 84 expected_env = '#!{}'.format(executable)
85 expected_rc_version = "\nRC_HOOK_VER = '{}'\n".format(vcsserver.__version__)
85 expected_rc_version = "\nRC_HOOK_VER = '{}'\n".format(vcsserver.get_version())
86 86 assert content.strip().startswith(expected_env)
87 87 assert expected_rc_version in content
88 88
@@ -76,7 +76,7 b' class RequestWrapperTween:'
76 76 repo_name = call_context.get('X-RC-Repo-Name', '')
77 77
78 78 count = request.request_count()
79 _ver_ = vcsserver.__version__
79 _ver_ = vcsserver.get_version()
80 80 _path = safe_str(get_access_path(request.environ))
81 81
82 82 ip = '127.0.0.1'
General Comments 0
You need to be logged in to leave comments. Login now