Commit 83abbcba authored by Anuar Ustayev's avatar Anuar Ustayev

[about page][xs]: wrapped helper function into try/except statement to avoid...

[about page][xs]: wrapped helper function into try/except statement to avoid server error and see the error logs - refs eds-pm#47
parent ab0c08c8
Pipeline #41442227 failed with stages
in 11 minutes and 37 seconds
......@@ -7,56 +7,60 @@ log = logging.getLogger(__name__)
def get_info():
root = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'../../../'
))
extensions = []
for _, __, ___ in os.walk(root):
for dir in __:
if dir.startswith('ckanext'):
extensions.append(os.path.join(root, dir))
break
result = {}
for ext in extensions:
ext_name = ext.split('/')[-1]
if ext_name in result.keys():
continue
try:
repo = git.Repo(ext)
except:
# Check if submodule
try:
sub = git.Submodule(ext)
branch, tag = None, None
commit = sub.parent_commit
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
try:
root = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'../../../'
))
extensions = []
for _, __, ___ in os.walk(root):
for dir in __:
if dir.startswith('ckanext'):
extensions.append(os.path.join(root, dir))
break
result = {}
for ext in extensions:
ext_name = ext.split('/')[-1]
if ext_name in result.keys():
continue
try:
repo = git.Repo(ext)
except:
continue
# Check if submodule
try:
sub = git.Submodule(ext)
branch, tag = None, None
commit = sub.parent_commit
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
continue
except:
continue
branch, commit, tag = None, repo.head.commit.hexsha, None
try:
branch = repo.active_branch.name
except TypeError:
pass
branch, commit, tag = None, repo.head.commit.hexsha, None
try:
branch = repo.active_branch.name
except TypeError:
pass
for t in repo.tags:
if t is None:
continue
if t.commit.hexsha == commit:
tag = t.name
for t in repo.tags:
if t is None:
continue
if t.commit.hexsha == commit:
tag = t.name
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
return result
return result
except Exception as e:
log.info('Unexpected error when rendering about page for sysadmin.')
log.debug(e)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment