-
Notifications
You must be signed in to change notification settings - Fork 31
Adhoc enqueue params #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Adhoc enqueue params #579
Changes from all commits
581baf4
b98983a
d45666a
5128c68
39697ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,17 +19,22 @@ | |
| the Element superclass. | ||
| """ | ||
|
|
||
| import json | ||
| import uuid | ||
| import time | ||
| import os | ||
| from os import path | ||
| from datetime import datetime | ||
| from xml.dom import minidom | ||
|
|
||
| from galicaster.core import context | ||
| from galicaster.mediapackage.utils import _checknget, read_ini | ||
|
|
||
| from galicaster.utils.mediainfo import get_duration | ||
| from galicaster.utils.i18n import _ | ||
|
|
||
| logger = context.get_logger() | ||
|
|
||
| # Mediapackage Status | ||
| NEW = 0 | ||
| UNSCHEDULED = 1 | ||
|
|
@@ -1520,26 +1525,39 @@ def getOCCaptureAgentProperties(self): | |
|
|
||
| def setProperty(self, prop=None, value=None): | ||
| """Sets the value of a property in the mediapackage. | ||
| The enqueue_params property will be JSON serialized. | ||
| Args: | ||
| prop (str): the name of the property. | ||
| value (str): the new value of the property name. | ||
| value (str): the new value of the property. | ||
| """ | ||
| if not prop or value is None: | ||
| return None | ||
| else: | ||
| self.properties[prop] = value | ||
| return True | ||
| property_value = value | ||
| if prop == "enqueue_params": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To allow for this kind of API: Also, this support should be added generically, not just for an "enqueue_params" property. Essentially, to add this functionality what we should do is to support dictionary properties, at least. And serialize/deserialize them on the corresponding classes. The setProperty function should not be the one carrying this logic
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @Alfro, I agree but went with the minimal changes to provide this functionality for |
||
| try: | ||
| property_value = json.dumps(value) | ||
| except Exception: | ||
| logger.warn('Unable to serialize property {} of media package {}'.format(prop, self.getIdentifier())) | ||
| return False | ||
| self.properties[prop] = property_value | ||
| return True | ||
|
|
||
|
|
||
| def getProperty(self, prop=None): | ||
| """Gets the property specified of the mediapackage. | ||
| When specifying the enqueue_params property the object returned will be | ||
| the result of JSON deserialization. | ||
| See https://docs.python.org/2/library/json.html#encoders-and-decoders | ||
| Returns: | ||
| Obj: the object with the value of the property specified | ||
| """ | ||
| if not prop: | ||
| return None | ||
| else: | ||
| if prop in self.properties: | ||
| return self.properties[prop] | ||
| else: | ||
| if prop and prop in self.properties: | ||
| property_string = self.properties[prop] | ||
| if prop == "enqueue_params": | ||
| try: | ||
| return json.loads(property_string) | ||
| except Exception: | ||
| logger.warn('Unable to deserialize property {} of media package {}'.format(prop, self.getIdentifier())) | ||
| return None | ||
| return property_string | ||
| return None | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is a good way to simplify the conditionals here as you can't have
workflowwithoutworkflow_parametersi believe