def create(cls): # Build main menu cls._delete_old() Logger.info("Building {0} menu...".format(cls.MAIN_MENU_LABEL)) pm.menu(cls.MAIN_MENU_ID, label=cls.MAIN_MENU_LABEL, parent=cls.MAIN_WINDOW, tearOff=1) MenuUtil.addMenuItem(cls.MAIN_MENU_ID, divider=1, label="Tools") # Tools MenuUtil.addMenuItem(cls.MAIN_MENU_ID, label="Builder", command=tool_cmds.luna_builder, icon="builder.svg") cls._add_external_tools() # Developer tools cls._add_dev_menu() # Help and config section MenuUtil.addMenuItem(cls.MAIN_MENU_ID, divider=1) MenuUtil.addMenuItem(cls.MAIN_MENU_ID, label="Configuration", command=tool_cmds.luna_configer, icon="config.svg") cls._add_help_menu()
def run_all_tests(): test_suite = unittest.TestLoader().discover(start_dir=directories.TEST_DIR_PATH, pattern="*_test.py") Logger.info("Running {0} tests...".format(test_suite.countTestCases())) test_runner = unittest.TextTestRunner(verbosity=2, resultclass=TestResult) test_runner.failfast = False test_runner.buffer = Config.get(TestVars.buffer_output, default=True) test_runner.run(test_suite)
def add_luna_callbacks(): if Config.get(LunaVars.callback_licence, True): try: callbacks.remove_licence_popup_callback() Logger.info("Added file save licence callback") except RuntimeError: Logger.exception("Failed to add file save licence callback!")
def open_port(lang="python"): port = Config.get(LunaVars.command_port, default=7221) if not pm.commandPort("127.0.0.1:{0}".format(port), n=1, q=1): try: pm.commandPort(name="127.0.0.1:{0}".format(port), stp="python", echoOutput=True) Logger.info("Command port opened: Python - {0}".format(port)) except Exception as e: Logger.exception("Failed to open command port", exc_info=e)
def run(): # Logging Logger.write_to_rotating_file(directories.LOG_FILE, level=30) Logger.info("Logging to file: {0}".format(directories.LOG_FILE)) Logger.info("Current logging level: {0}".format(Logger.get_level(name=1))) # Luna initialization open_port(lang="python") build_luna_menu() build_luna_hud() add_luna_callbacks()
def reload_rig_components(*args): """Reloads all modules located in in Luna_rig.components package""" avoid_reload = set("Luna_rig.core.meta, Luna_rig.core.component") to_reload = set() for mod_name in sys.modules.keys(): if "Luna_rig.components" in mod_name and "pymel" not in mod_name: to_reload.add(mod_name) for mod_name in to_reload.difference(avoid_reload): mod = sys.modules.get(mod_name) if mod: reload(mod) Logger.info("Reloaded {0}".format(mod_name))
def create(cls): hud_instance = None Logger.info("Building {0}...".format(cls.HUD_NAME)) # Delete old cls.remove() hud_instance = pm.headsUpDisplay(cls.HUD_NAME, section=cls.SECTION, block=cls.BLOCK, blockSize=cls.BLOCK_SIZE, labelFontSize=cls.FONT_SIZE, command=cls.getHudText, event=cls.UPDATE_EVENT) Logger.info("Successfully created HUD: {0}".format(cls.HUD_NAME)) return hud_instance
def delete_temp_files(cls): """Delete the temp files in the cache and clear the cache.""" # If we don't want to keep temp files around for debugging purposes, delete them when # all tests in this TestCase have been run if Config.get(TestVars.delete_dirs, True): for d in cls.dirs_created: if os.path.isdir(d): shutil.rmtree(d) Logger.info("Deleted dir: {0}".format(d)) cls.dirs_created = [] if Config.get(TestVars.delete_files, default=True): for f in cls.files_created: if os.path.exists(f): os.remove(f) Logger.info("Deleted temp file: {0}".format(f)) cls.files_created = []
def _add_external_tools(cls): register = fileFn.load_json(directories.EXTERNAL_TOOLS_REGISTER) found = set(register).intersection(set(pm.moduleInfo(lm=1))) if not found: return tools_menu = MenuUtil.addSubMenu(cls.MAIN_MENU_ID, label="External", tear_off=1, icon="") for tool in found: MenuUtil.addMenuItem( tools_menu, label=register[tool].get("label"), command=register[tool].get("command"), icon=register[tool].get("icon"), use_maya_icons=register[tool].get("useMayaIcon")) Logger.info("Added {0} to Luna >> Tools menu".format(tool))
def reset(cls): """ Reset config to default. Copies default config file with normal config name """ shutil.copy2(directories.DEFAULT_CONFIG_PATH, directories.CONFIG_PATH) Logger.info("Luna config reset to default")