Example #1
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
Example #2
0
def delete_stage_folder(asset):

    # Check if the folder exists
    if asset.stage and folder(asset).is_stage():

        # Get the source folder ( from the pipe tree )
        # Use the "folder" wizard module
        source = folder(asset).stage

        # Get the destination archive folder using the "prefs" wizard module
        destination = folder(asset).trash

        # Check if the default archives folder exists
        # Using the project variable ( from the asset object )
        # And the "defaults" wizard module
        if not os.path.isdir(os.path.join(asset.project, defaults._trash_folder_)):

            # Create the archive folder
            os.mkdir(os.path.join(asset.project, defaults._trash_folder_))

        # Create the .zip archive file ( name with the python "time" module)
        # And using the "utility" wizard module
        util.zip_folder(destination, source)

        # Remove the the source tree ( from the pipeline folder's tree)
        shutil.rmtree(source)

        # Return the success
        return 1

    else:

        # Return the fail
        return 0
Example #3
0
 def __init__(self, asset):
     self.database = util.database()
     self.asset = asset
     self.path = folder(self.asset).export()
     self.file = os.path.join(self.path, defaults._export_prefs_)
     self.read_settings()
     self.get_version()
     self.version_path = folder(self.asset).export(
         self.asset.export_version)
Example #4
0
def create_software_folder(asset):

    # Check if the asset object as a software assigned
    # And check if the concerned folder doesn't exists
    if asset.software and\
            not folder(asset).is_software():

        # Create the folder using the "os" python module
        # And using the "folder" wizard module
        os.mkdir(folder(asset).software)
Example #5
0
    def folder(self):

        # Return the asset folder
        # in function of which variables are declared in the asset
        if self.stage:
            return folder(self).software
        elif self.name:
            return folder(self).name
        elif self.category:
            return folder(self).category
        else:
            return folder(self).domain
Example #6
0
    def export(self, export_asset_namespace, need_proxy=0, from_asset=None):

        # This function create the folders and writes the needed preferences
        # to the necessary .wd files
        # This function need thoses arguments :
        #-export_asset_namespace ( the namespace of the imported asset )
        #-need_proxy ( Does the asset need a proxy version - only used in set_dress and layouts )

        # Set the namespace from the imported asset as "export_asset" variable
        # This will influence the export folders
        self.export_asset = export_asset_namespace

        # Add the export asset to export_root '.wd' file if doesn't exists
        # Using the "prefs" wizard module
        self.asset_prefs.export_root.add_export_asset(self.export_asset)

        # Set the export_asset as default - Influence the nexts imports of this exported asset
        self.asset_prefs.export_root.set_default_export_asset(
            self.export_asset)

        # Create the new folders using the "wizard.asset.build" module
        build.create_export(self)

        # Get a new version with the "prefs" wizard module
        version = self.asset_prefs.export.get_new_version()

        # Create the version folder using the "wizard.asset.build" module
        path = build.create_export(self, version)

        # Get the export_file using the "folder" wizard module
        file = folder(self).export_file

        if from_asset:
            self.asset_prefs.export.set_from_asset(from_asset)

        if need_proxy:

            # If a proxy is needed, get the proxy file using the "wizard.asset.folder" module
            proxy_file = folder(self).export_proxy_file

            # Build and return the full proxy file path/name using the "os" python module
            return [os.path.join(path, file), os.path.join(path, proxy_file)]

        else:

            # If no proxy needed, return only the main export file
            # Using the "os" pytohn module
            return os.path.join(path, file)
Example #7
0
 def __init__(self, asset, in_out=None):
     self.database = util.database()
     self.asset = asset
     self.in_out = in_out
     self.path = folder(self.asset).name
     self.file = os.path.join(self.path, defaults._name_prefs_)
     self.settings = self.read_settings()
Example #8
0
 def __init__(self, asset):
     self.database = util.database()
     self.asset = asset
     self.path = folder(self.asset).software
     self.file = os.path.join(self.path, defaults._software_prefs_)
     self.read_settings()
     self.get_version()
Example #9
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
Example #10
0
    def __init__(self, asset, version=None):
        self.database = util.database()
        self.asset = asset
        self.path = folder(self.asset).playblast()
        self.file = os.path.join(self.path, defaults._playblast_prefs_)
        self.read_settings()

        self.version = self.get_version()
Example #11
0
def create_sandbox(asset):
    logger.debug('Creating sandbox folder')
    print('current_task:creating sandbox folder')
    sys.stdout.flush()

    path = folder(asset).sandbox
    if not os.path.isdir(path):
        os.makedirs(path)
