Add Active tag and zeroconv handler.

This commit is contained in:
Tim 2022-02-19 08:15:40 +00:00
parent a5be688755
commit 674ae581ce
No known key found for this signature in database
GPG Key ID: E95CE08DB3F50537
21 changed files with 329 additions and 258 deletions

View File

@ -1,17 +1,13 @@
{ {
"process_name": "Show basic alert process", "process_name": "Show basic alert process",
"step1": { "step1": {"active": true,
"name": "trigger_alert", "name": "trigger_alert",
"payload": { "min": 0,
"text": "Some Text", "payload": { "text": "Some Text" }
"min": 0
}
}, },
"step2": { "step2": {"active": true,
"name": "trigger_alert", "name": "trigger_alert",
"payload": { "delay": 5,
"text": "Some more text Text", "payload": { "text": "Some more text Text" }
"delay": 5
}
} }
} }

35
scripts/blank.json Normal file
View File

@ -0,0 +1,35 @@
{
"process_name": "Test Display hiding",
"step1": {"active": true,
"name": "display_hide",
"delay": 1
},
"step2": {"active": true,
"name": "display_show",
"delay": 1
},
"step3": {"active": true,
"name": "display_blank",
"delay": 1
},
"step4": {"active": true,
"name": "display_show",
"delay": 1
},
"step5": {"active": true,
"name": "display_theme",
"delay": 1
},
"step6": {"active": true,
"name": "display_show",
"delay": 1
},
"step7": {"active": true,
"name": "display_desktop",
"delay": 1
},
"step8": {"active": true,
"name": "display_show",
"delay": 1
}
}

View File

@ -1,26 +0,0 @@
---
process_name: Test Display hiding
step1:
delay: 1
name: display_hide
step2:
delay: 1
name: display_show
step3:
delay: 1
name: display_blank
step4:
delay: 1
name: display_show
step5:
delay: 1
name: display_theme
step6:
delay: 1
name: display_show
step7:
delay: 1
name: display_desktop
step8:
delay: 1
name: display_show

104
scripts/full_run_rand.json Normal file
View File

@ -0,0 +1,104 @@
{
"process_name": "Test Process Service Random",
"step1": {"active": true,
"name": "clear_live_controller",
"max": 1,
"min": 1
},
"step2": {"active": true,
"name": "clear_preview_controller",
"delay": 1
},
"step3": {"active": true,
"name": "new_service",
"max": 1,
"min": 1
},
"step4": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step5": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step6": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step7": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {"active": true,
"plugin": "custom"
}
},
"step8": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "images"
}
},
"step9": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step10": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step11": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step12": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step13": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "custom"
}
},
"step14": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step15": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step16": {"active": true,
"name": "load_service_random"
}
}

View File

@ -1,85 +0,0 @@
---
process_name: test process
step1:
max: 1
min: 1
name: clear_live_controller
step2:
delay: 1
name: clear_preview_controller
step3:
max: 1
min: 1
name: new_service
step4:
delay: 1
name: search_and_add
payload:
plugin: songs
step5:
delay: 1
name: search_and_add
payload:
plugin: songs
step6:
delay: 1
name: search_and_add
payload:
plugin: bibles
step7:
delay: 1
name: search_and_add
payload:
plugin: bibles
step8:
delay: 1
name: search_and_add
payload:
plugin: custom
step9:
delay: 1
name: search_and_add
payload:
plugin: images
step10:
delay: 1
name: search_and_add
payload:
plugin: songs
step11:
delay: 1
name: search_and_add
payload:
plugin: presentation
step12:
delay: 1
name: search_and_add
payload:
plugin: bibles
step13:
delay: 1
name: search_and_add
payload:
plugin: bibles
step14:
delay: 1
name: search_and_add
payload:
plugin: songs
step15:
delay: 1
name: search_and_add
payload:
plugin: custom
step16:
delay: 1
name: search_and_add
payload:
plugin: bibles
step17:
delay: 1
name: search_and_add
payload:
plugin: bibles
step18:
name: load_service_random

