Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 80755c8

Browse files
authored
New template (#21)
* add get_input_device_by_id method and delete useless template * fix avaliability problem * fix method name * fix test and lint * fix preview exception raising logic * add data file to package * add new param to template * remove 'sourceType' param in 'generate_preview' method * update version
1 parent 393635f commit 80755c8

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

elemental/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_input_device_by_id(self, input_device_id):
185185
device_info.pop('@href')
186186
return dict(device_info)
187187

188-
def generate_preview(self, source_type, input_id):
188+
def generate_preview(self, input_id):
189189
url = f'{self.server_ip}/inputs/generate_preview'
190190
headers = self.generate_headers(url)
191191

@@ -195,7 +195,7 @@ def generate_preview(self, source_type, input_id):
195195

196196
# generate body
197197
data = f"input_key=0&live_event[inputs_attributes][0][source_type]=" \
198-
f"{source_type}&live_event[inputs_attributes][0]" \
198+
f"DeviceInput&live_event[inputs_attributes][0]" \
199199
f"[device_input_attributes][sdi_settings_attributes]" \
200200
f"[input_format]=Auto&live_event[inputs_attributes][0]" \
201201
f"[device_input_attributes][device_id]={input_id}"
@@ -204,7 +204,7 @@ def generate_preview(self, source_type, input_id):
204204

205205
response_parse = ast.literal_eval(response.text)
206206

207-
if 'preview_image_id' not in response_parse:
207+
if 'type' in response_parse and response_parse['type'] == 'error':
208208
raise ElementalException(
209209
f"Response: {response.status_code}\n{response.text}")
210210
else:

elemental/client_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,17 @@ def test_create_event_should_call_send_request_as_expect_and_return_event_id():
141141
'mediastore_container_backup':
142142
'https://hu5n3jjiyi2jev.data.medias'
143143
'tore.us-east-1.amazonaws.com/backup',
144-
'channel': "1", 'device_name': "0"})
144+
'input_device': {'id': '1',
145+
'name': None,
146+
'device_name': 'HD-SDI 1',
147+
'device_number': '0',
148+
'device_type': 'AJA',
149+
'description':
150+
'AJA Capture Card',
151+
'channel': '1',
152+
'channel_type': 'HD-SDI',
153+
'quad': 'false',
154+
'availability': False}})
145155

146156
response_from_elemental_api = client.send_request.call_args_list[0][1]
147157
assert response_from_elemental_api['http_method'] == 'POST'
@@ -347,7 +357,7 @@ def test_get_preview_will_parse_response_json_as_expect():
347357
status=200, text=file_fixture(
348358
'success_response_for_generate_preview.json'))
349359

350-
response = client.generate_preview('DeviceInput', '2')
360+
response = client.generate_preview('2')
351361

352362
assert response == {
353363
'preview_url': f'{ELEMENTAL_ADDRESS}/'
@@ -367,7 +377,7 @@ def test_get_preview_will_raise_ElementalException_if_preview_unavaliable():
367377
"Device already in use."}))
368378

369379
with pytest.raises(ElementalException) as exc_info:
370-
client.generate_preview('DeviceInput', '1')
380+
client.generate_preview('1')
371381

372382
respond_text = json.dumps({'type': 'error',
373383
'message': 'Input is invalid. '

elemental/templates/qvbr_mediastore.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<live_event href="/live_events/3" product="Elemental Live + HEVC Package" version="2.14.4.308149">
3-
<name>SuperBowl AVC Live (FLL - Dev)</name>
3+
<name>{{channel_name}}</name>
44
<input>
55
<deblock_selected>true</deblock_selected>
66
<denoise_selected>false</denoise_selected>
@@ -18,11 +18,11 @@
1818
<service_provider_name nil="true"/>
1919
<timecode_source>embedded</timecode_source>
2020
<device_input>
21-
<device_type>AJA</device_type>
22-
<device_number>{{ device_number }}</device_number>
23-
<channel>{{ channel }}</channel>
24-
<channel_type>HD-SDI</channel_type>
25-
<device_name>HD-SDI 1</device_name>
21+
<device_type>{{ input_device["device_type"] }}</device_type>
22+
<device_number>{{ input_device["device_number"] }}</device_number>
23+
<channel>{{ input_device["channel"] }}</channel>
24+
<channel_type>{{ input_device["channel_type"] }}</channel_type>
25+
<device_name>{{ input_device["device_name"] }}</device_name>
2626
<name nil="true"/>
2727
<sdi_settings>
2828
<input_format>Auto</input_format>
@@ -835,7 +835,7 @@
835835
<destination>
836836
<password>{{ password }}</password>
837837
<username>{{ username }}</username>
838-
<uri>{{ mediastore_container_master}}</uri>
838+
<uri>{{ mediastore_container_master }}</uri>
839839
</destination>
840840
</apple_live_group_settings>
841841
<type>apple_live_group_settings</type>

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
name='python-elemental',
88
author='CBS Interactive',
99
author_email='[email protected]',
10-
version='0.2',
10+
version='0.4',
1111
include_patckage_data=True,
1212
url='https://github.com/cbsinteractive/elemental.git',
1313
license='MIT',
1414
long_description=open('README.md').read(),
1515
install_requires=requirements,
1616
packages=setuptools.find_packages(),
17+
package_data={'elemental': ['templates/*']}
1718
)

0 commit comments

Comments
 (0)