Skip to content

Commit

Permalink
added warning to user if alamut source can't connect
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvanzessen committed May 1, 2023
1 parent dfcb102 commit b7c22dc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sources/alamut.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Tuple
from pydantic import BaseSettings, Field

from aiohttp.client_exceptions import ClientConnectorError, ContentTypeError

from util import get_pdot_abbreviation, reverse_complement

from .source_result import Source, SourceURL
Expand Down Expand Up @@ -105,12 +107,21 @@ async def get_and_parse_annotate(self) -> bool:

url = f"http://{secrets.ip}/annotate?institution={secrets.institution}&apikey={secrets.api_key}&variant={transcript_cdot}"

resp, alamut = await self.async_get_json(url)
# If the Alamut server isn't running nginx will just give an error page
# which can't be parsed to json
try:
resp, alamut = await self.async_get_json(url)
except (ClientConnectorError, ContentTypeError) as e:
alamut_maybe_down_str = "Alamut might be down?"
self.matches_consensus = False
if alamut_maybe_down_str not in self.matches_consensus_tooltip:
self.matches_consensus_tooltip.append(alamut_maybe_down_str)
return True

if resp.status != 200:
self.html_text = "Can't connect to Alamut PC"
self.log_error("Can't connect to Alamut PC")
return
return True

self.new_variant_data["chr"] = alamut["Chromosome"]
self.new_variant_data["pos"] = alamut["gDNA end"]
Expand Down

0 comments on commit b7c22dc

Please sign in to comment.