Example #12
0
def create_export_folder(asset, version = None):

    # Check if the asset object as a variant assigned
    # Check if the asset object as an expoet_asset assigned
    # And check if the concerned folder doesn't exists
    # Usign the "folder" wizard module
    if asset.variant and asset.export_asset and\
            not folder(asset).is_export(version):

        # Get the path using the "folder" wizard module
        path = folder(asset).export(version)

        # Create the folder tree using the "os" pytohn module
        os.mkdir(path)

        # Return the path
        return path
        
Example #13
0
def create_folders(asset):

    # Create the folders from the "asset" object
    # For each part of the asset, check if the part is 
    # assigned and create the concerned folders
    if asset.domain and\
            not folder(asset).is_domain():
        os.mkdir(folder(asset).domain)
    if asset.category and\
            not folder(asset).is_category():
        os.mkdir(folder(asset).category)
    if asset.name and\
            not folder(asset).is_name():
        os.mkdir(folder(asset).name)
    if asset.stage and\
            not folder(asset).is_stage():
        os.mkdir(folder(asset).stage)
    if asset.variant and\
            not folder(asset).is_variant():
        os.mkdir(folder(asset).variant)
Example #14
0
def create_export_root_folder(asset):

    # Check if the asset object as a variant assigned
    # And check if the concerned folder doesn't exists
    if asset.variant:
        path = folder(asset).export_root()

        # Create the folder using the "os" python module
        os.mkdir(path)

        # Return the path
        return path
Example #15
0
    def playblast(self, version):

        # This function create the defaults playblast folder in the asset variant folder
        # and return the playblast file

        # Add the new version to the "playblast.wd" file
        self.asset_prefs.playblast.new_version(version)

        # Build and get the playblast folder using the "wizard.asset.build" wizard module
        path = build.create_playblast(self)

        # Get the playblast file using the "wizard.asset.folder" wizard module
        file = folder(self).playblast_file(version)

        # Build and return the full file usign the "os" python module
        return os.path.join(path, file)
Example #16
0
    def export_multiple(self, export_asset_namespace, files_list):

        # This function create an export folder and return
        # an export file names list to export multiples files
        # It return a list and files and you need to copy your originals files
        # to the new names given

        # Set the namespace from the imported asset as "export_asset" variable
        # This will influence the export folders
        self.export_asset = export_asset_namespace

        # Add the export asset to export_root '.wd' file if doesn't exists
        # Using the "prefs" wizard module
        self.asset_prefs.export_root.add_export_asset(self.export_asset)

        # Set the export_asset as default - Influence the nexts imports of this exported asset
        self.asset_prefs.export_root.set_default_export_asset(
            self.export_asset)

        # Create the new folders using the "wizard.asset.build" module
        build.create_export(self)

        # Get a new version with the "prefs" wizard module
        version = self.asset_prefs.export.get_new_version()

        # Create the version folder using the "wizard.asset.build" module
        path = build.create_export(self, version)

        # Init the file names list
        export_files_names = []

        # Loop into the given files list in arguments
        for file in files_list:

            # Get the file name with the "os" python module
            file_name = os.path.splitext(os.path.basename(file))[0]

            # Get the file name using the "wizard.asset.folder" wizard module
            file = folder(self).export_file_multiple(file_name)

            # Append the full file name to the files names list
            # Using the "os" pytohn module to build the full file
            export_files_names.append(os.path.join(path, file))

        # Return the files names list
        return export_files_names
Example #17
0
def prepare_export():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    node_name = 'Export (wizard)'
    if node_name not in reference_asset.get_all_nodes_names():
        write_node = nuke.createNode('Write')
        write_node['name'].setValue(node_name)
    else:
        write_node = nuke.toNode(node_name)

    base_file = folder(asset).export_file
    extension = os.path.splitext(base_file)[-1]
    file = base_file.replace(extension, '.%05d') + extension
    path = os.path.split(
        asset.export('{}{}{}'.format(asset.category, asset.name,
                                     asset.variant)))[0]
    full_file = os.path.join(path, file)

    write_node['file'].setValue(full_file.replace('\\', '/'))
    write_node['colorspace'].setValue('compositing_linear')
    write_node['compression'].setValue('PIZ Wavelet')
Example #18
0
 def get_image(self):
     image_name = 'capture.{}.png'.format(self.asset.version)
     image_path = os.path.join(folder(self.asset).software, image_name)
     return image_path
