Skip to content

Commit

Permalink
nabweb: fix Upgrade page crash when date was not set for 'Last check'.
Browse files Browse the repository at this point in the history
  • Loading branch information
f-laurens committed Jun 11, 2021
1 parent d18a5fb commit 0619b82
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions nabweb/views.py
Expand Up @@ -473,8 +473,10 @@ def do_get_repository_info(repository, relpath):
if root_dir is None:
return {
"status": "error",
"message": "Cannot find pynab installation from "
"Raspbian systemd services",
"message": "Cannot find Pynab installation from "
"OS systemd services",
"info_date": datetime.datetime.now(),
"name": GitInfo.NAMES[repository],
}
repo_dir = root_dir + "/" + relpath
head_sha1 = (
Expand All @@ -485,6 +487,8 @@ def do_get_repository_info(repository, relpath):
"status": "error",
"message": "Cannot get HEAD - not a git repository? "
"Check /var/log/syslog",
"info_date": datetime.datetime.now(),
"name": GitInfo.NAMES[repository],
}
info = {}
info["head"] = head_sha1
Expand Down Expand Up @@ -523,7 +527,10 @@ def do_get_repository_info(repository, relpath):
!= ""
)
info["tag"] = (
os.popen(f"cd {repo_dir} && git describe --long --tags")
os.popen(
f"cd {repo_dir} && git describe --long 2>/dev/null "
f"|| git describe --long --tags 2>/dev/null"
)
.read()
.strip()
)
Expand Down Expand Up @@ -639,8 +646,8 @@ def post(self, request, *args, **kwargs):
if root_dir is None:
return {
"status": "error",
"message": "Cannot find pynab installation from "
"Raspbian systemd services",
"message": "Cannot find Pynab installation from "
"OS systemd services",
}
locked = (
os.popen(
Expand Down

0 comments on commit 0619b82

Please sign in to comment.