Ejemplo n.º 1
0
def rebuild_work_stats():
    project_dic = project.read_project()
    asset_version_list = []
    stats().reset_versions_count()

    for domain in project_dic.keys():
        for category in project_dic[domain].keys():
            for name in project_dic[domain][category].keys():
                for stage in project_dic[domain][category][name].keys():
                    asset = asset_core.asset(domain=domain,
                                             category=category,
                                             name=name,
                                             stage=stage)
                    for variant in prefs().asset(asset).stage.variants:
                        if variant and variant != 'None':
                            asset.variant = variant
                            for software in prefs().asset(
                                    asset).stage.softwares:
                                asset.software = software
                                version_list = prefs().asset(
                                    asset).software.versions
                                for version in version_list:
                                    if version != '0000':
                                        asset.version = version
                                        if prefs().asset(
                                                asset
                                        ).software.version_user == prefs(
                                        ).user:
                                            asset_version_list.append(asset)
                                            stats().add_version(asset)
Ejemplo n.º 2
0
def create_playblast(asset):

    # 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):

        # Get the playblast folder path
        path = folder(asset).playblast()

        # Create the folder tree if it doesn't exists
        if not os.path.isdir(path):
            os.makedirs(path)

            # Log it to the user
            logger.debug('Playblast folder created')

        # Init the asset software prefs using the wizard "prefs" module
        prefs.asset(asset).playblast.write()

        # Return the path
        return path
Ejemplo n.º 3
0
def create_export_root(asset):

    # First read the project dictionnary
    project_dic = project.read_project()

    print('current_task:Creating export_root folder')
    print('percent:78')
    sys.stdout.flush()


    # 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):

        # Create the folder tree and return the path
        path = create_export_root_folder(asset)

        # Create the prefs file with the wizard "prefs" module
        prefs.asset(asset).export_root.write()

        # Log the success to user
        # And return the path
        logger.debug('Export root folder created')
        print('current_task:export_root folder created')
        print('percent:80')
        sys.stdout.flush()
        return path
Ejemplo n.º 4
0
def create_export(asset, version = None):

    # 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):

        # Create the folder tree and get the path
        path = create_export_folder(asset, version)

        # Init the asset software prefs
        # Use the wizard "prefs" module
        if version:
            asset.export_version = version
        prefs.asset(asset).export.write()

        # If a version was specified, add it to the prefs file
        if version:
            prefs.asset(asset).export.new_version(version)

        # Log the success to user
        # And return the folder path
        logger.debug('Export folder created')
        return path
Ejemplo n.º 5
0
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
Ejemplo n.º 6
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))
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
def check_category_existence(asset):

    # First read the main project dictionnary
    project_dic = project.read_project()

    # Check the presence in the project dictionnary
    if asset.category in project_dic \
            [asset.domain]:

        # Return the presence
        return 1
    else:
        return 0
Ejemplo n.º 9
0
def check_variant_existence(asset):

    # First read the main project dictionnary
    project_dic = project.read_project()

    # Check the presence in the project dictionnary
    if asset.variant in project_dic \
            [asset.domain] \
            [asset.category] \
            [asset.name] \
            [asset.stage]:

        # Return the presence
        return 1
    else:
        return 0
Ejemplo n.º 10
0
def check_software_existence(asset):

    # First read the main project dictionnary
    project_dic = project.read_project()

    # Return the requested part existence
    if asset.software in project_dic \
            [asset.domain] \
            [asset.category] \
            [asset.name] \
            [asset.stage] \
            [asset.variant]:

        # Return the presence
        return 1
    else:
        return 0
Ejemplo n.º 11
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
Ejemplo n.º 12
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
Ejemplo n.º 13
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
Ejemplo n.º 14
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
Ejemplo n.º 15
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