Skip to content
Snippets Groups Projects
Commit d7d951f9 authored by legac's avatar legac
Browse files

Mofigy the helper function get_versions to return the version number of

the application when manage under git.
parent e6d996b6
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
'select publications with a given category code': 'select publications with a given category code', 'select publications with a given category code': 'select publications with a given category code',
'teams': 'équipes', 'teams': 'équipes',
'undefined': 'undéfini', 'undefined': 'undéfini',
'unknown': 'unknown',
'url': 'url', 'url': 'url',
'value already in database or empty': 'value already in database or empty', 'value already in database or empty': 'value already in database or empty',
} }
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
""" """
import re
import os import os
import re
import subprocess
import tempfile
from gluon import current from gluon import current
from gluon.http import HTTP from gluon.http import HTTP
from gluon.validators import (IS_DATE_IN_RANGE, from gluon.validators import (IS_DATE_IN_RANGE,
...@@ -17,6 +20,8 @@ from gluon.validators import (IS_DATE_IN_RANGE, ...@@ -17,6 +20,8 @@ from gluon.validators import (IS_DATE_IN_RANGE,
IS_MATCH, IS_MATCH,
IS_LENGTH) IS_LENGTH)
# basic command
GIT = '/usr/bin/git'
# A field name can only contains [a_zA-Z0-9_] according to web2py # A field name can only contains [a_zA-Z0-9_] according to web2py
table_field = re.compile(r'[\w_]+\.[\w_]+') table_field = re.compile(r'[\w_]+\.[\w_]+')
...@@ -340,8 +345,23 @@ def get_versions(): ...@@ -340,8 +345,23 @@ def get_versions():
# web2py # web2py
li = [str(el) for el in current.request.env.web2py_version if isinstance(el, int)] li = [str(el) for el in current.request.env.web2py_version if isinstance(el, int)]
web2py = '.'.join(li) web2py = '.'.join(li)
# version of the application
myapp = current.T("unknown")
if os.path.exists(GIT):
ref_path = os.getcwd()
os.chdir(server_path)
fi = tempfile.TemporaryFile()
subprocess.call(["git", "describe"], stdout=fi)
fi.seek(0)
myapp = fi.read().strip('\n')
fi.close()
return dict(dbui=dbui, extjs=extjs, mathjax=mathjax, web2py=web2py) os.chdir(ref_path)
return dict(dbui=dbui, extjs=extjs, mathjax=mathjax, web2py=web2py, myapp=myapp)
def get_where_query(table): def get_where_query(table):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment