def create(self): name = self.ui.script_name_lineEdit.text() script = self.ui.script_editor.text().decode('utf-8') only_subprocess = self.ui.only_subprocess_checkBox.isChecked() project = self.ui.create_script_project_radioButton.isChecked() if name != '': logger.info(user_scripts().get_scripts_as_dic()) is_in_local = name in user_scripts().get_scripts_as_dic()[ defaults._user_scripts_].keys() is_in_project = name in user_scripts().get_project_scripts_as_dic( )[defaults._user_scripts_].keys() if (is_in_project or is_in_project) and not self.edit: logger.warning(f'{name} already exists') else: user_scripts().create_user_script( name, self.icon, script, only_subprocess=only_subprocess, project=project) send_signal.refresh_signal() self.hide() else: logger.warning('Please enter a script name')
def remove_stage(asset): # Creates a new stage with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check if category and name exists # Check if stage doesn't exists if checker.check_category_existence(asset) and \ checker.check_name_existence(asset) and \ checker.check_stage_existence(asset): # Remove the stage from the project dictionnary del project_dic[asset.domain] \ [asset.category] \ [asset.name] \ [asset.stage] if delete_stage_folder(asset): project.write_project(project_dic) # Create the "wall" event using the wizard "wall" module wall().remove_event(asset) send_signal.refresh_signal() # Return the success to the user return 1 else: # Return the fail and log it to the user logger.warning("{} - {} doesn't exists".format(asset.name, asset.stage)) return 0
def save(self, signal_dic): file = signal_dic[defaults._signal_file_key_] asset = asset_core.string_to_asset( signal_dic[defaults._signal_asset_key_]) filename = os.path.basename(file) filename = filename.split('.')[0] if filename == folder(asset).work_name_template: version = folder(asset).version_from_file(file) if version.isdigit(): asset.version = prefs.asset(asset).software.new_version( version=version) time.sleep(1) try: im_file = prefs.asset(asset).software.image screen_tools.screen_shot_current_screen(im_file) except: logger.critical(str(traceback.format_exc())) # Try refreshing the ui try: send_signal.refresh_signal() logger.info('{} saved ({})'.format(file, asset.software)) send_signal.save_signal() stats().add_xp(2) stats().add_version(asset) except: pass
def remove_name(asset): # Creates a new name with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check if category exists # Check if name doesn't exists if checker.check_category_existence(asset) and \ checker.check_name_existence(asset): # Add the name to the project dictionnary del project_dic \ [asset.domain] \ [asset.category] \ [asset.name] # Write the project dictionnary to the tree.wd # Only if the folder suppression succeed if delete_folder(asset): project.write_project(project_dic) # Create the "wall" event using the wizard "wall" module wall().remove_event(asset) send_signal.refresh_signal() # Return the success to the user return 1 else: # Return the fail return 0 else: # Return the fail and log it to the user logger.warning('{} already exists'.format(asset.name)) return 0
def refresh_ui(): send_signal.refresh_signal()
def create_variant(asset): print('current_task:Creating {}'.format(asset.variant)) print('percent:0') sys.stdout.flush() print('current_task:Updating project') print('percent:33') sys.stdout.flush() # Creates a new variant with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check special characters if not util.check_illegal(asset.variant) or asset.variant == "None" or asset.variant == "none": # Return the fail and log the problem to the user logger.warning('{} contains illegal characters'.format(asset.variant)) return 0 else: # Check if category, name, stage exists # Check if variant doesn't exists if checker.check_category_existence(asset): if checker.check_name_existence(asset): if checker.check_stage_existence(asset): if not checker.check_variant_existence(asset): # Add the variant to the project dictionnary project_dic[asset.domain] \ [asset.category] \ [asset.name] \ [asset.stage] \ [asset.variant] = {} # Add an ID for the variant id = nodes.asset_to_id(asset) project_dic[asset.domain] \ [asset.category] \ [asset.name] \ [asset.stage] \ [asset.variant] \ [defaults._asset_id_key_] = id # Write the project dictionnary to the tree.wd project.write_project(project_dic) print('current_task:Creating folders') print('percent:66') sys.stdout.flush() # Build the folders create_folders(asset) # Init the asset variant prefs prefs.asset(asset).variant.write() # Add the variant to the stage prefs prefs.asset(asset).stage.add_variant() # Create the softwares prefs and folders, childs of variant create_softwares(asset) create_export_root(asset) create_sandbox(asset) create_playblast(asset) # Log the success to user logger.info('{} - {} - {} created'.format(asset.name, asset.stage, asset.variant)) print('current_task:Variant created') print('percent:100') sys.stdout.flush() # Create the wall event with the "wall" wizard module wall().create_event(asset) send_signal.refresh_signal() # Return the success return 1 else: # Return the fail and log it to the user logger.warning('{} - {} - {} already exists'.format(asset.name, asset.stage, asset.variant)) return 0 else: logger.warning("{} doesn't exists".format(asset.stage)) return 0 else: logger.warning("{} doesn't exists".format(asset.name)) return 0 else: logger.warning("{} doesn't exists".format(asset.category)) return 0
def create_category(asset): # Creates a new category with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() print('current_task:Creating category') print('percent:0') sys.stdout.flush() if not util.check_illegal(asset.category) or asset.category == "None" or asset.category == "none": # Return the fail and log the problem to the user logger.warning('{} contains illegal characters'.format(asset.category)) return 0 else: # Check if category doesn't exists # Using the wizard "checker" module print('current_task:Updating project') print('percent:33') sys.stdout.flush() if not checker.check_category_existence(asset): # Add the category to the project dictionnary project_dic \ [asset.domain] \ [asset.category] = {} # Write the project dictionnary to the tree.wd project.write_project(project_dic) print('current_task:Creating folders') print('percent:66') sys.stdout.flush() # Build the folders create_folders(asset) # Init the asset category prefs prefs.asset(asset).category.write() # Log the success to user logger.debug('Sequence {} added to asset.wd'.format(asset.category)) logger.info('{} created'.format(asset.category)) print('current_task:Category created') print('percent:100') sys.stdout.flush() # Emit the event with the "wall" module ( from wizard ) wall().create_event(asset) send_signal.refresh_signal() # Return the success return 1 else: # Return the fail and log it to the user logger.warning('{} already exists'.format(asset.category)) return 0
def create_name(asset, in_out=None): print('current_task:Creating name') print('percent:0') sys.stdout.flush() print('current_task:Updating project') print('percent:33') sys.stdout.flush() # Creates a new name with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check special characters if not util.check_illegal(asset.name) or asset.name == "None" or asset.name == "none": # Return the fail and log the problem to the user logger.warning('{} contains illegal characters'.format(asset.name)) return 0 else: # Check if category exists # Check if name doesn't exists if checker.check_category_existence(asset): if not checker.check_name_existence(asset): # Add the name to the project dictionnary project_dic \ [asset.domain] \ [asset.category] \ [asset.name] = {} # Write the project dictionnary to the tree.wd project.write_project(project_dic) print('current_task:Creating folders') print('percent:66') sys.stdout.flush() # Build the folders create_folders(asset) # Init the asset name prefs prefs.asset(asset).name.write(in_out) # Log the success to user logger.debug('Asset {} added to asset.wd'.format(asset.name)) logger.info('{} created'.format(asset.name)) print('current_task:Name created') print('percent:100') sys.stdout.flush() # Create the wall event wall().create_event(asset) send_signal.refresh_signal() # Return the success return 1 else: # Return the fail and log it to the user logger.warning('{} already exists'.format(asset.name)) return 0 else: logger.warning("{} doesn't exists".format(asset.category)) return 0
def closeEvent(self, event): send_signal.refresh_signal() event.ignore() self.hide()