104
scripts/full_run_seq.json Normal file
View File

@ -0,0 +1,104 @@
{
"process_name": "Test Process Service Sequential",
"step1": {"active": true,
"name": "clear_live_controller",
"max": 1,
"min": 1
},
"step2": {"active": true,
"name": "clear_preview_controller",
"delay": 1
},
"step3": {"active": true,
"name": "new_service",
"max": 1,
"min": 1
},
"step4": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step5": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step6": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step7": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "custom"
}
},
"step8": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "images"
}
},
"step9": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step10": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step11": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step12": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step13": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "custom"
}
},
"step14": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "bibles"
}
},
"step15": {"active": true,
"name": "search_and_add",
"delay": 1,
"payload": {
"plugin": "songs"
}
},
"step16": {"active": true,
"name": "load_service_sequential"
}
}

View File

@ -1,80 +0,0 @@
---
process_name: test process
step1:
max: 1
min: 1
name: clear_live_controller
step2:
delay: 1
name: clear_preview_controller
step3:
max: 1
min: 1
name: new_service
step4:
delay: 1
name: search_and_add
payload:
plugin: songs
step5:
delay: 1
name: search_and_add
payload:
plugin: songs
step6:
delay: 1
name: search_and_add
payload:
plugin: bibles
step7:
delay: 1
name: search_and_add
payload:
plugin: bibles
step8:
delay: 1
name: search_and_add
payload:
plugin: custom
step9:
delay: 1
name: search_and_add
payload:
plugin: images
step10:
delay: 1
name: search_and_add
payload:
plugin: songs
step12:
delay: 1
name: search_and_add
payload:
plugin: bibles
step13:
delay: 1
name: search_and_add
payload:
plugin: bibles
step14:
delay: 1
name: search_and_add
payload:
plugin: songs
step15:
delay: 1
name: search_and_add
payload:
plugin: custom
step16:
delay: 1
name: search_and_add
payload:
plugin: bibles
step17:
delay: 1
name: search_and_add
payload:
plugin: bibles
step18:
name: load_service_sequential

View File

@ -1,6 +1,6 @@
{ {
"process_name": "live_item", "process_name": "live_item",
"step1": { "step1": {"active": true,
"name": "play_live_items" "name": "play_live_items"
} }
} }

View File

@ -1,33 +1,29 @@
{ {
"process_name": "play media", "process_name": "play media",
"step1": { "step1": {"active": true,
"name": "clear_live_controller", "name": "clear_live_controller",
"payload": {
"max": 1, "max": 1,
"min": 1 "min": 1
}
}, },
"step2": { "step2": {"active": true,
"name": "clear_preview_controller", "name": "clear_preview_controller",
"payload": {
"delay": 1 "delay": 1
}
}, },
"step3": { "step3": {"active": true,
"name": "search_and_add", "name": "search_and_add",
"delay": 10 "delay": 10,
"payload": { "payload": {
"plugin": "media" "plugin": "media"
} }
}, },
"step4": { "step4": {"active": true,
"name": "load_service_sequential" "name": "load_service_sequential"
}, },
"step5": { "step5": {"active": true,
"name": "flush_pending",
"delay": 30 "delay": 30
"name": "flush_pending"
}, },
"step6": { "step6": {"active": true,
"name": "media_pause" "name": "media_pause"
} }
} }

6
scripts/pause.json Normal file
View File

@ -0,0 +1,6 @@
{
"process_name": "Pause Media",
"step1": {"active": true,
"name": "media_pause",
}
}

View File

@ -1,4 +0,0 @@
---
process_name: Pause Media
step1:
name: media_pause

6
scripts/play.json Normal file
View File

@ -0,0 +1,6 @@
{
"process_name": "Play Media",
"step1": {"active": true,
"name": "media_play",
}
}

View File

