From 22ec3999ef719c385218b6d1806638065d2cff66 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 09:42:13 +0300 Subject: [PATCH 01/11] 1 --- modules/maya_warpper.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/maya_warpper.py b/modules/maya_warpper.py index eac77dd..7f7692f 100644 --- a/modules/maya_warpper.py +++ b/modules/maya_warpper.py @@ -111,7 +111,37 @@ def import_scene(path = None): namesspace = files.file_name_no_extension(files.file_name(path)) return cmds.file(path, i = True, f = True, ns = namesspace, esn = False) + +def list_referenced_files(): + results = [] + links = cmds.filePathEditor(query=True, listDirectories="") + for link in links: + pairs = cmds.filePathEditor(query=True, listFiles=link, withAttribute=True, status=True) + ''' + paris: list of strings ["file_name node status ...", "file_name node status ...",...] + we need to make this large list of ugly strings (good inforamtion seperated by white space) into a dictionry we can use + ''' + l = len(pairs) + items = l/3 + order = {} + index = 0 + ''' + order: dict of {node: [file_name, status],...} + ''' + + for i in range(0,items): + order[pairs[index+1]] = [os.path.join(link,pairs[index]),pairs[index+2]] + index = index + 3 + + for key in order: + # for each item in the dict, if the status is 0, repath it + if order[key][1] == "1": + results.append(order[key][0]) + + + return results + def relink_pathes(project_path = None): results = [] From 9b093ca3a56332d67e3a434057a39e019c5eea4d Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 22:49:42 +0300 Subject: [PATCH 02/11] 2 --- dialogue.py | 48 ++++++++++++++++++++++++++++++++++++++++++ pipeline.py | 13 +++++++++++- ui/pipeline_main_UI.ui | 6 ++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/dialogue.py b/dialogue.py index 3a858bd..1cbc2ca 100644 --- a/dialogue.py +++ b/dialogue.py @@ -149,7 +149,55 @@ def radio_selection(self): def result(self): return self.text_input.text(), self.radio_selection() +class collect_component_options(QtGui.QDialog): + def __init__(self, parent = None, title = None): + super(collect_component_options, self).__init__(parent) + + + self.setMaximumWidth(200) + self.setMinimumWidth(200) + self.setMaximumHeight(50) + + layout = QtGui.QVBoxLayout(self) + self.item_name = QtGui.QLabel(title) + #self.text_input = QtGui.QLineEdit() + self.directory_tree = QtGui.QCheckBox("Keep directory structure") + self.directory_tree.setChecked(True) + self.include_reference = QtGui.QCheckBox("Include referenced files") + self.include_reference.setChecked(True) + self.include_textures = QtGui.QCheckBox("Include textures") + self.include_textures.setChecked(True) + + layout.addWidget(self.item_name) + #layout.addWidget(self.text_input) + layout.addWidget(self.directory_tree) + layout.addWidget(self.include_reference) + layout.addWidget(self.include_textures) + buttons = QtGui.QDialogButtonBox( + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, + QtCore.Qt.Horizontal, self) + buttons.accepted.connect(self.accept) + buttons.rejected.connect(self.reject) + layout.addWidget(buttons) + + def options(self): + directory_tree = False + references = False + textures = False + + if self.directory_tree.isChecked(): + directory_tree = True + if self.include_reference.isChecked(): + references = True + if self.include_textures.isChecked(): + textures = True + + return references, textures + + + def result(self): + return self.options() class Login(QtGui.QDialog): def __init__(self, parent=None): diff --git a/pipeline.py b/pipeline.py index e14620f..e11e766 100644 --- a/pipeline.py +++ b/pipeline.py @@ -1619,6 +1619,7 @@ def __init__(self, parent=None): self.ui.actionDocumentation.triggered.connect(self.documentation) self.ui.actionFiles_repath.triggered.connect(self.repath) + self.ui.actionCollect_component.triggered.connect(self.collect_component) self.ui.users_pushButton.clicked.connect(self.login_window) self.ui.projects_pushButton.clicked.connect(self.projects_window) @@ -3965,7 +3966,17 @@ def component_rename(self): self.set_component_selection() #re open the component that was open... - + + def collect_component(self): + + dialog = dlg.collect_component_options(self, title = "Collect component options") + result = dialog.exec_() + input = dialog.result() + + if result == QtGui.QDialog.Accepted: + log.info(input) + + def enable(self, Qwidget, level = None): diff --git a/ui/pipeline_main_UI.ui b/ui/pipeline_main_UI.ui index 0c6935a..6e18455 100644 --- a/ui/pipeline_main_UI.ui +++ b/ui/pipeline_main_UI.ui @@ -735,6 +735,7 @@ Tools + @@ -767,6 +768,11 @@ Documentation + + + Collect component + + From 241f76f60f5842f1dfdb2880f4407479fe97b4e9 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 23:18:11 +0300 Subject: [PATCH 03/11] 3 --- dialogue.py | 2 +- modules/files.py | 9 +++++++++ modules/maya_warpper.py | 13 ++++++------- pipeline.py | 19 +++++++++++++++++-- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/dialogue.py b/dialogue.py index 1cbc2ca..753d223 100644 --- a/dialogue.py +++ b/dialogue.py @@ -193,7 +193,7 @@ def options(self): if self.include_textures.isChecked(): textures = True - return references, textures + return directory_tree, references, textures def result(self): diff --git a/modules/files.py b/modules/files.py index 58b1f51..98346b4 100644 --- a/modules/files.py +++ b/modules/files.py @@ -164,6 +164,15 @@ def list_dir_folders(path): return [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))] +def assure_path_exists(path): + dir = os.path.dirname(path) + if not os.path.exists(dir): + os.makedirs(dir) + + +def reletive_path(absolute_path, path): + return os.path.relpath(path, absolute_path) + def create_directory(path): if not os.path.exists(path): diff --git a/modules/maya_warpper.py b/modules/maya_warpper.py index 7f7692f..bc574b5 100644 --- a/modules/maya_warpper.py +++ b/modules/maya_warpper.py @@ -131,16 +131,15 @@ def list_referenced_files(): ''' for i in range(0,items): - order[pairs[index+1]] = [os.path.join(link,pairs[index]),pairs[index+2]] + order[pairs[index+1]] = [os.path.join(link,pairs[index]),pairs[index+1],pairs[index+2]] index = index + 3 for key in order: # for each item in the dict, if the status is 0, repath it - if order[key][1] == "1": - results.append(order[key][0]) + if order[key][2] == "1": + results.append([order[key][0],cmds.nodeType(order[key][1])]) - - return results + return results def relink_pathes(project_path = None): @@ -171,8 +170,8 @@ def relink_pathes(project_path = None): if repath(key,order[key][0],project_path): results.append(key) - - return results + + return results diff --git a/pipeline.py b/pipeline.py index e11e766..2b557b5 100644 --- a/pipeline.py +++ b/pipeline.py @@ -3975,8 +3975,23 @@ def collect_component(self): if result == QtGui.QDialog.Accepted: log.info(input) - - + tree = input[0] + ref = input[1] + texture = input[2] + + dependencies = maya.list_referenced_files() + for dep in dependencies: + if dep[1] == 'file': + print "TEX: ", files.reletive_path(self.settings.current_project_path,dep[0]) + if dep[1] == 'reference': + print "REF: ", files.reletive_path(self.settings.current_project_path,dep[0]) + + path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) + print path + + + files.assure_path_exists() + def enable(self, Qwidget, level = None): From e0a6139832c2b5c3b271c8eb8791419d384394c5 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 23:48:05 +0300 Subject: [PATCH 04/11] 4 --- pipeline.py | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/pipeline.py b/pipeline.py index 2b557b5..1cef27b 100644 --- a/pipeline.py +++ b/pipeline.py @@ -3979,18 +3979,50 @@ def collect_component(self): ref = input[1] texture = input[2] + + + #collect dependencies + + import glob + dependencies = maya.list_referenced_files() + dep_paths = [] for dep in dependencies: if dep[1] == 'file': print "TEX: ", files.reletive_path(self.settings.current_project_path,dep[0]) + dep_paths.append(files.reletive_path(self.settings.current_project_path,dep[0])) if dep[1] == 'reference': print "REF: ", files.reletive_path(self.settings.current_project_path,dep[0]) - path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) - print path + + if len(glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))) == 1: + pipe_file = glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))[0] + comp_name = os.path.basename(pipe_file)[0] + tumb_file = os.path.join(os.path.dirname(pipe_path),"tumbnails",("%s.%s"%(comp_name,"png"))) + + dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) + dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) + + if len(glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))) == 1: + pipe_file = glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))[0] + comp_name = os.path.basename(pipe_file)[0] + tumb_file = os.path.join(os.path.dirname(pipe_path),"tumbnails",("%s.%s"%(comp_name,"png"))) + + dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) + dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) + + dep_paths.append(files.reletive_path(self.settings.current_project_path,dep[0])) + + + + + collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) + for rel_path in dep_paths: + path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'Collect'),self.settings.current_project_name,rel_path) + files.assure_path_exists(path) + - files.assure_path_exists() def enable(self, Qwidget, level = None): From 67d0de28de22d43bd1848447529a1098013b5e58 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 23:50:19 +0300 Subject: [PATCH 05/11] 6 --- pipeline.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline.py b/pipeline.py index 1cef27b..08658b0 100644 --- a/pipeline.py +++ b/pipeline.py @@ -3998,7 +3998,7 @@ def collect_component(self): if len(glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))) == 1: pipe_file = glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))[0] comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_path),"tumbnails",("%s.%s"%(comp_name,"png"))) + tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) @@ -4006,7 +4006,7 @@ def collect_component(self): if len(glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))) == 1: pipe_file = glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))[0] comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_path),"tumbnails",("%s.%s"%(comp_name,"png"))) + tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) From b51c6f65d301838390b0a6697cea2701c47c657b Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Sun, 12 Jun 2016 23:58:22 +0300 Subject: [PATCH 06/11] 7 --- pipeline.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pipeline.py b/pipeline.py index 08658b0..301c622 100644 --- a/pipeline.py +++ b/pipeline.py @@ -3988,13 +3988,19 @@ def collect_component(self): dependencies = maya.list_referenced_files() dep_paths = [] for dep in dependencies: + # for texture files if dep[1] == 'file': - print "TEX: ", files.reletive_path(self.settings.current_project_path,dep[0]) + #print "TEX: ", files.reletive_path(self.settings.current_project_path,dep[0]) dep_paths.append(files.reletive_path(self.settings.current_project_path,dep[0])) + + # for refernce files if dep[1] == 'reference': - print "REF: ", files.reletive_path(self.settings.current_project_path,dep[0]) + #print "REF: ", files.reletive_path(self.settings.current_project_path,dep[0]) + + # if this is a master version or a verison or a master, this will detect it and grab the + # *.pipe file and the tumbnail + # otherwise, it will only get the file and create a path for it - if len(glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))) == 1: pipe_file = glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))[0] comp_name = os.path.basename(pipe_file)[0] @@ -4015,13 +4021,17 @@ def collect_component(self): - + # where to collect the files collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) for rel_path in dep_paths: path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'Collect'),self.settings.current_project_name,rel_path) files.assure_path_exists(path) - + + # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect + # create no users + + # if the function is a success, open the project folder in the finder From 7e49c6bfdd8db33b502b1238585324d494272407 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Mon, 13 Jun 2016 00:00:32 +0300 Subject: [PATCH 07/11] 8 --- pipeline.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipeline.py b/pipeline.py index 301c622..251b27f 100644 --- a/pipeline.py +++ b/pipeline.py @@ -4021,13 +4021,18 @@ def collect_component(self): + # where to collect the files collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) + + # create the tree sturcutre in a releative path for rel_path in dep_paths: path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'Collect'),self.settings.current_project_name,rel_path) files.assure_path_exists(path) + # ---> copy the actual files to the new relative directories... + # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect # create no users From 413900d9a9da7c4ebc641cb7994886df0ed1863b Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Tue, 14 Jun 2016 10:34:49 +0300 Subject: [PATCH 08/11] 9 --- modules/files.py | 25 ++++++++++++-- pipeline.py | 90 +++++++++++++++++++++++++++--------------------- 2 files changed, 73 insertions(+), 42 deletions(-) diff --git a/modules/files.py b/modules/files.py index 98346b4..b241875 100644 --- a/modules/files.py +++ b/modules/files.py @@ -52,7 +52,7 @@ import operator import sys import subprocess - +import glob def dir_rename(dir_fullpath, new_name): @@ -88,7 +88,10 @@ def file_rename(fullpath, new_name): def file_copy(source, dest): if os.path.exists(source): - return shutil.copy2(source, dest) + try: + return shutil.copy2(source, dest) + except: + return None else: return None @@ -170,6 +173,7 @@ def assure_path_exists(path): os.makedirs(dir) + def reletive_path(absolute_path, path): return os.path.relpath(path, absolute_path) @@ -264,4 +268,19 @@ def explore(path): os.startfile(path) - \ No newline at end of file +def get_pipe_file_from_folder_or_parent_folder(path): + + dir = os.path.dirname(path) + file = os.path.join(dir,"*.pipe") + + + if len(glob.glob(file)) == 1: #if its a master + return glob.glob(file)[0] + + dir = os.path.dirname(dir) + file = os.path.join(dir,"*.pipe") + + if len(glob.glob(file)) == 1: #if its a version + return glob.glob(file)[0] + + diff --git a/pipeline.py b/pipeline.py index 251b27f..b4a8cdb 100644 --- a/pipeline.py +++ b/pipeline.py @@ -65,6 +65,7 @@ import collections import logging import webbrowser + log_file = os.path.join(os.path.dirname(__file__), 'pipeline_log.txt') log = logging.getLogger(__name__) @@ -3974,64 +3975,75 @@ def collect_component(self): input = dialog.result() if result == QtGui.QDialog.Accepted: + + # where to collect the files + collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) + collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect'),self.settings.current_project_name) + + log.info(input) tree = input[0] ref = input[1] texture = input[2] + + #collect dependencies + + # ALL OF THIS SHOULD BE RETRIVED BY THE COMPONENT AND NOT IN THIS UGLY WAY!! - #collect dependencies + file = maya.current_open_file() + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,file)) + files.assure_path_exists(path) + files.file_copy(file,path) - import glob + pipe_file = files.get_pipe_file_from_folder_or_parent_folder(file) + comp_name = os.path.basename(pipe_file)[0] + tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) + + pipe_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_new_path) + files.file_copy(pipe_file,pipe_file_new_path) + + tumb_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,tumb_file)) + files.assure_path_exists(tumb_file_new_path) + files.file_copy(tumb_file,tumb_file_new_path) dependencies = maya.list_referenced_files() - dep_paths = [] + #dep_paths = [] for dep in dependencies: # for texture files if dep[1] == 'file': - #print "TEX: ", files.reletive_path(self.settings.current_project_path,dep[0]) - dep_paths.append(files.reletive_path(self.settings.current_project_path,dep[0])) - + filename = files.file_name(dep[0]) + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) + files.assure_path_exists(path) + files.file_copy(dep[0],path) + + # for refernce files if dep[1] == 'reference': - #print "REF: ", files.reletive_path(self.settings.current_project_path,dep[0]) - - # if this is a master version or a verison or a master, this will detect it and grab the - # *.pipe file and the tumbnail - # otherwise, it will only get the file and create a path for it - - if len(glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))) == 1: - pipe_file = glob.glob(os.path.join(os.path.dirname(dep[0]),"*.pipe"))[0] - comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) - - dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) - dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) - - if len(glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))) == 1: - pipe_file = glob.glob(os.path.join(os.path.dirname(os.path.dirname(dep[0])),"*.pipe"))[0] - comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) - - dep_paths.append(files.reletive_path(self.settings.current_project_path,pipe_file)) - dep_paths.append(files.reletive_path(self.settings.current_project_path,tumb_file)) - - dep_paths.append(files.reletive_path(self.settings.current_project_path,dep[0])) + + filename = files.file_name(dep[0]) + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) + files.assure_path_exists(path) + files.file_copy(dep[0],path) + pipe_file = files.get_pipe_file_from_folder_or_parent_folder(dep[0]) + comp_name = os.path.basename(pipe_file)[0] + tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) + + + pipe_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_new_path) + files.file_copy(pipe_file,pipe_file_new_path) + + tumb_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,tumb_file)) + files.assure_path_exists(tumb_file_new_path) + files.file_copy(tumb_file,tumb_file_new_path) + - # where to collect the files - collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) - - - # create the tree sturcutre in a releative path - for rel_path in dep_paths: - path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'Collect'),self.settings.current_project_name,rel_path) - files.assure_path_exists(path) - - # ---> copy the actual files to the new relative directories... # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect # create no users From 755200438682cf4bdbc97f9b72fe1ebb8a1c5230 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Tue, 14 Jun 2016 22:29:16 +0300 Subject: [PATCH 09/11] 10 --- modules/files.py | 4 +- pipeline.py | 103 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 77 insertions(+), 30 deletions(-) diff --git a/modules/files.py b/modules/files.py index b241875..3e7bc00 100644 --- a/modules/files.py +++ b/modules/files.py @@ -281,6 +281,8 @@ def get_pipe_file_from_folder_or_parent_folder(path): file = os.path.join(dir,"*.pipe") if len(glob.glob(file)) == 1: #if its a version - return glob.glob(file)[0] + return glob.glob(file)[0] + + return None diff --git a/pipeline.py b/pipeline.py index b4a8cdb..33b8de1 100644 --- a/pipeline.py +++ b/pipeline.py @@ -700,6 +700,7 @@ def master(self): return master_file return None + ''' @property def thumbnail(self): if self.project: @@ -710,6 +711,26 @@ def thumbnail(self): return QtGui.QPixmap(thumbnail_name) return large_image_icon + ''' + @property + def thumbnail(self): + file = self.thumbnail_path + if file: + return QtGui.QPixmap(file) + + return large_image_icon + + @property + def thumbnail_path(self): + if self.project: + if self.component_file: + if self.settings: + thumbnail_name = os.path.join(self.tumbnails_path,"%s.%s"%(self.component_name,"png")) + if os.path.isfile(thumbnail_name): + return thumbnail_name + + return None + def new_master(self, from_file = False): if self.project: @@ -842,7 +863,27 @@ def rename_asset(self, new_name): self.asset_name = new_name return True - + + def get_data_file(self,path = None): + + if path: + dir = os.path.dirname(path) + file = os.path.join(dir,"*.pipe") + + + if len(glob.glob(file)) == 1: #if its a master + return glob.glob(file)[0] + + dir = os.path.dirname(dir) + file = os.path.join(dir,"*.pipe") + + if len(glob.glob(file)) == 1: #if its a version + return glob.glob(file)[0] + + return None + + return None + class pipeline_shot(pipeline_component): def __init__(self, **kwargs): @@ -3979,35 +4020,37 @@ def collect_component(self): # where to collect the files collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect'),self.settings.current_project_name) - - + log.info(input) tree = input[0] ref = input[1] texture = input[2] + #collect dependencies - - # ALL OF THIS SHOULD BE RETRIVED BY THE COMPONENT AND NOT IN THIS UGLY WAY!! - - + file = maya.current_open_file() path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,file)) files.assure_path_exists(path) files.file_copy(file,path) - pipe_file = files.get_pipe_file_from_folder_or_parent_folder(file) - comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) + component_dummy = pipeline_component() + pipe_file = component_dummy.get_data_file(path = file) + + if pipe_file: + component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) + + pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_copy) + files.file_copy(pipe_file,pipe_file_copy) + + if component.thumbnail_path: + tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) + files.assure_path_exists(tumb_file_copy) + files.file_copy(component.thumbnail_path,tumb_file_copy) - pipe_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) - files.assure_path_exists(pipe_file_new_path) - files.file_copy(pipe_file,pipe_file_new_path) - tumb_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,tumb_file)) - files.assure_path_exists(tumb_file_new_path) - files.file_copy(tumb_file,tumb_file_new_path) dependencies = maya.list_referenced_files() #dep_paths = [] @@ -4029,20 +4072,22 @@ def collect_component(self): files.assure_path_exists(path) files.file_copy(dep[0],path) - - pipe_file = files.get_pipe_file_from_folder_or_parent_folder(dep[0]) - comp_name = os.path.basename(pipe_file)[0] - tumb_file = os.path.join(os.path.dirname(pipe_file),"tumbnails",("%s.%s"%(comp_name,"png"))) - - pipe_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) - files.assure_path_exists(pipe_file_new_path) - files.file_copy(pipe_file,pipe_file_new_path) - - tumb_file_new_path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,tumb_file)) - files.assure_path_exists(tumb_file_new_path) - files.file_copy(tumb_file,tumb_file_new_path) - + component_dummy = pipeline_component() + pipe_file = component_dummy.get_data_file(path = file) + + if pipe_file: + component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) + + pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_copy) + files.file_copy(pipe_file,pipe_file_copy) + + if component.thumbnail_path: + tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) + files.assure_path_exists(tumb_file_copy) + files.file_copy(component.thumbnail_path,tumb_file_copy) + # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect From ddf1ce427751fa90e73b521ebc0d916b453b6434 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Tue, 14 Jun 2016 22:59:29 +0300 Subject: [PATCH 10/11] 11 --- modules/files.py | 4 +++- pipeline.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/files.py b/modules/files.py index 3e7bc00..37aeed3 100644 --- a/modules/files.py +++ b/modules/files.py @@ -172,7 +172,9 @@ def assure_path_exists(path): if not os.path.exists(dir): os.makedirs(dir) - +def assure_folder_exists(path): + if not os.path.exists(path): + os.makedirs(path) def reletive_path(absolute_path, path): return os.path.relpath(path, absolute_path) diff --git a/pipeline.py b/pipeline.py index 33b8de1..b434783 100644 --- a/pipeline.py +++ b/pipeline.py @@ -4019,7 +4019,7 @@ def collect_component(self): # where to collect the files collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) - collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect'),self.settings.current_project_name) + collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect')) log.info(input) tree = input[0] @@ -4043,6 +4043,8 @@ def collect_component(self): pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) files.assure_path_exists(pipe_file_copy) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) files.file_copy(pipe_file,pipe_file_copy) if component.thumbnail_path: @@ -4053,7 +4055,7 @@ def collect_component(self): dependencies = maya.list_referenced_files() - #dep_paths = [] + for dep in dependencies: # for texture files if dep[1] == 'file': @@ -4074,13 +4076,15 @@ def collect_component(self): component_dummy = pipeline_component() - pipe_file = component_dummy.get_data_file(path = file) + pipe_file = component_dummy.get_data_file(path = dep[0]) if pipe_file: component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) files.assure_path_exists(pipe_file_copy) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) files.file_copy(pipe_file,pipe_file_copy) if component.thumbnail_path: @@ -4088,8 +4092,12 @@ def collect_component(self): files.assure_path_exists(tumb_file_copy) files.file_copy(component.thumbnail_path,tumb_file_copy) - + fps = self.project.project_fps + padding = self.project.project_padding + file_type = self.project.project_file_type + + project_file = self.project_file = pipeline_project().create(collect_path, name = '%s_%s'%(self.component.component_name,'collect'), padding = padding, file_type = file_type, fps = fps, users = None) # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect # create no users From 85eed4863d18360a28d1d49a6df55d67a2f684f1 Mon Sep 17 00:00:00 2001 From: liorbenhorin Date: Tue, 14 Jun 2016 23:32:48 +0300 Subject: [PATCH 11/11] 12 --- dialogue.py | 37 ++++++++---- icons/archive.svg | 4 ++ pipeline.py | 149 +++++++++++++++++++++++----------------------- 3 files changed, 105 insertions(+), 85 deletions(-) create mode 100644 icons/archive.svg diff --git a/dialogue.py b/dialogue.py index 753d223..fb946dd 100644 --- a/dialogue.py +++ b/dialogue.py @@ -57,10 +57,15 @@ def set_icons(): global simple_warning_icon global massage_icon global users_icon + global archive_icon + global new_icon + warning_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"critical")) simple_warning_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"warning")) massage_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"massage")) users_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"users")) + archive_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"archive")) + new_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"new")) def warning(icon, title, message ): @@ -120,6 +125,9 @@ def __init__(self, parent = None, title = None): self.setMinimumWidth(200) self.setMaximumHeight(50) + self.label = QtGui.QLabel() + self.label.setPixmap(new_icon) + layout = QtGui.QVBoxLayout(self) self.item_name = QtGui.QLabel(title) self.text_input = QtGui.QLineEdit() @@ -128,10 +136,12 @@ def __init__(self, parent = None, title = None): self.exclude_radio = QtGui.QRadioButton("Include only textures") + layout.addWidget(self.item_name) layout.addWidget(self.text_input) layout.addWidget(self.include_radio) layout.addWidget(self.exclude_radio) + buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, @@ -158,19 +168,23 @@ def __init__(self, parent = None, title = None): self.setMinimumWidth(200) self.setMaximumHeight(50) + self.label = QtGui.QLabel() + self.label.setPixmap(archive_icon) + layout = QtGui.QVBoxLayout(self) self.item_name = QtGui.QLabel(title) - #self.text_input = QtGui.QLineEdit() - self.directory_tree = QtGui.QCheckBox("Keep directory structure") - self.directory_tree.setChecked(True) + self.include_reference = QtGui.QCheckBox("Include referenced files") self.include_reference.setChecked(True) self.include_textures = QtGui.QCheckBox("Include textures") self.include_textures.setChecked(True) + + layout.addWidget(self.label) + layout.addStretch() layout.addWidget(self.item_name) - #layout.addWidget(self.text_input) - layout.addWidget(self.directory_tree) + + layout.addWidget(self.HLine()) layout.addWidget(self.include_reference) layout.addWidget(self.include_textures) @@ -182,22 +196,25 @@ def __init__(self, parent = None, title = None): layout.addWidget(buttons) def options(self): - directory_tree = False references = False textures = False - - if self.directory_tree.isChecked(): - directory_tree = True + if self.include_reference.isChecked(): references = True if self.include_textures.isChecked(): textures = True - return directory_tree, references, textures + return references, textures def result(self): return self.options() + + def HLine(self): + toto = QtGui.QFrame() + toto.setFrameShape(QtGui.QFrame.HLine) + toto.setFrameShadow(QtGui.QFrame.Sunken) + return toto class Login(QtGui.QDialog): def __init__(self, parent=None): diff --git a/icons/archive.svg b/icons/archive.svg new file mode 100644 index 0000000..1c6b0a7 --- /dev/null +++ b/icons/archive.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/pipeline.py b/pipeline.py index b434783..780ad79 100644 --- a/pipeline.py +++ b/pipeline.py @@ -4018,90 +4018,89 @@ def collect_component(self): if result == QtGui.QDialog.Accepted: # where to collect the files - collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) - collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect')) - - log.info(input) - tree = input[0] - ref = input[1] - texture = input[2] - - - #collect dependencies - - file = maya.current_open_file() - path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,file)) - files.assure_path_exists(path) - files.file_copy(file,path) - - component_dummy = pipeline_component() - pipe_file = component_dummy.get_data_file(path = file) - - if pipe_file: - component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) - - pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) - files.assure_path_exists(pipe_file_copy) - files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) - files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) - files.file_copy(pipe_file,pipe_file_copy) + collect_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory")) + if collect_path: + + collect_path = os.path.join(collect_path,'%s_%s'%(self.component.component_name,'collect')) + + log.info(input) + ref = input[0] + texture = input[1] + + + #collect dependencies - if component.thumbnail_path: - tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) - files.assure_path_exists(tumb_file_copy) - files.file_copy(component.thumbnail_path,tumb_file_copy) + file = maya.current_open_file() + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,file)) + files.assure_path_exists(path) + files.file_copy(file,path) + + component_dummy = pipeline_component() + pipe_file = component_dummy.get_data_file(path = file) + + if pipe_file: + component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) + + pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_copy) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) + files.file_copy(pipe_file,pipe_file_copy) + if component.thumbnail_path: + tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) + files.assure_path_exists(tumb_file_copy) + files.file_copy(component.thumbnail_path,tumb_file_copy) - - dependencies = maya.list_referenced_files() - for dep in dependencies: - # for texture files - if dep[1] == 'file': - filename = files.file_name(dep[0]) - path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) - files.assure_path_exists(path) - files.file_copy(dep[0],path) - + + dependencies = maya.list_referenced_files() - # for refernce files - if dep[1] == 'reference': + for dep in dependencies: + if texture: # for texture files + + if dep[1] == 'file': + filename = files.file_name(dep[0]) + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) + files.assure_path_exists(path) + files.file_copy(dep[0],path) + + if ref: # for refernce files + + if dep[1] == 'reference': - - filename = files.file_name(dep[0]) - path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) - files.assure_path_exists(path) - files.file_copy(dep[0],path) - - component_dummy = pipeline_component() - pipe_file = component_dummy.get_data_file(path = dep[0]) - - if pipe_file: - component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) + filename = files.file_name(dep[0]) + path = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,dep[0])) + files.assure_path_exists(path) + files.file_copy(dep[0],path) + + + component_dummy = pipeline_component() + pipe_file = component_dummy.get_data_file(path = dep[0]) + + if pipe_file: + component = pipeline_component(path = pipe_file, project = self.project, settings = self.settings) + + pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) + files.assure_path_exists(pipe_file_copy) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) + files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) + files.file_copy(pipe_file,pipe_file_copy) + + if component.thumbnail_path: + tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) + files.assure_path_exists(tumb_file_copy) + files.file_copy(component.thumbnail_path,tumb_file_copy) - pipe_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,pipe_file)) - files.assure_path_exists(pipe_file_copy) - files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"masters")) - files.assure_folder_exists(os.path.join(os.path.dirname(pipe_file_copy),"versions")) - files.file_copy(pipe_file,pipe_file_copy) - - if component.thumbnail_path: - tumb_file_copy = os.path.join(collect_path,files.reletive_path(self.settings.current_project_path,component.thumbnail_path)) - files.assure_path_exists(tumb_file_copy) - files.file_copy(component.thumbnail_path,tumb_file_copy) - - - fps = self.project.project_fps - padding = self.project.project_padding - file_type = self.project.project_file_type - - project_file = self.project_file = pipeline_project().create(collect_path, name = '%s_%s'%(self.component.component_name,'collect'), padding = padding, file_type = file_type, fps = fps, users = None) - # need to create a project.pipe file for this, with only the releated assets, name it after the component + collect - # create no users - - # if the function is a success, open the project folder in the finder + + fps = self.project.project_fps + padding = self.project.project_padding + file_type = self.project.project_file_type + project_file = pipeline_project().create(collect_path, name = '%s_%s'%(self.component.component_name,'collect'), padding = padding, file_type = file_type, fps = fps, users = None) + + dlg.massage("massage", "Success", "Project created successfully" )