From 9a35bfa25445323b5b1b61126f9ef795812d0e8a Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 11 Apr 2017 14:42:47 +0200 Subject: [PATCH] Send offline status to Opencast when exiting #455 --- galicaster/opencast/client.py | 3 +++ galicaster/opencast/service.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/galicaster/opencast/client.py b/galicaster/opencast/client.py index 55acfa3a..daa588ec 100644 --- a/galicaster/opencast/client.py +++ b/galicaster/opencast/client.py @@ -29,6 +29,7 @@ INIT_ENDPOINT = 'info/me.json' ME_ENDPOINT = 'info/me.json' +SERVICES_ENDPOINT = 'info/components.json' SETRECORDINGSTATE_ENDPOINT = 'capture-admin/recordings/{id}' SETSTATE_ENDPOINT = 'capture-admin/agents/{hostname}' SETCONF_ENDPOINT = 'capture-admin/agents/{hostname}/configuration' @@ -167,6 +168,8 @@ def whoami(self): def welcome(self): return self.__call('GET', INIT_ENDPOINT) + def services(self): + return self.__call('GET', SERVICES_ENDPOINT) def ical(self): icalendar = self.__call('GET', ICAL_ENDPOINT, query_params={'agentid': self.hostname}, headers={'If-None-Match': self.ical_etag}) diff --git a/galicaster/opencast/service.py b/galicaster/opencast/service.py index 0cde4b69..554b981b 100644 --- a/galicaster/opencast/service.py +++ b/galicaster/opencast/service.py @@ -72,6 +72,7 @@ def __init__(self, repo, occlient, scheduler, conf, disp, logger, recorder): self.dispatcher.connect('recorder-started', self.__check_recording_started) self.dispatcher.connect('recorder-stopped', self.__check_recording_stopped) self.dispatcher.connect("recorder-error", self.on_recorder_error) + self.dispatcher.connect("quit", self.on_quit) self.t_stop = None @@ -248,3 +249,11 @@ def on_recorder_error(self, origin=None, error_message=None): if now_is_recording_time: self.scheduler.mp_rec = None self.__set_recording_state(mp, 'capture_error') + + def on_quit(self, origin=None): + import json + from distutils.version import LooseVersion + response = json.loads(self.client.services()) + version = response["rest"][0]["version"] + if LooseVersion("2.3.0") <= LooseVersion(version): + self.client.setstate('offline')