@ -1,4 +0,0 @@
---
process_name: Play Media
step1:
name: media_play

6
scripts/stop.json Normal file
View File

@ -0,0 +1,6 @@
{
"process_name": "Stop Media",
"step1": {"active": true,
"name": "media_stop",
}
}

View File

@ -1,4 +0,0 @@
---
process_name: Stop Media
step1:
name: media_stop

View File

@ -1,34 +1,32 @@
{ {
"process_name": "play media", "process_name": "play media",
"step1": { "step1": {"active": true,
"name": "clear_live_controller", "name": "clear_live_controller",
"max": 1, "max": 1,
"min": 1 "min": 1
}, },
"step2": { "step2": {"active": true,
"name": "clear_preview_controller", "name": "clear_preview_controller",
"delay": 1 "delay": 1
}, },
"step3": { "step3": {"active": true,
"name": "new_service", "name": "new_service",
"max": 1, "max": 1,
"min": 1 "min": 1
}, },
"step4": { "step4": {"active": true,
"name": "search_and_add", "name": "search_and_add",
"delay": 1, "delay": 1,
"payload": { "payload": {
"plugin": "songs" "plugin": "songs"
} }
}, },
"step5": { "step5": {"active": true,
"name": "search_and_add", "name": "search_and_add",
"delay": 1, "delay": 1,
"payload": { "payload": {"plugin": "bibles" }
"plugin": "bibles"
}
}, },
"step6": { "step6": {"active": true,
"name": "load_service_sequential" "name": "load_service_sequential"
} }
} }

15
scripts/themes.json Normal file
View File

@ -0,0 +1,15 @@
{
"process_name": "Themes",
"step1": {"active": true,
"name": "set_theme_level",
"payload": { "theme_level": "global" }
},
"step2": {"active": true,
"delay": 2,
"name": "change_default_theme"
},
"step3": {"active": true,
"delay": 2,
"name": "change_default_theme"
}
}

View File

@ -1,4 +0,0 @@
---
process_name: themes
step1:
name: loop_theme_default

View File

