def modules(): import importlib exists = importlib.util.find_spec serpent_modules = { "OCR": (exists("tesserocr") or exists("pytesseract")) is not None, "GUI": exists("kivy") is not None, "ML": exists("keras") is not None and exists("tensorforce") is not None } clear_terminal() display_serpent_logo() print("") print("Installed Serpent.AI Modules:") print("") print( f"OCR => {'Yes' if serpent_modules['OCR'] else 'No; Install with `serpent setup ocr` if needed'}" ) print( f"GUI => {'Yes' if serpent_modules['GUI'] else 'No; Install with `serpent setup gui` if needed'}" ) print( f"ML => {'Yes' if serpent_modules['ML'] else 'No; Install with `serpent setup ml` if needed'}" ) print("")
def setup(module=None): clear_terminal() display_serpent_logo() print("") if module is None: setup_base() elif module == "ocr": setup_ocr() elif module == "gui": setup_gui() elif module == "ml": setup_ml() else: print(f"Invalid Setup Module: {module}")
def generate_game_agent_plugin(): clear_terminal() display_serpent_logo() print("") game_agent_name = input( "What is the name of the game agent? (Titleized, No Spaces i.e. AwesomeGameAgent): \n" ) if game_agent_name in [None, ""]: raise Exception("Invalid game agent name.") prepare_game_agent_plugin(game_agent_name) subprocess.call( shlex.split( f"serpent activate Serpent{game_agent_name}GameAgentPlugin"))
def update(): clear_terminal() display_serpent_logo() print("") print("Updating Serpent.AI to the latest version...") subprocess.call(shlex.split("pip install --upgrade SerpentAI")) if is_linux(): shutil.copy( os.path.join(os.path.dirname(__file__), "requirements.linux.txt"), os.path.join(os.getcwd(), "requirements.txt")) elif is_macos(): shutil.copy( os.path.join(os.path.dirname(__file__), "requirements.darwin.txt"), os.path.join(os.getcwd(), "requirements.txt")) elif is_windows(): shutil.copy( os.path.join(os.path.dirname(__file__), "requirements.win32.txt"), os.path.join(os.getcwd(), "requirements.txt")) subprocess.call(shlex.split("pip install -r requirements.txt")) import yaml with open(os.path.join(os.path.dirname(__file__), "config", "config.yml"), "r") as f: serpent_config = yaml.safe_load(f) or {} with open(os.path.join(os.getcwd(), "config", "config.yml"), "r") as f: user_config = yaml.safe_load(f) or {} config_changed = False for key, value in serpent_config.items(): if key not in user_config: user_config[key] = value config_changed = True if config_changed: with open(os.path.join(os.getcwd(), "config", "config.yml"), "w") as f: f.write(yaml.dump(user_config))
def generate_game_plugin(): clear_terminal() display_serpent_logo() print("") game_name = input( "What is the name of the game? (Titleized, No Spaces i.e. AwesomeGame): \n" ) game_platform = input( "How is the game launched? (One of: 'steam', 'executable', 'web_browser'): \n" ) if game_name in [None, ""]: raise Exception("Invalid game name.") if game_platform not in ["steam", "executable", "web_browser"]: raise Exception("Invalid game platform.") prepare_game_plugin(game_name, game_platform) subprocess.call( shlex.split(f"serpent activate Serpent{game_name}GamePlugin"))