def set_animation_basic_preset(self): try: animation_basic_preset = serializer.JSONSerializer( path=os.path.join(cfg.script_dir(), 'presets', 'animation_basic_preset.json')).read() except Exception: serialize_data_file = serializer.JSONSerializer().create( os.path.join(cfg.script_dir(), 'presets', 'animation_basic_preset.json'), Preset_dialog.animation_basic_preset) animation_basic_preset = serialize_data_file.read() self.populate_preset(animation_basic_preset)
def set_preset(self, preset_file): try: preset = serializer.JSONSerializer(path=preset_file).read() except Exception: logger.info("could not set preset from {}".format(preset_file)) self.populate_preset(preset)
def set_data_file(self, path): if os.path.isfile(path): self.data_file = serializer.JSONSerializer(path=path) return True else: pass
def create(self, path): projects = {} settings_data = {} settings_data["user"] = [None, None] settings_data["current_project"] = None settings_data["projects"] = projects settings_data["check_for_updates"] = True self.data_file = serializer.JSONSerializer().create( path, settings_data) self.settings_file = self.data_file.read() logger.info("Created pipeline settings file at: {}".format(path)) return self
def load_preset(self): # logger.info("load preset") def_dir = '' if self.pipeline_window: def_dir = self.pipeline_window.project.path if self.pipeline_window.project else '' # path = QtWidgets.QFileDialog.getOpenFileName(self, "Load preset file", dir = os.path.join(cfg.script_dir(), 'presets'), filter="*.json") path = inputs.FileDialog.get_file(caption='Select preset file', filter='*.json', dir=os.path.join( cfg.script_dir(), 'presets')) if path: try: logger.info("Loading preset from {}".format(path)) preset = serializer.JSONSerializer(path=path).read() self.populate_preset(preset) return True except Exception, err: logger.info(err) logger.info("Can't parse preset from {}".format(path)) return False
def save_preset(self): # logger.info("save preset") catagories_model = self.hierarchy_table_view.model() branches_model = self.components_table_view.model() cataories = list() branches = dict() if catagories_model: for cat in catagories_model.items: cataories.append({ 'name': cat.name, 'from': cat._from, 'to': cat._to, 'padding': cat._padding, 'quantity': cat._quantity, 'trailing': cat._trailing, 'step': cat._step }) if branches_model: # logger.info(branches_model.items) for br in branches_model.items: # logger.info('working on branches[{}]'.format(br._branch)) # logger.info('adding {}'.format(br.name)) # if br._branch in branches: # branches[br._branch].update({br.name: {'format': br._format}}) # else: # branches[br._branch] = {br.name: {'format': br._format}} if br._branch in branches: branches[br._branch].update({ br.name: { 'format': br._format, 'master_file_type': br._master_file_type, 'version_file_type': br._version_file_type } }) else: branches[br._branch] = { br.name: { 'format': br._format, 'master_file_type': br._master_file_type, 'version_file_type': br._version_file_type } } # logger.info('now looking like: {}'.format(branches[br._branch])) preset = dict() preset['categories'] = cataories preset['branches'] = branches # for k, v in preset.iteritems(): # logger.info(k) # if isinstance(v, list): # for x in v: # logger.info("{}".format(x)) # # if isinstance(v, dict): # for xx, vv in v.iteritems(): # logger.info("{} {}".format(xx, vv)) def_dir = '' if self.pipeline_window: def_dir = self.pipeline_window.project.path if self.pipeline_window.project else '' path = QtWidgets.QFileDialog.getSaveFileName( self, "Save preset file", dir=os.path.join( os.path.join(cfg.script_dir(), 'presets', "preset")), filter="*.json") if path[0]: try: logger.info("Saving your preset to {}".format(path[0])) serializer.JSONSerializer().create(path[0], preset, force=True) self.set_preset_menu() except Exception, err: logger.info(err) logger.info("Can't save preset to {}".format(path[0]))
def create(self, nice_name=None, path=None, padding=3, fps=25, file_type="ma", users={"0": ["Admin", "1234", "admin"]}, branches=["scenes", "assets"], playblasts_root=cfg.playblast_save_options.PROJECT_ROOT, prefix=None): file_type = "ma" project_key = serializer.id_generator() project_data = {} project_data["nice_name"] = nice_name if nice_name else self.name project_data["project_name"] = self.name project_data["project_key"] = project_key project_data["padding"] = padding project_data["fps"] = fps project_data["defult_file_type"] = file_type project_data["users"] = users project_data["playblasts_root"] = playblasts_root # project_data["prefix"] = prefix # project_data["playblast_outside"] = playblast_outside folders = [ "scenes", "assets", "images", "sourceimages", "data", "autosave", "movies", "scripts", "sound", "clips", "renderData", "cache" ] for folder in folders: # project_data[folder] = folder files.create_directory(os.path.join(path, folder)) # render folders: r_folders = ["renderData", "depth", "iprimages", "shaders"] for r_folder in r_folders[1:]: files.create_directory(os.path.join(path, r_folders[0], r_folder)) fur_folders = [ "renderData", "fur", "furFiles", "furImages", "furEqualMap", "furAttrMap", "furShadowMap" ] for f_folder in fur_folders[2:]: files.create_directory( os.path.join(path, fur_folders[0], fur_folders[1], f_folder)) # cache folders: c_folders = ["cache", "particles", "nCache", "bifrost"] for c_folder in c_folders[1:]: files.create_directory(os.path.join(path, c_folders[0], c_folder)) fl_folders = ["cache", "nCache", "fluid"] for fl_folder in fl_folders[2:]: files.create_directory( os.path.join(path, fl_folders[0], fl_folders[1], fl_folder)) self.path = path data_path = os.path.join(path, "%s.%s" % (self.name, "json")) self.data_file_path = data_path self.data_file = serializer.JSONSerializer().create( self.data_file_path, project_data) self.project_file = self.data_file.read() for branch in branches: elements.BranchNode( branch, path=os.path.join(path, branch), project=self).create(path=os.path.join(path, branch)) # elements.BranchNode("assets", path=os.path.join(path, "assets"), project = self).create(path=os.path.join(path, "assets")) if playblasts_root == cfg.playblast_save_options.PROJECT_ROOT: files.create_directory(os.path.join(path, "playblasts")) if playblasts_root == cfg.playblast_save_options.PROJECT_SISTER: try: files.create_directory( os.path.join(os.path.dirname(path), "{}_playblasts".format(self.name))) except: logger.info("Could not create Playblasts folder at: {}".format( os.path.dirname(path))) return self