From da2e259d6e2dc9e7b8fd0ec6162eb42acad5b24e Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:24:27 +0200 Subject: [PATCH 01/15] Update pyca.conf New entry for Input names in pyca.conf. Each Input belongs to one flavor and to one output file, so Input names, flavor names and output names must be unique and must have the same number. The inputs are sent to the opencast-server and should/must be selected with new schedule entries. If inputs is not defined (default is=''), each track/flavor/output-file is added to the media package and uploaded. Flavor names must be unique because they are used to find the input behind the output file. This is a work-around because I did not want to change the database entries. It would be better to have the input name in the event.track database entry as [input, flavor, output_file], but then more changes are needed. --- etc/pyca.conf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/etc/pyca.conf b/etc/pyca.conf index 409f4dd1..eb5068f7 100644 --- a/etc/pyca.conf +++ b/etc/pyca.conf @@ -40,6 +40,12 @@ # Default: sqlite:///pyca.db #database = sqlite:///pyca.db +# Name of Inputs +# If inputs='' or selected inputs in event attachment='' all tracks are uploaded +# Type: list of strings (write as '...', '...') +# default: inputs = '' +# inputs = 'HDMI', 'presenter', 'black board' + [capture] @@ -78,8 +84,9 @@ directory = './recordings' # Default: ffmpeg -nostats -re -f lavfi -r 25 -i testsrc -t {{time}} {{dir}}/{{name}}.webm' command = 'ffmpeg -nostats -re -f lavfi -r 25 -i testsrc -f lavfi -i sine -t {{time}} {{dir}}/{{name}}.webm' -# Flavors of output files produced by the capture command. One flavors should -# be specified for every output file. +# Flavors of output files produced by the capture command. One flavors must +# be specified for every output file an Input. Flavor-names must be unique, number +# of flavors = number of inputs = number of output files # Type: list of strings (write as '...', '...') # Default: 'presenter/source' #flavors = 'presenter/source' From 59291ca20a2d5e7f65baa10641e25e6c34aaf945 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:26:45 +0200 Subject: [PATCH 02/15] Update config.py Added entry for inputs --- pyca/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyca/config.py b/pyca/config.py index a6668850..6862dc7a 100644 --- a/pyca/config.py +++ b/pyca/config.py @@ -20,6 +20,7 @@ cal_lookahead = integer(min=0, default=14) backup_mode = boolean(default=false) database = string(default='sqlite:///pyca.db') +inputs = force_list(default=list('')) [capture] directory = string(default='./recordings') From aae8608080bc31a746127e01da8d1fa9e6e11c10 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:38:32 +0200 Subject: [PATCH 03/15] Update ingest.py - added function get_input_params(event) to extract 'capture.device.names' property from attachment, - added function trackinput_selected(event,flavor, track) to decide if flavor/track has corresponding input to attachment - add only tracks to mediapackage if trackinput_selected() is True --- pyca/ingest.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/pyca/ingest.py b/pyca/ingest.py index 5e984062..9a5949f2 100644 --- a/pyca/ingest.py +++ b/pyca/ingest.py @@ -22,6 +22,59 @@ logger = logging.getLogger(__name__) notify = sdnotify.SystemdNotifier() +def get_input_params(event): + '''Extract the input configuration parameters from the properties attached + to the schedule-entry + ''' + + inputs = [] + for attachment in event.get_data().get('attach'): + data = attachment.get('data') + if (attachment.get('x-apple-filename') == 'org.opencastproject.capture.agent.properties'): + for prop in data.split('\n'): + if prop.startswith('capture.device.names'): + param = prop.split('=', 1) + inputs = param[1].split(',') + break + return inputs + + +def trackinput_selected(event,flavor, track): + ''' check if input corresponding to flavor is selected in schedule-attachment + parameter 'capture.device.names' + returns True if input is selected or if capture.device.names='' + ''' + + # inputs from pyca.conf + inputs_conf = config('agent', 'inputs') + + # if no inputs defined, return True -> add all tracks to mediapackage + if (inputs_conf == ['']): + logger.info('No inputs in config defined') + return True + + # flavors from pyca.conf + flavors_conf = config('capture', 'flavors') + + # inputs in event attachment + inputs_event = get_input_params(event) + + # if no inputs in attachment, return True -> add all tracks to mediapackage + if (inputs_event == ['']): + logger.info('No inputs in schedule') + # print('No inputs in event attachment') + return True + + # Input corresponding to track-flavor from pyca.conf + input_track = inputs_conf[flavors_conf.index(flavor)] + + if input_track in inputs_event: + # Input corresponding to flavor is selected in attachment + return True + + # Input corresponding to flavor is not selected in attachment + return False + def get_config_params(properties): '''Extract the set of configuration parameters from the properties attached @@ -86,11 +139,14 @@ def ingest(event): # add track for (flavor, track) in event.get_tracks(): - logger.info('Adding track (%s -> %s)', flavor, track) - track = track.encode('ascii', 'ignore') - fields = [('mediaPackage', mediapackage), ('flavor', flavor), + if (trackinput_selected(event, flavor, track) == True): + logger.info('Adding track (%s -> %s)', flavor, track) + track = track.encode('ascii', 'ignore') + fields = [('mediaPackage', mediapackage), ('flavor', flavor), ('BODY1', (pycurl.FORM_FILE, track))] - mediapackage = http_request(service_url + '/addTrack', fields) + mediapackage = http_request(service_url + '/addTrack', fields) + else: + logger.info('Ignoring track (%s -> %s)', flavor, track) # ingest logger.info('Ingest recording') From b9ed2f7df338ee3c7dfe0e64b3958f5445a0baf1 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:16:53 +0200 Subject: [PATCH 04/15] Update utils.py - capture.py will not start capturing if connection to opencast endpoint is not possible. In original service() will endless stay in while-loop with 5sec sleep until endpoint is connected. This is not a good idea, because events in the database will not start recording. To change this, the already installed flag 'force_update' is used. The while-loop will only wait and loop if force_update=True and return immediately if force_update=False. force_update is passed through the calling functions register_ca(), recording_state(), set_service_status_immediate(), update_agent_state() - register_ca() is extended by the registration of the input configuration --- pyca/utils.py | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/pyca/utils.py b/pyca/utils.py index 195fed1f..1d1cdbad 100644 --- a/pyca/utils.py +++ b/pyca/utils.py @@ -129,9 +129,14 @@ def service(service_name, force_update=False): service_name, config('services', service_id)) except pycurl.error: - logger.exception('Could not get %s endpoint. Retry in 5s', + if (force_update == True): + logger.exception('Could not get %s endpoint. Retry in 5s', service_name) - time.sleep(5.0) + time.sleep(5.0) + else: + logger.warning('Could not get %s endpoint. Ignoring', + service_name) + break; return config('services', service_id) @@ -140,7 +145,7 @@ def ensurelist(x): return x if type(x) == list else [x] -def register_ca(status='idle'): +def register_ca(status='idle', force_update=False): '''Register this capture agent at the Matterhorn admin server so that it shows up in the admin interface. @@ -151,7 +156,7 @@ def register_ca(status='idle'): # here. We will just run silently in the background: if config('agent', 'backup_mode'): return - service_endpoint = service('capture.admin') + service_endpoint = service('capture.admin', force_update) if not service_endpoint: logger.warning('Missing endpoint for updating agent status.') return @@ -165,8 +170,19 @@ def register_ca(status='idle'): except pycurl.error as e: logger.warning('Could not set agent state to %s: %s', status, e) + # register_configuration + url += '/configuration + inputstring = ",".join(config('agent', 'inputs')) + params=[('configuration','{\'capture.device.names\': \'' + inputstring +'\' }')] + try: + response = http_request(url, params).decode('utf-8') + if response: + logger.info(response) + except pycurl.error as e: + logger.warning('Could not set configuration: %s', e) + -def recording_state(recording_id, status): +def recording_state(recording_id, status, force_update=False): '''Send the state of the current recording to the Matterhorn core. :param recording_id: ID of the current recording @@ -177,9 +193,13 @@ def recording_state(recording_id, status): # in the background: if config('agent', 'backup_mode'): return + service_endpoint = service('capture.admin', force_update) + # check if service_endpoint is availible, otherwise service()[0] is not defined + if not service_endpoint: + logger.warning('Missing endpoint for updating agent status.') + return params = [('state', status)] - url = service('capture.admin')[0] - url += f'/recordings/{recording_id}' + url = f'{service_endpoint[0]}/recordings/{recording_id}' try: result = http_request(url, params).decode('utf-8') logger.info(result) @@ -209,12 +229,12 @@ def set_service_status(dbs, service, status): dbs.commit() -def set_service_status_immediate(service, status): +def set_service_status_immediate(service, status, force_update=False): '''Update the status of a particular service in the database and send an immediate signal to Opencast. ''' set_service_status(service, status) - update_agent_state() + update_agent_state(force_update) @db.with_session @@ -229,7 +249,7 @@ def get_service_status(dbs, service): return db.ServiceStatus.STOPPED -def update_agent_state(): +def update_agent_state(force_update=False): '''Update the current agent state in opencast. ''' status = 'idle' @@ -242,7 +262,7 @@ def update_agent_state(): elif get_service_status(db.Service.INGEST) == db.ServiceStatus.BUSY: status = 'uploading' - register_ca(status=status) + register_ca(status=status, force_update=force_update) def terminate(shutdown=None): From fcd45756e893c908c93a4e9a7092b522afdfd499 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:21:35 +0200 Subject: [PATCH 05/15] Update ingest.py added force_update=True to extended functions --- pyca/ingest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyca/ingest.py b/pyca/ingest.py index 9a5949f2..6bd2afd0 100644 --- a/pyca/ingest.py +++ b/pyca/ingest.py @@ -98,7 +98,7 @@ def ingest(event): # Update status set_service_status(Service.INGEST, ServiceStatus.BUSY) notify.notify('STATUS=Uploading') - recording_state(event.uid, 'uploading') + recording_state(event.uid, 'uploading', force_update=True) update_event_status(event, Status.UPLOADING) # Select ingest service @@ -181,7 +181,7 @@ def safe_start_ingest(event): except Exception: logger.exception('Something went wrong during the upload') # Update state if something went wrong - recording_state(event.uid, 'upload_error') + recording_state(event.uid, 'upload_error', force_update=True) update_event_status(event, Status.FAILED_UPLOADING) set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE) @@ -190,7 +190,7 @@ def control_loop(): '''Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry. ''' - set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE) + set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE, force_update=True) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): From 1e2fc5265e07b790a7aa6e7a3887f4fa1ffb5797 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:45:05 +0200 Subject: [PATCH 06/15] Update schedule.py added force_update=True in service() and check for service_enpdoint, otherwise sevice_endpoint[0] will not exist, uri= changed accordingly --- pyca/schedule.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyca/schedule.py b/pyca/schedule.py index d85dca3a..20e6d380 100644 --- a/pyca/schedule.py +++ b/pyca/schedule.py @@ -66,8 +66,13 @@ def get_schedule(db): lookahead = config('agent', 'cal_lookahead') * 24 * 60 * 60 if lookahead: params['cutoff'] = str((timestamp() + lookahead) * 1000) - uri = '%s/calendars?%s' % (service('scheduler')[0], - urlencode(params)) + + service_endpoint = service('scheduler', force_update=True) + if not service_endpoint: + logger.warning('Missing endpoint for updating schedule.') + return + uri = '%s/calendars?%s' % (service_endpoint[0], + urlencode(params)) try: vcal = http_request(uri) UpstreamState.update_sync_time(config('server', 'url')) From 3097387a5a3ed025b301e1ab25b3fb5c4b4efed2 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:21:25 +0200 Subject: [PATCH 07/15] Update README.rst --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.rst b/README.rst index e10072e2..525ff934 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,15 @@ PyCA – Opencast Capture Agent ============================= +fork with following changes: + +- capture.py will not start capturing if connection to opencast endpoint is not possible. The original function service() will endless stay in a while-loop with 5sec sleep until endpoint is connected. Events in the database will not start recording. To change this, the already installed flag 'force_update' is used. The while-loop will only wait and loop if force_update=True and return immediately if force_update=False. force_update is passed through the calling functions register_ca(), recording_state(), set_service_status_immediate(), update_agent_state() +- Inputs are now possible. The Definition in pyca.conf is extended with an item inputs +- register_ca() is extended by the registration of the input configuration +- Ingest only uploads the selected tracks from schedule events + + + + .. image:: https://github.com/opencast/pyCA/workflows/Test%20pyCA/badge.svg?branch=master :target: https://github.com/opencast/pyCA/actions?query=workflow%3A%22Test+pyCA%22+branch%3Amaster From f52ec72b673367904215ead1f96e0c20622a50cf Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:39:35 +0200 Subject: [PATCH 08/15] Update utils.py --- pyca/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyca/utils.py b/pyca/utils.py index 1d1cdbad..ab292d81 100644 --- a/pyca/utils.py +++ b/pyca/utils.py @@ -171,7 +171,7 @@ def register_ca(status='idle', force_update=False): logger.warning('Could not set agent state to %s: %s', status, e) # register_configuration - url += '/configuration + url += '/configuration' inputstring = ",".join(config('agent', 'inputs')) params=[('configuration','{\'capture.device.names\': \'' + inputstring +'\' }')] try: From 433c60da7e2cdf7f6892d6012de3f61161cd2e7f Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Tue, 16 Aug 2022 21:44:08 +0200 Subject: [PATCH 09/15] Update schedule.py --- pyca/schedule.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyca/schedule.py b/pyca/schedule.py index 20e6d380..d5bbcdce 100644 --- a/pyca/schedule.py +++ b/pyca/schedule.py @@ -66,13 +66,13 @@ def get_schedule(db): lookahead = config('agent', 'cal_lookahead') * 24 * 60 * 60 if lookahead: params['cutoff'] = str((timestamp() + lookahead) * 1000) - + service_endpoint = service('scheduler', force_update=True) if not service_endpoint: logger.warning('Missing endpoint for updating schedule.') return uri = '%s/calendars?%s' % (service_endpoint[0], - urlencode(params)) + urlencode(params)) try: vcal = http_request(uri) UpstreamState.update_sync_time(config('server', 'url')) From 482298b9dc2e8e8b02af2e98c16e134a63f75314 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Tue, 16 Aug 2022 21:56:06 +0200 Subject: [PATCH 10/15] Update utils.py --- pyca/utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pyca/utils.py b/pyca/utils.py index ab292d81..c24c75df 100644 --- a/pyca/utils.py +++ b/pyca/utils.py @@ -129,14 +129,14 @@ def service(service_name, force_update=False): service_name, config('services', service_id)) except pycurl.error: - if (force_update == True): + if force_update: logger.exception('Could not get %s endpoint. Retry in 5s', - service_name) + service_name) time.sleep(5.0) else: - logger.warning('Could not get %s endpoint. Ignoring', - service_name) - break; + logger.warning('Could not get %s endpoint. Ignoring', + service_name) + break return config('services', service_id) @@ -173,7 +173,7 @@ def register_ca(status='idle', force_update=False): # register_configuration url += '/configuration' inputstring = ",".join(config('agent', 'inputs')) - params=[('configuration','{\'capture.device.names\': \'' + inputstring +'\' }')] + params=[('configuration', '{\'capture.device.names\': \'' + inputstring + '\' }')] try: response = http_request(url, params).decode('utf-8') if response: @@ -197,9 +197,9 @@ def recording_state(recording_id, status, force_update=False): # check if service_endpoint is availible, otherwise service()[0] is not defined if not service_endpoint: logger.warning('Missing endpoint for updating agent status.') - return + return params = [('state', status)] - url = f'{service_endpoint[0]}/recordings/{recording_id}' + url = f'{service_endpoint[0]}/recordings/{recording_id}' try: result = http_request(url, params).decode('utf-8') logger.info(result) From 318234d815f87736d801f5e1b728be33a88f6cfa Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Tue, 16 Aug 2022 22:03:44 +0200 Subject: [PATCH 11/15] Update ingest.py --- pyca/ingest.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pyca/ingest.py b/pyca/ingest.py index 6bd2afd0..e083425b 100644 --- a/pyca/ingest.py +++ b/pyca/ingest.py @@ -22,24 +22,26 @@ logger = logging.getLogger(__name__) notify = sdnotify.SystemdNotifier() + def get_input_params(event): '''Extract the input configuration parameters from the properties attached to the schedule-entry ''' - inputs = [] + inputs = [] for attachment in event.get_data().get('attach'): data = attachment.get('data') - if (attachment.get('x-apple-filename') == 'org.opencastproject.capture.agent.properties'): + if (attachment.get('x-apple-filename') == + 'org.opencastproject.capture.agent.properties'): for prop in data.split('\n'): if prop.startswith('capture.device.names'): param = prop.split('=', 1) inputs = param[1].split(',') - break + break return inputs -def trackinput_selected(event,flavor, track): +def trackinput_selected(event, flavor, track): ''' check if input corresponding to flavor is selected in schedule-attachment parameter 'capture.device.names' returns True if input is selected or if capture.device.names='' @@ -54,20 +56,20 @@ def trackinput_selected(event,flavor, track): return True # flavors from pyca.conf - flavors_conf = config('capture', 'flavors') - + flavors_conf = config('capture', 'flavors') + # inputs in event attachment inputs_event = get_input_params(event) - - # if no inputs in attachment, return True -> add all tracks to mediapackage + + # if no inputs in attachment, return True -> add all tracks to mediapackage if (inputs_event == ['']): logger.info('No inputs in schedule') - # print('No inputs in event attachment') + # print('No inputs in event attachment') return True # Input corresponding to track-flavor from pyca.conf input_track = inputs_conf[flavors_conf.index(flavor)] - + if input_track in inputs_event: # Input corresponding to flavor is selected in attachment return True @@ -139,11 +141,11 @@ def ingest(event): # add track for (flavor, track) in event.get_tracks(): - if (trackinput_selected(event, flavor, track) == True): + if trackinput_selected(event, flavor, track): logger.info('Adding track (%s -> %s)', flavor, track) track = track.encode('ascii', 'ignore') fields = [('mediaPackage', mediapackage), ('flavor', flavor), - ('BODY1', (pycurl.FORM_FILE, track))] + ('BODY1', (pycurl.FORM_FILE, track))] mediapackage = http_request(service_url + '/addTrack', fields) else: logger.info('Ignoring track (%s -> %s)', flavor, track) @@ -190,7 +192,8 @@ def control_loop(): '''Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry. ''' - set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE, force_update=True) + set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE, + force_update=True) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): From a5ba7f85fbc69908357fccdcda7c9f086361de26 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:29:03 +0200 Subject: [PATCH 12/15] Update utils.py --- pyca/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyca/utils.py b/pyca/utils.py index c24c75df..eb6575c5 100644 --- a/pyca/utils.py +++ b/pyca/utils.py @@ -180,7 +180,7 @@ def register_ca(status='idle', force_update=False): logger.info(response) except pycurl.error as e: logger.warning('Could not set configuration: %s', e) - + def recording_state(recording_id, status, force_update=False): '''Send the state of the current recording to the Matterhorn core. From 7497d5b0e42adf3f38b3ae65536704c0d4d62748 Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:36:17 +0200 Subject: [PATCH 13/15] Update utils.py --- pyca/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyca/utils.py b/pyca/utils.py index eb6575c5..1add795d 100644 --- a/pyca/utils.py +++ b/pyca/utils.py @@ -173,7 +173,8 @@ def register_ca(status='idle', force_update=False): # register_configuration url += '/configuration' inputstring = ",".join(config('agent', 'inputs')) - params=[('configuration', '{\'capture.device.names\': \'' + inputstring + '\' }')] + params = [('configuration', + '{\'capture.device.names\': \'' + inputstring + '\' }')] try: response = http_request(url, params).decode('utf-8') if response: @@ -194,7 +195,8 @@ def recording_state(recording_id, status, force_update=False): if config('agent', 'backup_mode'): return service_endpoint = service('capture.admin', force_update) - # check if service_endpoint is availible, otherwise service()[0] is not defined + # check if service_endpoint is availible, otherwise service()[0] + # is not defined if not service_endpoint: logger.warning('Missing endpoint for updating agent status.') return From fd6d4aba50870c29337226366805d3453131fbed Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:54:13 +0200 Subject: [PATCH 14/15] Update ingest.py --- pyca/ingest.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pyca/ingest.py b/pyca/ingest.py index e083425b..5f8b6714 100644 --- a/pyca/ingest.py +++ b/pyca/ingest.py @@ -31,8 +31,8 @@ def get_input_params(event): inputs = [] for attachment in event.get_data().get('attach'): data = attachment.get('data') - if (attachment.get('x-apple-filename') == - 'org.opencastproject.capture.agent.properties'): + if (attachment.get('x-apple-filename') == + 'org.opencastproject.capture.agent.properties'): for prop in data.split('\n'): if prop.startswith('capture.device.names'): param = prop.split('=', 1) @@ -42,19 +42,19 @@ def get_input_params(event): def trackinput_selected(event, flavor, track): - ''' check if input corresponding to flavor is selected in schedule-attachment - parameter 'capture.device.names' - returns True if input is selected or if capture.device.names='' - ''' + ''' check if input corresponding to flavor is selected in + schedule-attachment parameter 'capture.device.names' + returns True if input is selected or if capture.device.names='' + ''' # inputs from pyca.conf inputs_conf = config('agent', 'inputs') - + # if no inputs defined, return True -> add all tracks to mediapackage if (inputs_conf == ['']): logger.info('No inputs in config defined') return True - + # flavors from pyca.conf flavors_conf = config('capture', 'flavors') @@ -66,14 +66,14 @@ def trackinput_selected(event, flavor, track): logger.info('No inputs in schedule') # print('No inputs in event attachment') return True - + # Input corresponding to track-flavor from pyca.conf input_track = inputs_conf[flavors_conf.index(flavor)] if input_track in inputs_event: # Input corresponding to flavor is selected in attachment return True - + # Input corresponding to flavor is not selected in attachment return False @@ -192,8 +192,8 @@ def control_loop(): '''Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry. ''' - set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE, - force_update=True) + set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE, + force_update=True) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): From d18cffff66f479ff045ffa6d51c57aac1af3b6ff Mon Sep 17 00:00:00 2001 From: RolfBerger <111289977+RolfBerger@users.noreply.github.com> Date: Thu, 18 Aug 2022 11:11:03 +0200 Subject: [PATCH 15/15] Update README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 525ff934..e881504e 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,3 @@ -PyCA – Opencast Capture Agent -============================= fork with following changes: - capture.py will not start capturing if connection to opencast endpoint is not possible. The original function service() will endless stay in a while-loop with 5sec sleep until endpoint is connected. Events in the database will not start recording. To change this, the already installed flag 'force_update' is used. The while-loop will only wait and loop if force_update=True and return immediately if force_update=False. force_update is passed through the calling functions register_ca(), recording_state(), set_service_status_immediate(), update_agent_state() @@ -21,6 +19,8 @@ fork with following changes: :target: https://github.com/opencast/pyCA/blob/master/license.lgpl :alt: LGPL-3 license +PyCA – Opencast Capture Agent +============================= **PyCA** is a fully functional Opencast_ capture agent written in Python. It is free software licensed under the terms of the `GNU Lesser General Public License`_.