-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ImperialCollegeLondon/index-process-data
Adding process data to index view
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
"""Views for the main app.""" | ||
|
||
import asyncio | ||
|
||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import render | ||
from drunc.process_manager.process_manager_driver import ProcessManagerDriver | ||
from drunc.utils.shell_utils import create_dummy_token_from_uname | ||
from druncschema.process_manager_pb2 import ProcessInstanceList, ProcessQuery | ||
|
||
|
||
async def get_session_info() -> ProcessInstanceList: | ||
"""Get info about all sessions from process manager.""" | ||
token = create_dummy_token_from_uname() | ||
pmd = ProcessManagerDriver("drunc:10054", token=token, aio_channel=True) | ||
query = ProcessQuery(names=[".*"]) | ||
return await pmd.ps(query) | ||
|
||
|
||
def index(request: HttpRequest) -> HttpResponse: | ||
"""View that renders the index/home page.""" | ||
return render(request=request, template_name="main/index.html") | ||
val = asyncio.run(get_session_info()) | ||
context = {"values": val.data.values} | ||
|
||
return render(request=request, context=context, template_name="main/index.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters