def postprocess(self): web = get_web_container() self.files = [] self.file_types = [] self._upload_zipped_files() context = self.get_value("%s|context" % self.name) description = self.get_value("%s|description" % self.name) # let checkin take care of moving files to the lib from pyasm.checkin import FileCheckin for sobject in self.sobject_dict.keys(): files, file_types = self.sobject_dict.get(sobject) self.checkin = FileCheckin.get( sobject, files, file_types, \ context=context, snapshot_type="file" ) self.checkin.set_description(description) self.checkin.execute() # remove the files in upload area for key in self.sobject_dict.keys(): files, file_types = self.sobject_dict.get(key) for file in files: os.unlink(file)
def postprocess(my): web = get_web_container() my.files = [] my.file_types = [] my._upload_zipped_files() context = my.get_value("%s|context" % my.name) description = my.get_value("%s|description" % my.name) # let checkin take care of moving files to the lib from pyasm.checkin import FileCheckin for sobject in my.sobject_dict.keys(): files, file_types = my.sobject_dict.get(sobject) my.checkin = FileCheckin.get( sobject, files, file_types, \ context=context, snapshot_type="file" ) my.checkin.set_description(description) my.checkin.execute() # remove the files in upload area for key in my.sobject_dict.keys(): files, file_types = my.sobject_dict.get(key) for file in files: os.unlink(file)
def postprocess(my): web = get_web_container() my.files = [] my.file_types = [] if my.get_option('upload_type') == 'arbitrary': my._upload_arbitrary_files() else: my._upload_specified_files() context = my.get_value("%s|context" % my.name) subcontext = my.get_value("%s|subcontext" % my.name) if subcontext: context = '%s/%s' % (context, subcontext) description = my.get_value("%s|description" % my.name) from pyasm.widget import CheckboxWdg cb = CheckboxWdg("%s|is_revision" % my.get_input_name()) is_rev = cb.is_checked(False) # let checkin take care of moving files to the lib from pyasm.checkin import FileCheckin my.checkin = FileCheckin.get( my.sobject, my.files, my.file_types, \ context=context, snapshot_type="file" ) my.checkin.set_description(description) my.checkin.set_revision(is_rev) my.checkin.execute() my.sobjects.append(my.sobject) my.info['context'] = context my.add_description('File Publish for [%s]' % my.sobject.get_code()) # remove the files in upload area for file in my.files: if os.path.exists(file): os.unlink(file) Trigger.call(my, "email")
def execute(my): print "EXECUTING sample command" # create the render render = SearchType.create("prod/render") render.set_parent(my.prev_command.sobject) render.set_value("pipeline_code", "turntable") render.commit() Task.add_initial_tasks(render) prev_sobject = my.prev_command.sobject prev_process = "model" this_sobject = my.prev_command.sobject this_process = "turntable" # get the deliverable snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process) if not snapshot: return # once we have this snapshot, open the file and process lib_dir = snapshot.get_lib_dir() file_name = snapshot.get_name_by_type("maya") file_path = "%s/%s" % (lib_dir, file_name) f = open(file_path, 'r') lines = f.readlines() f.close() tmp_dir = Environment.get_tmp_dir() new_file_name = "whatever.new" new_file_path = "%s/%s" % (tmp_dir, new_file_name) f2 = open(new_file_path, 'wb') for i, line in enumerate(lines): line = "%s - %s" % (i, line) f2.write(line) f2.close() file_paths = [new_file_path] file_types = ['maya'] from pyasm.checkin import FileCheckin checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process) checkin.execute() my.set_event_name("task/approved") my.set_process("preprocess") my.set_pipeline_code("turntable") my.sobjects = [render] # ??? my.sobject = render my.set_as_approved()
def execute(my): print "EXECUTING sample command" # create the render render = SearchType.create("prod/render") render.set_parent(my.prev_command.sobject) render.set_value("pipeline_code", "turntable") render.commit() Task.add_initial_tasks(render) prev_sobject = my.prev_command.sobject prev_process = "model" this_sobject = my.prev_command.sobject this_process = "turntable" # get the deliverable snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process) if not snapshot: return # once we have this snapshot, open the file and process lib_dir = snapshot.get_lib_dir() file_name = snapshot.get_name_by_type("maya") file_path = "%s/%s" % (lib_dir, file_name) f = open( file_path, 'r') lines = f.readlines() f.close() tmp_dir = Environment.get_tmp_dir() new_file_name = "whatever.new" new_file_path = "%s/%s" % (tmp_dir, new_file_name) f2 = open( new_file_path, 'wb') for i, line in enumerate(lines): line = "%s - %s" % ( i,line) f2.write(line) f2.close() file_paths = [new_file_path] file_types = ['maya'] from pyasm.checkin import FileCheckin checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process) checkin.execute() my.set_event_name("task/approved") my.set_process("preprocess") my.set_pipeline_code("turntable") my.sobjects = [render] # ??? my.sobject = render my.set_as_approved()
def postprocess(self): web = get_web_container() self.files = [] self.file_types = [] if self.get_option('upload_type') == 'arbitrary': self._upload_arbitrary_files() else: self._upload_specified_files() context = self.get_value("%s|context" % self.name) subcontext = self.get_value("%s|subcontext" % self.name) if subcontext: context = '%s/%s' %(context, subcontext) description = self.get_value("%s|description" % self.name) from pyasm.widget import CheckboxWdg cb = CheckboxWdg("%s|is_revision" % self.get_input_name()) is_rev = cb.is_checked(False) # let checkin take care of moving files to the lib from pyasm.checkin import FileCheckin self.checkin = FileCheckin.get( self.sobject, self.files, self.file_types, \ context=context, snapshot_type="file" ) self.checkin.set_description(description) self.checkin.set_revision(is_rev) self.checkin.execute() self.sobjects.append(self.sobject) self.info['context'] = context self.add_description('File Publish for [%s]' %self.sobject.get_code()) # remove the files in upload area for file in self.files: if os.path.exists(file): os.unlink(file) Trigger.call(self, "email")
def postprocess(self): web = get_web_container() keys = web.get_form_keys() from pyasm.search import Transaction transaction = Transaction.get() assert transaction # first get some data based in column = self.get_value("%s|column" % self.name) if column == "": column = self.name # NOTE: why did this change? #prefix = self.get_input_name() prefix = self.get_name() context = self.get_value("%s|context" % prefix) description = self.get_value("%s|description" % prefix) field_storage = self.get_value(prefix) handoff_path = self.get_value("%s|path" % prefix ) custom_ticket = self.get_value("%s|ticket" % prefix ) from pyasm.widget import CheckboxWdg cb = CheckboxWdg("%s|is_revision" % prefix) is_rev = cb.is_checked() if handoff_path: handoff_path = handoff_path.replace("\\", "/") # This check causes issues.. Just assume it's in the upload location #if not os.path.exists(handoff_path): security = Environment.get_security() ticket = security.get_ticket_key() # in case it's supplied by widget like SimpleUploadWdg if custom_ticket: ticket = custom_ticket handoff_path = os.path.basename(handoff_path) handoff_path = Common.get_filesystem_name(handoff_path) handoff_path = "%s/upload/%s/%s" % (Environment.get_tmp_dir(), ticket, handoff_path) print "Uploaded path: ", handoff_path if not os.path.exists(handoff_path): raise Exception("Uploaded Path [%s] does not exist" % handoff_path) self.files = [handoff_path] file_types = ['main'] # create an icon icon_creator = IconCreator(handoff_path) icon_creator.execute() icon_path = icon_creator.get_web_path() if icon_path: self.files.append(icon_path) file_types.append("icon") web_path = icon_creator.get_icon_path() if web_path: self.files.append(web_path) file_types.append("web") elif field_storage != "": #else: # process and get the uploaded files upload = FileUpload() upload.set_field_storage(field_storage) upload.execute() # get files and file types self.files = upload.get_files() if not self.files: return file_types = upload.get_file_types() else: if self.get_option("file_required") == "true": err_msg = _("upload is required") raise TacticException("%s %s" % (self.name, err_msg)) else: return checkin_class = self.get_option("checkin") if checkin_class: snapshot_type = self.get_option("snapshot_type") self.checkin = Common.create_from_class_path(checkin_class, [self.sobject, self.files, file_types, context, snapshot_type]) else: from pyasm.checkin import FileCheckin self.checkin = FileCheckin.get( self.sobject, self.files, file_types, \ context=context, column=column, snapshot_type="file" ) self.sobjects.append(self.sobject) self.checkin.set_description(description) self.checkin.set_revision(is_rev) self.checkin.execute() # remove the files in upload area for file in self.files: if os.path.exists(file): os.unlink(file)
def postprocess(my): web = get_web_container() keys = web.get_form_keys() from pyasm.search import Transaction transaction = Transaction.get() assert transaction # first get some data based in column = my.get_value("%s|column" % my.name) if column == "": column = my.name # NOTE: why did this change? #prefix = my.get_input_name() prefix = my.get_name() context = my.get_value("%s|context" % prefix) description = my.get_value("%s|description" % prefix) field_storage = my.get_value(prefix) handoff_path = my.get_value("%s|path" % prefix ) custom_ticket = my.get_value("%s|ticket" % prefix ) from pyasm.widget import CheckboxWdg cb = CheckboxWdg("%s|is_revision" % prefix) is_rev = cb.is_checked() if handoff_path: handoff_path = handoff_path.replace("\\", "/") # This check causes issues.. Just assume it's in the upload location #if not os.path.exists(handoff_path): security = Environment.get_security() ticket = security.get_ticket_key() # in case it's supplied by widget like SimpleUploadWdg if custom_ticket: ticket = custom_ticket handoff_path = os.path.basename(handoff_path) handoff_path = Common.get_filesystem_name(handoff_path) handoff_path = "%s/upload/%s/%s" % (Environment.get_tmp_dir(), ticket, handoff_path) print "Uploaded path: ", handoff_path if not os.path.exists(handoff_path): raise Exception("Uploaded Path [%s] does not exist" % handoff_path) my.files = [handoff_path] file_types = ['main'] # create an icon icon_creator = IconCreator(handoff_path) icon_creator.execute() icon_path = icon_creator.get_web_path() if icon_path: my.files.append(icon_path) file_types.append("icon") web_path = icon_creator.get_icon_path() if web_path: my.files.append(web_path) file_types.append("web") elif field_storage != "": #else: # process and get the uploaded files upload = FileUpload() upload.set_field_storage(field_storage) upload.execute() # get files and file types my.files = upload.get_files() if not my.files: return file_types = upload.get_file_types() else: if my.get_option("file_required") == "true": err_msg = _("upload is required") raise TacticException("%s %s" % (my.name, err_msg)) else: return checkin_class = my.get_option("checkin") if checkin_class: snapshot_type = my.get_option("snapshot_type") my.checkin = Common.create_from_class_path(checkin_class, [my.sobject, my.files, file_types, context, snapshot_type]) else: from pyasm.checkin import FileCheckin my.checkin = FileCheckin.get( my.sobject, my.files, file_types, \ context=context, column=column, snapshot_type="file" ) my.sobjects.append(my.sobject) my.checkin.set_description(description) my.checkin.set_revision(is_rev) my.checkin.execute() # remove the files in upload area for file in my.files: if os.path.exists(file): os.unlink(file)