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 create_softwares(asset): print('current_task:Creating software') print('percent:0') sys.stdout.flush() print('current_task:Updating project') print('percent:33') sys.stdout.flush() # Creates a new software with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check if category, name, stage and variant exists if checker.check_category_existence(asset) and \ checker.check_name_existence(asset) and \ checker.check_stage_existence(asset) and \ checker.check_variant_existence(asset): percent_step = 33/len(prefs.asset(asset).stage.softwares) percent = 33 # Loop, add every softwares of the concerned stage for software in prefs.asset(asset).stage.softwares: # Assign the software from the loop to the "asset" object asset.software = software # Check if this software doesn't already exists if not checker.check_software_existence(asset): # Add the software to the project dictionnary project_dic[asset.domain] \ [asset.category] \ [asset.name] \ [asset.stage] \ [asset.variant] \ [asset.software] = {} # Write the project dictionnary to the tree.wd project.write_project(project_dic) percent+=percent_step print('current_task:Creating {} folders'.format(software)) print('percent:{}'.format(int(percent))) sys.stdout.flush() # Build the folders create_software_folder(asset) # Init the asset software prefs prefs.asset(asset).software.write() # Log the success to user logger.debug('Software {} added to asset.wd'.format(software))
def create_stage(asset): print('current_task:Creating {}'.format(asset.stage)) print('percent:0') sys.stdout.flush() print('current_task:Updating project') print('percent:33') sys.stdout.flush() # 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): if checker.check_name_existence(asset): if not checker.check_stage_existence(asset): # Add the stage to the project dictionnary project_dic[asset.domain] \ [asset.category] \ [asset.name] \ [asset.stage] = {} # 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 stage prefs prefs.asset(asset).stage.write() print('current_task:Stage created') print('percent:100') sys.stdout.flush() # Return and log the success to user logger.debug('Stage {} added to asset.wd'.format(asset.stage)) return 1 else: # Return and log the fail to the user logger.warning('{} - {} already exists'.format(asset.name, 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 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 remove_category(asset): # Creates a new category with an "asset" object in arg # First read the project dictionnary project_dic = project.read_project() # Check if category doesn't exists if checker.check_category_existence(asset): # Add the category to the project dictionnary del project_dic \ [asset.domain] \ [asset.category] # write the project file project.write_project(project_dic) # Return the success return 1 else: # Return the fail return 0
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