def subscriptions_query(self): import collections stub = tc.server_start() all_sobjects = tc.query_tab_names(True) filters = [('login', env.Env.get_user()), ('project_code', env.Env.get_project())] subscriptions = stub.query('sthpw/subscription', filters) spl = collections.defaultdict(list) for sub in subscriptions: split = stub.split_search_key(sub['message_code']) spl[split[0]].append(split[1]) parents = collections.defaultdict(list) for key, values in spl.items(): parents[key.split('?')[0]] = \ tc.get_sobjects(sobjects_list=stub.query(key, [('code', values)]), get_snapshots=False) pprint(all_sobjects) pprint(dict(parents)) # print(stub.get_parent('cgshort/shot?project=the_pirate&code=SHOT00001')) server = tc.server_start() expr = "@GET(cgshort/shot.cgshort/scenes.code)" result = server.eval(expr) pprint(result) pprint(stub.query('cgshort/shot', [('scenes_code', 'SCENES00001')]))
def dynamic_query(self, limit=0, offset=0): filters = [] order_bys = ['timestamp desc'] columns = [] # sobjects_list = tc.server_start(project=env_inst.current_project).query(self.current_stype, filters, columns, order_bys, limit=limit, offset=offset) # print self.current_stype # print sobjects_list # print filters search_type = tc.server_start().build_search_type( self.current_stype, env_inst.current_project) # all_process = self.context_items[self.current_stype] # sobjects = tc.get_sobjects(all_process, sobjects_list) # sobjects = tc.get_sobjects_objects(sobjects_list, env_inst.current_project) sobjects = tc.get_sobjects( search_type=search_type, project_code=env_inst.current_project, filters=filters, order_bys=order_bys, limit=limit, offset=offset, include_info=False, include_snapshots=True, ) return sobjects
def start_sync_ui(self, preset_dict=None): self.show() self.sync_in_progress = True self.progress_bar.setHidden(False) self.toggle_ui(False) self.clear_queue() if not preset_dict: preset_dict = self.get_current_preset_dict() if self.sobject: self.sobject.update_snapshots() self.sync_by_pipeline(self.sobject, preset_dict) self.sync_children(self.sobject, preset_dict) self.save_last_sync_date() else: stype_sobjects, data = tc.get_sobjects( self.stype.get_code(), [], project_code=self.stype.project.get_code(), get_all_snapshots=True) for sobject in stype_sobjects.values(): self.sync_by_pipeline(sobject, preset_dict) self.sync_children(sobject, preset_dict) self.save_last_sync_date(sobject) self.download_files() self.progress_bar.setHidden(True) self.toggle_ui(True)
def check_name_uniqueness(self, data): existing = False name = data.get('name') if not name: return True search_type = self.tactic_widget.get_search_type() if not search_type and self.sobject: search_key_split = tc.split_search_key( self.sobject.get_search_key()) search_type = search_key_split.get('search_type') if name and search_type: # better version, that take parents into account parent_sobject = self.tactic_widget.get_parent_sobject() if parent_sobject: related_sobjects, info = parent_sobject.get_related_sobjects( child_stype=self.stype, parent_stype=parent_sobject.get_stype()) else: if self.sobject: if self.sobject.get_value('name'): filters = [('name', self.sobject.get_value('name'))] related_sobjects, info = tc.get_sobjects( self.stype.get_code(), filters, project_code=self.stype.get_project().get_code()) else: related_sobjects = {} else: related_sobjects = {} for related_sobject in related_sobjects.values(): if related_sobject.get_value('name') == name: existing = True if self.get_view() == 'edit': # check if we editing and leaved the same name, not warn about uniqueness if self.init_data.get('name') == name: existing = False if existing: msb = QtGui.QMessageBox( QtGui.QMessageBox.Question, 'This Name already used!', "Do you want to use this name anyway?", QtGui.QMessageBox.NoButton, self) msb.addButton("Yes", QtGui.QMessageBox.YesRole) msb.addButton("No", QtGui.QMessageBox.NoRole) msb.exec_() reply = msb.buttonRole(msb.clickedButton()) if reply == QtGui.QMessageBox.YesRole: return True elif reply == QtGui.QMessageBox.NoRole: return False return True
def dynamic_query(self, limit=0, offset=0): filters = [] order_bys = ['timestamp desc'] columns = [] sobjects_list = tc.server_start().query(self.current_stype, filters, columns, order_bys, limit=limit, offset=offset) print self.current_stype print sobjects_list print filters all_process = self.context_items[self.current_stype] sobjects = tc.get_sobjects(all_process, sobjects_list) return sobjects