@ -226,11 +226,16 @@ def get_live_image(rtc: object) -> None:
assert ret.status_code == 204, ret.status_code assert ret.status_code == 204, ret.status_code
def loop_theme_default(rtc: object) -> None: def change_default_theme(rtc: object) -> None:
print_text('loop_theme_default') print_text('loop_theme_default')
items = get_themes(rtc) items = get_themes(rtc)
for item in json.loads(items.text): default = get_default_theme(rtc)
print(item) first = None
for item in json.loads(items):
if item['name'].replace("\"", "") != default and first is None:
first = item['name']
set_theme(rtc, first)
# items = requests.get(rtc.base_url + 'service/items') # items = requests.get(rtc.base_url + 'service/items')
# service = json.loads(items.text) # service = json.loads(items.text)
# limit = len(service) # limit = len(service)
@ -241,17 +246,18 @@ def loop_theme_default(rtc: object) -> None:
# rtc.pending.append(Task(rtc, pl)) # rtc.pending.append(Task(rtc, pl))
def get_themes(rtc: object) -> str: def get_themes(rtc: object) -> list:
print_text('get_themes') print_text('get_themes')
ret = requests.get(rtc.base_url + 'controller/themes') ret = requests.get(rtc.base_url + 'controller/themes')
assert ret.status_code == 200, ret.status_code assert ret.status_code == 200, ret.status_code
return ret.text return ret.text
def get_default_theme(rtc: object) -> None: def get_default_theme(rtc: object) -> str:
print_text('get_default_theme') print_text('get_default_theme')
ret = requests.get(rtc.base_url + 'controller/theme') ret = requests.get(rtc.base_url + 'controller/theme')
assert ret.status_code == 204, ret.status_code assert ret.status_code == 200, ret.status_code
return ret.text.replace("\"", "").replace("\n", "")
def get_themes_name(rtc: object, payload: dict) -> None: def get_themes_name(rtc: object, payload: dict) -> None:
@ -259,6 +265,7 @@ def get_themes_name(rtc: object, payload: dict) -> None:
print_text('get_themes_name') print_text('get_themes_name')
ret = requests.get(rtc.base_url + f'themes/{t_name}') ret = requests.get(rtc.base_url + f'themes/{t_name}')
assert ret.status_code == 204, ret.status_code assert ret.status_code == 204, ret.status_code
return ret.text
def get_live_theme(rtc: object) -> None: def get_live_theme(rtc: object) -> None:
@ -269,21 +276,22 @@ def get_live_theme(rtc: object) -> None:
def get_theme_level(rtc: object) -> None: def get_theme_level(rtc: object) -> None:
print_text('get_theme_level') print_text('get_theme_level')
ret = requests.get(rtc.base_url + 'theme_level') ret = requests.get(rtc.base_url + 'controller/theme')
assert ret.status_code == 204, ret.status_code assert ret.status_code == 200, ret.status_code
return ret.text
def set_theme_level(rtc: object, payload: dict) -> None: def set_theme_level(rtc: object, payload: dict) -> None:
t_level = payload['theme_level'] t_level = payload['theme_level']
print_text('set_theme_level') print_text('set_theme_level')
ret = requests.post(rtc.base_url + 'theme_level', json=dict(level=t_level)) ret = requests.post(rtc.base_url + 'controller/theme-level', json=dict(level=t_level))
assert ret.status_code == 204, ret.status_code assert ret.status_code == 204, ret.status_code
return ret.text
def set_theme(rtc: object, payload: dict) -> None: def set_theme(rtc: object, theme_name: str) -> None:
t_level = payload['theme_level'] print_text('set_theme')
print_text('set_theme_level') ret = requests.post(rtc.base_url + 'controller/theme', json=dict(theme=theme_name))
ret = requests.post(rtc.base_url + 'theme_level', json=dict(level=t_level))
assert ret.status_code == 204, ret.status_code assert ret.status_code == 204, ret.status_code

View File

@ -117,13 +117,13 @@ class RunTestsController(object):
parser.add_argument('rargs', nargs='*', default=[]) parser.add_argument('rargs', nargs='*', default=[])
a = parser.parse_args() a = parser.parse_args()
f_open = f'{a.rargs[0]}' f_open = f'{a.rargs[0]}'
print(f_open)
with open(f_open, 'r') as file: with open(f_open, 'r') as file:
commands = json.load(file) commands = json.load(file)
for step in commands: for step in commands:
if step == 'process_name': if step == 'process_name':
print_info(f'Processing file {commands[step]}') print_info(f'Processing file {commands[step]}')
continue continue
if commands[step]['active'] is True:
self.tasks.append(Task(self, commands[step])) self.tasks.append(Task(self, commands[step]))
self.process_queue() self.process_queue()

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # # along with this program. If not, see <https://www.gnu.org/licenses/>. #
########################################################################## ##########################################################################
import socket import socket
from zeroconf import ServiceBrowser, Zeroconf from zeroconf import ServiceBrowser, Zeroconf, ServiceInfo
from time import sleep from time import sleep
from test_api.apitest.logger import print_info from test_api.apitest.logger import print_info
@ -42,6 +42,10 @@ def check_for_openlp(type: str) -> str:
self.port = str(info.port) self.port = str(info.port)
self.address = socket.inet_ntoa(info.addresses[0]) self.address = socket.inet_ntoa(info.addresses[0])
@staticmethod
def update_service(info: ServiceInfo) -> None:
pass
zeroconf = Zeroconf() zeroconf = Zeroconf()
my_listener = MyListener() my_listener = MyListener()
_ = ServiceBrowser(zeroconf, f'_{type}._tcp.local.', my_listener) _ = ServiceBrowser(zeroconf, f'_{type}._tcp.local.', my_listener)