def update_prefs(self): executable = self.ui.executable_lineEdit.text() scripts_path = self.ui.additionnal_textEdit.toPlainText() env_paths = self.ui.env_textEdit.toPlainText() software = self.ui.setup_softwares_comboBox.currentText() if executable.endswith('"'): executable = executable[:-1] if executable.startswith('"'): executable = executable[1:] software_prefs.software(software).init_settings( executable, env_paths, scripts_path)
def get_env(software, level=0): env = os.environ.copy() if level == 0: env_path = os.path.abspath('softwares_env') python_path = os.path.abspath( 'ressources\\python27\\Lib\\site-packages') elif level == 1: env_path = os.path.abspath('') python_path = os.path.abspath( '..\\ressources\\python27\\Lib\\site-packages') script_path = os.path.join(env_path, 'softwares') env[defaults._script_software_env_dic_[software]] = script_path env[defaults._script_software_env_dic_[software]] += os.pathsep + env_path env[defaults. _script_software_env_dic_[software]] += os.pathsep + python_path env['PATH'] = '' env_paths = software_prefs.software(software).get_env_paths() if env_paths: for user_env in env_paths.splitlines(): user_env.replace(' ', '') if '=' in user_env: key = user_env.split('=')[0] path = user_env.split('=')[-1] env[key] = path else: pass return env
def refresh_ui(self): self.update_launch_button() software = self.ui.setup_softwares_comboBox.currentText() executable = software_prefs.software(software).get_path() command = softwares._cmd_dic_[software] env = software_prefs.software(software).get_env() env_paths = software_prefs.software(software).get_env_paths() if executable: self.ui.executable_lineEdit.setText(executable) else: self.ui.executable_lineEdit.clear() self.ui.command_lineEdit.setText(command) if env: self.ui.additionnal_textEdit.setText(env) else: self.ui.additionnal_textEdit.clear() if env_paths: self.ui.env_textEdit.setText(env_paths) else: self.ui.env_textEdit.clear()
def run(self): lock = prefs.asset(self.asset).software.get_lock if not lock or lock == prefs.user: logger.info('Launching {}...'.format(self.asset.software)) #prefs.asset(self.asset).software.set_running(0) os.environ[ defaults. _current_assets_list_] += ':' + utils.short_asset_to_string( self.asset) wizard_path = os.path.abspath('') python_path = os.path.abspath('ressources\\python27') python37_path = os.path.abspath('ressources\\python37') ocio_path = os.path.abspath( 'ressources\\plugins\\color_managment\\aces_1.0.3\\config.ocio' ) rel_site_script_path = os.path.join( defaults._softwares_scripts_path_) abs_site_script_path = os.path.abspath(rel_site_script_path) env = os.environ.copy() if self.asset.software != defaults._guerilla_ and self.asset.software != defaults._designer_: env[defaults._script_software_env_dic_[ self.asset.software]] = abs_site_script_path env[defaults._script_software_env_dic_[ self.asset. software]] += os.pathsep + wizard_path + '\\softwares_env' env[defaults._script_software_env_dic_[ self.asset. software]] += os.pathsep + python_path + '\\Lib\\site-packages' if self.asset.software == defaults._houdini_ or self.asset.software == defaults._nuke_: env[defaults._script_software_env_dic_[ self.asset.software]] = wizard_path + '\\softwares_env' env[defaults._script_software_env_dic_[ self.asset. software]] += os.pathsep + python_path + '\\Lib\\site-packages' ''' if self.asset.software == defaults._houdini_: env[defaults._script_software_env_dic_[self.asset.software]] += os.pathsep + wizard_path + '\\softwares_env\\softwares\\houdini_wizard' ''' env_paths = software_prefs.software( self.asset.software).get_env_paths() scripts_paths = software_prefs.software( self.asset.software).get_env() if scripts_paths: for path in scripts_paths.splitlines(): env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + path if env_paths: for user_env in env_paths.splitlines(): user_env.replace(' ', '') if '=' in user_env: key = user_env.split('=')[0] path = user_env.split('=')[-1] if key in env.keys(): env[key] += os.pathsep + path else: env[key] = path else: pass if self.asset.software == defaults._maya_ or self.asset.software == defaults._maya_yeti_: if defaults._maya_icon_path_ in env.keys(): env[defaults. _maya_icon_path_] += os.pathsep + os.path.abspath( defaults._icon_path_) else: env[defaults._maya_icon_path_] = os.path.abspath( defaults._icon_path_) if self.asset.software == defaults._nuke_: env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + abs_site_script_path env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + os.path.join( abs_site_script_path, 'nuke_wizard') env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + os.path.abspath( defaults._icon_path_) if self.asset.software == defaults._painter_: env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + os.path.join( abs_site_script_path, 'painter_wizard') if self.asset.software == defaults._designer_: env[defaults._script_software_env_dic_[ self.asset. software]] = os.pathsep + python37_path + '\\Lib\\site-packages' env[defaults._script_software_env_dic_[ self.asset. software]] += os.pathsep + wizard_path + '\\softwares_env' env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + os.path.join( abs_site_script_path, 'designer_wizard') if self.asset.software == defaults._blender_: env[defaults._script_software_env_dic_[ self.asset. software]] = os.pathsep + python37_path + '\\Lib\\site-packages' env[defaults._script_software_env_dic_[ self.asset. software]] += os.pathsep + wizard_path + '\\softwares_env' env[defaults._script_software_env_dic_[ self.asset.software]] += os.pathsep + os.path.join( abs_site_script_path, 'blender_wizard') env[defaults._site_var_] = os.environ[defaults._site_var_] env[defaults._asset_var_] = utils.asset_to_string(self.asset) self.command = self.command.replace('\\', '/') logger.info(self.command) if self.asset.software == defaults._painter_ or self.asset.software == defaults._nuke_: self.process = subprocess.Popen(self.command, env=env, cwd=wizard_path + '\\softwares_env') elif self.asset.software == defaults._houdini_: self.process = subprocess.Popen( self.command, env=env, cwd=wizard_path + '\\softwares_env\\softwares\\houdini_wizard') else: self.process = subprocess.Popen(self.command, env=env) self.process.wait() self.earThread.observer.stop() self.earThread.observer.join() string_asset = utils.short_asset_to_string(self.asset) running_assets_list = os.environ[ defaults._current_assets_list_].split(':') if string_asset in running_assets_list: running_assets_list.remove(string_asset) running_assets_list_string = (':').join(running_assets_list) os.environ[defaults. _current_assets_list_] = running_assets_list_string send_signal.refresh_launcher_signal() logger.info('{} closed'.format(self.software)) else: message = '{} - '.format(self.asset.category) message += '{} - '.format(self.asset.name) message += '{} - '.format(self.asset.stage) message += '{} - '.format(self.asset.variant) message += '{} '.format(self.asset.software) message += 'is locked by {}...'.format( prefs.asset(self.asset).software.get_lock) logger.warning(message)
def settings_path(self): return software_prefs.software(self.software).get_settings_path()
def env(self): return software_prefs.software(self.software).get_env()
def path(self): return software_prefs.software(self.software).get_path()