def find_platforms(root_dir: str) -> List[Platform]: platforms: List[Platform] = [] all_unsupported_elems: Set[str] = set() theme_xmls = find_theme_xmls(root_dir) for platform_name, xml_path in theme_xmls.items(): print_info(f"Processing platform `{platform_name}` (`{xml_path}`)") try: variables: Dict[str, str] = {} views: Dict[str, Dict[str, Element]] = create_default_views(root_dir) unsupported_elems = read_theme_xml(root_dir, xml_path, variables, views) except RuntimeError as err: print_error(err) warn(f"Platform `{platform_name}` skipped") continue platforms.append(Platform(platform_name, views)) all_unsupported_elems.update(unsupported_elems) if all_unsupported_elems: warn( "The following unknown or unsupported items were found in this theme:" ) for elem in all_unsupported_elems: warn(f" - {elem}") return platforms
def main(): args = parse_args() theme_name = os.path.basename(os.path.abspath(args.INPUTDIR)) platforms = find_platforms(args.INPUTDIR) default_views = create_default_views(args.INPUTDIR) out_files = create_qml(theme_name, platforms, default_views) if args.OUTPUTDIR: print_info("Writing files...") dump_files(out_files, args.OUTPUTDIR) copy_resources(args.OUTPUTDIR)
def __init_socket_connection(self): '''Init rc module socket connection''' # Loop until socket is connected # connect_ex returns 0 if connection was succesful while self.vlc_socket.connect_ex( (self.SOCKET_HOST, self.SOCKET_PORT)) != 0: time.sleep(0.1) errors.print_info("Vlc player started!") # Set socket time out so it waits a while to make sure data is written to buffer # This also prevents reading from buffer from blocking self.vlc_socket.settimeout(self.SOCKET_TIMEOUT) # When rc module starts, it writes data to socket buffer that we don't # want to read later self.__empty_reader_buffer()
def has_structural_similarity(ui_platforms): if not ui_platforms: return True for system in ui_platforms: for viewtype, elems in system['views'].items(): if viewtype not in ui_platforms[0]['views']: print_info( f"{system['name']}: {viewtype} not in {ui_platforms[0]['views'].keys()}" ) return False if len(elems) != len(ui_platforms[0]['views'][viewtype]): print_info( f"{system['name']}: {len(elems)} != {len(ui_platforms[0]['views'][viewtype])}" ) return False for idx, _ in enumerate(elems): if elems[idx]['type'] != ui_platforms[0]['views'][viewtype][ idx]['type']: print_info( f"{system['name']}: at idx {idx} {elems[idx]['type']} != {ui_platforms[0]['views'][viewtype][idx]['type']}" ) return False return True
''' Main ''' import os import signal import threading #import sys import json #import time from autobahn.twisted.websocket import WebSocketServerProtocol, \ WebSocketServerFactory #from twisted.python import log from twisted.internet import reactor import errors errors.print_info("Server starting... ") from libs import CRYPTO_CONFIG, GENERAL_CONFIG, WEBSOCKET_CONFIG import libs.crypto import libs.deviceinfo # Set display envrion so interfaces have the right DISPLAY if GENERAL_CONFIG and 'display' in GENERAL_CONFIG: os.environ['DISPLAY'] = GENERAL_CONFIG['display'] # interfaces should be only imported in contoller.py import interface import interface.audio import interface.browser import interface.config import interface.general
def print_systems(ui_platforms): for system in ui_platforms: print_info("Platform: " + system['name']) if system['variables']: print_info("Variables:") for k, v in system['variables'].items(): print_info(f" - {k}: {v}") if system['views']: print_info("Views:") for viewtype, elems in system['views'].items(): print_info(f" - {viewtype}: {len(elems)} elem") for elem in elems: print_info( f" - {elem['type']} {elem['name']} extra:{elem['is_extra']}" ) for prop in elem['params']: print_info(f" - {prop}: {elem['params'][prop]}") break