Skip to content

Commit

Permalink
Add release tag to html
Browse files Browse the repository at this point in the history
  • Loading branch information
WhoisDonlee committed Apr 19, 2024
1 parent b67172a commit 2e82e53
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from pydantic import BaseSettings, Field

from sources import *
from util import get_release_tag

class Settings(BaseSettings):
debug: bool = Field(True, env="DEBUG")
port: int = Field(8080, env="PORT")
release_tag: str = Field(get_release_tag())

sources: List[type] = [
Alamut,
Expand All @@ -32,4 +34,4 @@ def __init__(self):
super().__init__()
self.sources = [source for source in self.sources if source.is_complete(source)]

settings = Settings()
settings = Settings()
3 changes: 2 additions & 1 deletion router.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def index(request: Request):
"index.html.jinja2",
{
"request": request,
"release_tag": settings.release_tag,
}
)

Expand Down Expand Up @@ -304,4 +305,4 @@ async def websocket_endpoint(websocket: WebSocket, search: str):
await send_log(f"Used all sources.", websocket)

except WebSocketDisconnect:
await websocket.close()
await websocket.close()
2 changes: 1 addition & 1 deletion templates/base.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<footer class="footer mt-auto py-3 bg-light">
<div class="container">
<span class="text-muted">
Molclass - 2022
Molclass v{{ release_tag }}&nbsp;&nbsp;2022-2024
</span>
{% block footer %}
{% endblock %}
Expand Down
9 changes: 8 additions & 1 deletion util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import subprocess
# https://molbiol-tools.ca/Amino_acid_abbreviations.htm
protein_conversion = {
"Ala": "A",
Expand Down Expand Up @@ -54,4 +55,10 @@ def relative_path(path: str) -> str:
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, path)
else:
return os.path.join(".", path)
return os.path.join(".", path)

def get_release_tag() -> str:
tag = ""
result = subprocess.run(['git', 'describe', '--tags'], stdout=subprocess.PIPE)
tag = result.stdout.decode().strip()
return tag

0 comments on commit 2e82e53

Please sign in to comment.