Cleanup and add defaults

This commit is contained in:
Tim 2022-02-12 17:02:13 +00:00
parent 87a05a947c
commit 2a897edb10
No known key found for this signature in database
GPG Key ID: E95CE08DB3F50537
4 changed files with 17 additions and 10 deletions

View File

@ -1,3 +1,6 @@
python3-colorama==0.4.3
websocket-client==0.57.0
websocket-client~=1.2.3
zeroconf~=0.36.9
colorama~=0.4.4
PyYAML~=3.13
requests~=2.27.0

View File

@ -69,7 +69,7 @@ class RunTestsController(object):
if not conn_timeout:
print_error("Could not connect to WS! Exiting.")
def on_message(self, message: str) -> None:
def on_message(self, ws_obj: object, message: str) -> None:
if self.debug:
print_debug(f"Message returned: {message}")
if not self.received:
@ -78,15 +78,15 @@ class RunTestsController(object):
self.ws_data.append(message)
@staticmethod
def on_open() -> None:
print_info("Socket Listener Opened")
def on_open(ws_obj: object) -> None:
print_info(f"Socket Listener Opened")
@staticmethod
def on_close() -> None:
print_info("Socket Listener Closed")
@staticmethod
def on_error(error: str) -> None:
def on_error(ws_obj: object, error: str) -> None:
print_error(f'WebSocket Error: {error}')
def load_and_check_sockets(self, first_run: bool = False) -> bool:
@ -117,8 +117,9 @@ class RunTestsController(object):
parser.add_argument('rargs', nargs='*', default=[])
a = parser.parse_args()
f_open = f'{a.rargs[0]}'
print(f_open)
with open(f_open, 'r') as file:
commands = yaml.load(file, Loader=yaml.FullLoader)
commands = yaml.load(file, Loader=yaml.SafeLoader)
for step in commands:
if step == 'process_name':
print_info(f'Processing file {commands[step]}')

View File

@ -36,7 +36,7 @@ def check_for_openlp(type: str) -> str:
def add_service(self, zeroconf: Zeroconf, type: str, name: str):
info = zeroconf.get_service_info(type, name)
# print_info(f'Service {name} added, service info: {info}')
print_info(f'Service {name} added, service info: {info}')
if info.name.startswith("OpenLP"):
print_info(f'Service {name} found')
self.port = str(info.port)

View File

@ -31,11 +31,14 @@ def start() -> None:
print_text('Check OpenLP is running')
op_address, op_http_port = check_for_openlp('http')
if not op_http_port:
print_error('OpenLP is not running - aborting')
return
print_error('OpenLP is not found - defaulting to 4316')
op_http_port = 4316
else:
print_ok(f'OpenLP is running on port (http) {op_http_port}')
_, op_ws_port = check_for_openlp('ws')
if not op_ws_port:
print_error('OpenLP is not found - defaulting to 4317')
op_ws_port = 4317
print_ok(f'OpenLP is running network Address {op_address}')
print_ok(f'OpenLP is running on port (ws) {op_ws_port}')
rtc = RunTestsController(op_address, op_http_port, op_ws_port)