def quit_server(addr: Tuple[str, int], loop: asyncio.AbstractEventLoop = None): """Send a command to the server to Quit. Args: addr (tuple): Server IP address loop (asyncio.AbstractEventLoop)[None]: Event loop to run the async command with. """ if loop is None: loop = get_loop() return loop.run_until_complete(quit_server_async(addr))
def request_schedules(addr: Tuple[str, int], print_results: bool = True, loop: asyncio.AbstractEventLoop = None): """Send a command to the server to Update Commands. Args: addr (tuple): Server IP address print_results (bool)[True]: If true print the schedules that were returned. loop (asyncio.AbstractEventLoop)[None]: Event loop to run the async command with. """ if loop is None: loop = get_loop() return loop.run_until_complete( request_schedules_async(addr, print_results=print_results))
def stop_schedule(addr: Tuple[str, int], name: str = '', list_schedules: bool = False, loop: asyncio.AbstractEventLoop = None): """Send a command to the server to stop running a schedule. Args: addr (tuple): Server IP address name (str)['']: Name of the schedule. list_schedules (bool)[False]: If True request and print the schedules that the server is running. loop (asyncio.AbstractEventLoop)[None]: Event loop to run the async command with. """ if loop is None: loop = get_loop() return loop.run_until_complete( stop_schedule_async(addr, name, list_schedules=list_schedules))
def update_server(addr: Tuple[str, int], module_name: str = '', list_schedules: bool = False, loop: asyncio.AbstractEventLoop = None): """Send a command to the server to Update Commands. Args: addr (tuple): Server IP address module_name (str)['']: Module name to import/reload. If blank import/reload all modules. list_schedules (bool)[False]: If True request and print the schedules that the server is running. loop (asyncio.AbstractEventLoop)[None]: Event loop to run the async command with. """ if loop is None: loop = get_loop() return loop.run_until_complete( update_server_async(addr, module_name, list_schedules))
def run_command(addr: Tuple[str, int], callback_name: str = '', *args, loop: asyncio.AbstractEventLoop = None, **kwargs): """Send a command to the server to run a registered callback function with the given arguments. Args: addr (tuple): Server IP address callback_name (str)['']: Name of the registered callback function. *args: Positional arguments for the callback function. **kwargs: Keyword Arguments for the callback function. loop (asyncio.AbstractEventLoop)[None]: Event loop to run the async command with. """ if loop is None: loop = get_loop() return loop.run_until_complete( run_command_async(addr, callback_name, *args, **kwargs))
def loop(self) -> 'asyncio.AbstractEventLoop': if self._loop is not None: return self._loop return get_loop()