コード例 #1
0
 def saveFile(self, type=0):
     #So this function needs to look into the proper component folder (if it exists), find the Working folder (if it exists, if not make it)
     #Then save an iteration of this file.
     project = self.getSelectedProject()
     if project!="None":
         if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
             part_index = int(windows.optionMenu("partOptionMenu", q=True, v=True).split(":")[0]) - 1
             part_directory, part_name, part_numname = project.modelingComponents[part_index]
             if os.path.isdir(part_directory):
                 #part_name = project.modelingComponents[part_index][1]
                 
                 working_dir = os.path.join(part_directory, "Working")
                 publish_dir = os.path.join(part_directory, "Publish")
                 
                 if os.path.isdir(working_dir)==False:
                     os.makedirs(working_dir)
                 if os.path.isdir(publish_dir)==False:
                     os.makedirs(publish_dir)
                     
                 if type==0:
                     files = glob.glob(working_dir+"/*")
                     if len(files)>0:
                         highest_num=0
                         for file in files:
                             if os.path.isfile(file):
                                 filenum = int(file.split("/")[-1].split("_")[-1].split(".")[0])
                                 if filenum>highest_num:
                                     highest_num = filenum
                         else:
                             highest_num+=1
                             num = ("0"*max(0,3-len(str(highest_num)))+str(highest_num))
                             #if len(str(highest_num))==1:
                             #    num="00"+str(highest_num)
                             #if len(str(highest_num))==2:
                             #    num="0"+str(highest_num)
                             #if len(str(highest_num))==3:
                             #    num=str(highest_num)
                             print("Num: " + num)
                     else:
                         num = "001"
                     
                     if num=="001":
                         if windows.confirmDialog(title = "Save Part File?", message = "Save the first version of this part? You will not be prompted when saving new versions after this.", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                             file_name = os.path.join(working_dir , part_name + "_working_" + num + ".mb")
                             system.saveAs(file_name)
                     else:
                         file_name = os.path.join(working_dir , part_name + "_working_" + num + ".mb")
                         system.saveAs(file_name)
                         
                 elif type==1:
                     if windows.confirmDialog(title = "Publish File", message = "Publish this scene file?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         file_name = os.path.join(publish_dir, part_name + "_publish.mb")
                         current_filename = system.sceneName()
                         system.saveAs(file_name)
                         system.saveAs(current_filename)
             else:
                 windows.confirmDialog(title = "Part Not Found", message = "The selected part folder cannot be found.", button=["Dismiss"])
コード例 #2
0
ファイル: general.py プロジェクト: joemuers/pyswarm
def GetCurrentSceneName():
    """
    Returns the name only (*not* the full path) of the current Maya scene.
    (i.e. last name that scene was saved as).
    """
    sceneFile = sm.sceneName()
    sceneFile = os.path.split(sceneFile)[1]

    return os.path.splitext(sceneFile)[0]
コード例 #3
0
ファイル: gui.py プロジェクト: onelson/ringling-render-tools
 def job_data(self):
     return {
             'renderer': get_job_type(),
             'title': self.job_title,
             'project': os.path.normpath(workspace.getPath()),
             'output': os.path.join(JOB_OUTPUT_UNC, getpass.getuser(), '{job_id}', 'output'), # job_id is injected by hpc-spool when the submission happens
             'scene': os.path.normpath(sceneName()),
             'start': self.job_start,
             'end': self.job_end,
             'threads': self.job_threads,
             'step': self.job_step,
     }
コード例 #4
0
ファイル: gui.py プロジェクト: sgmorale/ringling-render-tools
 def job_data(self):
     job_uuid = JobSpec.new_uuid()
     return {
             'renderer': get_job_type(),
             'title': self.job_title,
             'project': os.path.normpath(workspace.getPath()),
             'output': os.path.join(JOB_OUTPUT_UNC, getpass.getuser(), job_uuid),
             'scene': os.path.normpath(sceneName()),
             'start': self.job_start,
             'end': self.job_end,
             'threads': self.job_threads,
             'step': int(Scene().defaultRenderGlobals.byFrameStep.get()),
             'uuid': job_uuid,
     }
コード例 #5
0
 def job_data(self):
     moddedType = str(get_job_type())
     if os.environ['EMULATE'] == '0':                
         moddedType +='_local'
     return {
             'renderer': moddedType,
             'title': self.job_title,
             'project': os.path.normpath(workspace.getPath()),
             'output': os.path.join('D:\\hpc\\', getpass.getuser(), '{job_id}', 'output'), # job_id is injected by hpc-spool when the submission happens
             'scene': os.path.normpath(sceneName()),
             'start': self.job_start,
             'end': self.job_end,
             'threads': 4, #self.job_threads,
             'step': self.job_step,
             'ext' : None
     }
コード例 #6
0
    def test_get_scene_name(self):
        with Stub() as pymel.core.system:
            from pymel.core.system import sceneName

            sceneName() >> "S:/foo/bar.ext"
        self.assertEquals(get_scene_name(), "bar")
        with Stub() as pymel.core.system:
            from pymel.core.system import sceneName

            sceneName() >> "S:\\foo\\bar.ext"
        self.assertEquals(get_scene_name(), "bar")

        with Stub() as pymel.core.system:
            from pymel.core.system import sceneName

            sceneName() >> "S:/foo/bar_no_ext"
        self.assertEquals(get_scene_name(), "bar_no_ext")
コード例 #7
0
 def get_shot_name(self):
     self.config['SHOT'] = os.path.splitext(sceneName().basename())[0]
コード例 #8
0
ファイル: fileSaver.py プロジェクト: Rhinoceroscity/FileSaver
 def saveFile(self, type=0):
     #So this function needs to look into the proper component folder (if it exists), find the Working folder (if it exists, if not make it)
     #Then save an iteration of this file.
     project = self.getSelectedProject()
     if project!="None":
         if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
             part_index = int(windows.optionMenu("partOptionMenu", q=True, v=True).split(":")[0]) - 1
             part_directory, part_name, part_numname = project.modelingComponents[part_index]
             if os.path.isdir(part_directory):
                 #part_name = project.modelingComponents[part_index][1]
                 
                 working_dir = os.path.join(part_directory, "Working")
                 qa_dir = os.path.join(part_directory, "QA")
                 publish_dir = os.path.join(part_directory, "Publish")
                 
                 if os.path.isdir(working_dir)==False:
                     os.makedirs(working_dir)
                 if os.path.isdir(qa_dir)==False:
                     os.makedirs(qa_dir)
                 if os.path.isdir(publish_dir)==False:
                     os.makedirs(publish_dir)
                 
                 #If save type is 0 (which is a regular work file incremental save)
                 #Save format: part_modeler_v001.mb
                 if type==0:
                     if self.username!="":
                         files = glob.glob(working_dir+"/*")
                         if len(files)>0:
                             highest_num=0
                             for file in files:
                                 if os.path.isfile(file):
                                     filenum = int(os.path.split(file)[1].split(".")[0][-3:])
                                     if filenum>highest_num:
                                         highest_num = filenum
                             else:
                                 highest_num+=1
                                 num = ("0"*max(0,3-len(str(highest_num)))+str(highest_num))
                                 print("Num: " + num)
                         else:
                             num = "001"
                         
                         if num=="001":
                             if windows.confirmDialog(title = "Save Part File?", message = "Save the first version of this part? You will not be prompted when saving new versions after this.", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                                 file_name = os.path.join(working_dir , part_name + "_" + self.username + "_" + "v" + num + ".mb")
                                 system.saveAs(file_name)
                         else:
                             file_name = os.path.join(working_dir , part_name + "_" + self.username + "_" + "v" + num + ".mb")
                             system.saveAs(file_name)
                     else:
                         windows.confirmDialog(title="No username entered.", message="Please enter a valid username to save with.",button="Dismiss")
                 
                 #If the save file is type 1, its a publish attempt 
                 elif type==1:
                     if windows.confirmDialog(title = "Publish File", message = "Publish this scene file?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         file_name = os.path.join(publish_dir, part_name + "_publish.mb")
                         if os.path.isfile(file_name):
                             ctime = os.path.getctime(file_name)
                             moveFolder = os.path.join(publish_dir,"_old",time.strftime("%b%d_%Y %H-%M-%S",time.localtime(ctime)))
                             if not os.path.isdir(moveFolder):
                                 os.makedirs(moveFolder)
                             shutil.move(file_name, moveFolder)
                         #Save the current file, then move on to cleaning up this file in preparation for publishing
                         current_filename = system.sceneName()
                         system.saveAs(current_filename)
                         #Clean up all references
                         reference_files = []
                         references = general.ls(type = "reference")
                         if len(references)>0:
                             for reference in references:
                                 if "sharedReferenceNode"!=reference:
                                     reference_files.append(system.referenceQuery(reference, filename=True))
                             else:
                                 for file in reference_files:
                                     system.FileReference(pathOrRefNode = file).remove()
                         general.select(clear = True)
                         general.select(general.ls(geometry = True))
                         layerName = os.path.split(system.sceneName())[1].split("_")[0].replace(" ", "_")
                         general.createDisplayLayer(name = layerName)
                         system.saveAs(file_name)
                         system.openFile(current_filename, f = True)
                 #If its type 2, its a QA submit
                 elif type==2:
                     if windows.confirmDialog(title = "Submit for QA", message = "Submit this scene file for QA?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         _time = time.strftime("%b%d_%Y_%H-%M-%S", time.localtime(time.time()))
                         file_name = os.path.join(qa_dir, part_name + "_%s_%s.mb"%(self.username,_time))
                         _files = glob.glob(qa_dir+"/*.mb")
                         if len(_files)>0:
                             found=False
                             for i in _files:
                                 if file_name == i:
                                     found=True
                                     if windows.confirmDialog(title = "Overwrite?", message = "A QA file with this name already exists.  Overwrite it?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes': 
                                         current_filename = system.sceneName()
                                         system.saveAs(file_name)
                                         system.saveAs(current_filename)
                                         
                                 else:
                                     _folder = os.path.join(qa_dir,os.path.split(i)[1].split(".")[0])
                                     os.makedirs(_folder)
                                     shutil.move(i, _folder)
                             else:
                                 if found==False:
                                     current_filename = system.sceneName()
                                     system.saveAs(file_name)
                                     system.saveAs(current_filename)
                         else:
                             current_filename = system.sceneName()
                             system.saveAs(file_name)
                             system.saveAs(current_filename)
             else:
                 windows.confirmDialog(title = "Part Not Found", message = "The selected part folder cannot be found.", button=["Dismiss"])
コード例 #9
0
def get_scene_name():
    """Returns the filename (no extension) of the current scene"""
    return os.path.splitext(os.path.basename(sceneName()))[0]