handling some exceptions in simple state checker
This commit is contained in:
@@ -10,8 +10,10 @@ import requests
|
|||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
from multiprocessing.context import TimeoutError
|
from multiprocessing.context import TimeoutError
|
||||||
|
from tatsu.exceptions import ParseException
|
||||||
|
|
||||||
from ics import Calendar
|
from ics import Calendar
|
||||||
|
from ics.grammar.parse import ParseError
|
||||||
|
|
||||||
from backend import LrcException
|
from backend import LrcException
|
||||||
from backend.config import Config
|
from backend.config import Config
|
||||||
@@ -66,8 +68,13 @@ def get_calender(rec_id):
|
|||||||
url = get_service_url('org.opencastproject.scheduler') + "/calendars"
|
url = get_service_url('org.opencastproject.scheduler') + "/calendars"
|
||||||
res = session.get(url, params=params)
|
res = session.get(url, params=params)
|
||||||
if res.ok:
|
if res.ok:
|
||||||
logger.debug(res.text)
|
|
||||||
return Calendar(res.text)
|
try:
|
||||||
|
return Calendar(res.text)
|
||||||
|
except (ValueError, ParseException, IndexError, ParseError) as ex:
|
||||||
|
logger.debug(res.text)
|
||||||
|
logger.error("Could not parse calendar for agent {}! ({})".format(rec_id, ex))
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_capture_agents():
|
def get_capture_agents():
|
||||||
@@ -109,6 +116,9 @@ def get_recorder_adapter(recorder_info: dict) -> RecorderAdapter:
|
|||||||
def check_capture_agent_state(a: dict):
|
def check_capture_agent_state(a: dict):
|
||||||
logger.debug("Checking Agent {}".format(a['name']))
|
logger.debug("Checking Agent {}".format(a['name']))
|
||||||
c = get_calender(a['name'])
|
c = get_calender(a['name'])
|
||||||
|
if c is None:
|
||||||
|
logger.error("Could not get calendar for agent {}!".format(a['name']))
|
||||||
|
return
|
||||||
is_recording_in_calendar = len(list(c.timeline.now())) >= 1
|
is_recording_in_calendar = len(list(c.timeline.now())) >= 1
|
||||||
if is_recording_in_calendar:
|
if is_recording_in_calendar:
|
||||||
logger.info("{} has entry in Calender and should therefore be recording... checking now!".format(a['name']))
|
logger.info("{} has entry in Calender and should therefore be recording... checking now!".format(a['name']))
|
||||||
|
|||||||
Reference in New Issue
Block a user