Example #19
0
    def get_references(self):

        # Init a references list
        self.references_list = []

        # Init an "assets" list
        self.assets_list = []

        # Get the references dictionnary using the "prefs" wizard module
        self.references_dic = self.asset_prefs.software.references

        # Loop in the keys of the dictionnary to list the references
        # The keys are the imported assets namepsaces
        for reference in list(self.references_dic.keys()):

            # Append the namespace to the references_list
            self.references_list.append(reference)

            # Get the asset from the namespace key
            # The asset is stored as a string and converted into an asset
            # Using the "wizard.asset.main" string_to_asset function
            # The key to access the string_asset is stored in the "defaults" wizard module
            string_asset = self.references_dic[reference][
                defaults._string_asset_]
            asset = asset_core.string_to_asset(string_asset)

            # The key to access the count is stored in the "defaults" wizard module
            # The count is used to differenciate the sames imported assets
            # Example :
            #-Characters_John_rigging_main_0001
            #-Characters_John_rigging_main_0002
            #-Characters_John_rigging_main_0003
            #-Characters_Albert_rigging_main_0001
            count = self.references_dic[reference][defaults._count_]

            # Check if the stored reference in the references dictionnary has a proxy and need to be visible
            # The keys to access thoses variables are stored in the "defaults" wizard module
            if (defaults._proxy_ and defaults._visible_
                ) in self.references_dic[reference].keys():
                proxy = self.references_dic[reference][defaults._proxy_]
                visible = self.references_dic[reference][defaults._visible_]
            else:

                # If thoses keys are not stored in the dictionnary, set proxy to 0 and visible to 1
                proxy = 0

                # If the asset category is sets and the exported asset contain a proxy file
                # Set the proxy by defaults to 1
                if asset.category == defaults._sets_ and prefs.asset(
                        asset).export.is_proxy:
                    proxy = 1
                visible = 1

                # If the keys are not in the references dictionnary, add them
                # by defaults
                self.add_proxy_and_visible_keys(reference, proxy, visible)

            # Add a list in the assets_list
            # This list contains all the keys from the reference dictionnary
            #-asset
            #-count
            #-proxy
            #-pvisible
            if folder(asset).export():
                self.assets_list.append([asset, count, proxy, visible])
Example #20
0
 def get_proxy_file(self):
     return folder(self.asset).export_proxy_file
Example #21
0
 def write(self):
     if folder(self.asset).is_export():
         write_prefs(self.database, self.file, self.settings)
     else:
         logger.debug("Can't write software prefs")
Example #22
0
    def file(self):

        # Get the asset file using the "folder" wizard module
        return folder(self).file
Example #23
0
 def get_folder(self):
     return folder(self.asset).playblast()
Example #24
0
 def get_version_image(self, version):
     folder_obj = folder(self.asset)
     path = os.path.join(folder_obj.playblast(),
                         folder_obj.playblast_image(version))
     return path
Example #25
0
 def get_file(self, version):
     return folder(self.asset).playblast_file(version)
Example #26
0
    def sandbox(self):

        # Return the asset folder
        # in function of which variables are declared in the asset
        if self.stage:
            return folder(self).sandbox
Example #27
0
 def __init__(self, asset):
     self.database = util.database()
     self.asset = asset
     self.path = folder(self.asset).category
     self.file = os.path.join(self.path, defaults._category_prefs_)
     self.settings = self.read_settings()
 def refresh_file(self):
     file = folder(self.asset).export_file
     self.ui.file_label.setText(file)
Example #29
0
    def launch(self):

        # Check if a category is assigned
        # Check if a name is assigned
        # Check if a stage is assigned
        # Check if a variant is assigned
        # Check if a software is assigned
        if self.category and \
                self.name and \
                self.stage and \
                self.variant and \
                self.software:

            # Get the work file using the "getter" module
            self.work = folder(self).file

            # Check if the file exists, if not, copy it from
            # the install dir
            # "null" is the equivalent in the "yaml" module to the python "None" variable
            if defaults._init_file__dic_[self.software] != 'null':

                # Check if the file to launch exists using the "os" pytohn module
                if not os.path.isfile(self.work):

                    # If the file doesn't exists, copy it from the wizard install
                    # Getting the path using the "_init_file_dic_" dictionnary
                    # from the "defaults" wizard module
                    shutil.copyfile(
                        os.path.abspath(
                            defaults._init_file__dic_[self.software]),
                        self.work)

                # As long as "Substance painter" is not scriptable
                # Wizard get the referenced file here to launch the software
                # directly with the referenced asset ( only one and only "geo" )
                if self.software == defaults._painter_:

                    # Get the referenced asset using the "wizard.asset.main.asset.get_reference" wizard function
                    reference = self.get_reference()

                else:

                    # If software isn't substance painter, assign reference to "None"
                    reference = None

                # Create the launch object using the "wizard.software.main.launch" function
                # Give it the following arguments :
                #-asset
                #-the main ui object
                #-the reference
                self.instance = launch(self, reference)

                # Open the software using the "launch.open" function
                # Return the launched object
                return self.instance.open()

            else:

                # If no software is assigned to the asset, try to open the folder
                # Using the "os" python module
                try:
                    os.startfile(self.folder)
                except:

                    # If an exception is raised, log it to the user
                    logger.critical(str(traceback.format_exc()))
        else:
            return 0