def draw(self, shape_name=None): if self.label: self.draw_label() if isinstance(self, Patch) or shape_name in SHAPES: self.rect.center = self.center_pixel # self.rect = Rect(center=self.rect.center) gui.blit(self.image, self.rect) else: gui.draw(self, shape_name=shape_name)
async def main(): setup_loggers() user_arguments = create_parser_for_user_arguments() history_log_path = user_arguments.history or os.getenv('HISTORY_LOG_DIR_PATH', f'{os.getcwd()}') if not os.path.exists(history_log_path): logging.error(f'history log path does not exist {history_log_path}') sys.exit(2) token_file_path = user_arguments.token_file_path or os.getenv('TOKEN_FILE_PATH') if user_arguments.token_file_path and not os.path.exists(user_arguments.token_file_path): logging.error(f'token file path does not exist {user_arguments.token_file_path}') sys.exit(2) elif user_arguments.token_file_path: token_file_path = user_arguments.token_file_path token_from_file = await get_token_from_file(token_file_path) host = user_arguments.host or os.getenv('HOST', 'minechat.dvmn.org') read_port = user_arguments.read_port or os.getenv('READ_PORT', 5000) send_port = user_arguments.send_port or os.getenv('SEND_PORT', 5050) attempts = int(user_arguments.attempts or os.getenv('ATTEMPTS_COUNT', 3)) token = user_arguments.token or os.getenv('TOKEN') or token_from_file messages_queue = asyncio.Queue() sending_queue = asyncio.Queue() status_updates_queue = asyncio.Queue() history_queue = asyncio.Queue() watchdog_queue = asyncio.Queue() if os.path.exists(f'{history_log_path}/history_logs.txt'): with open(f'{history_log_path}/history_logs.txt') as log_file: messages_queue.put_nowait(log_file.read()) async with create_handy_nursery() as nursery: nursery.start_soon( gui.draw(messages_queue, sending_queue, status_updates_queue) ) nursery.start_soon( handle_connection(host, read_port, send_port, messages_queue, history_queue, watchdog_queue, sending_queue, status_updates_queue, token, attempts, history_log_path) )