def _test_get_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] filters.append( ['bin_id', bin_id] ) connectors = server.query("prod/submission_in_bin", filters) # get all of the submissions from the bin submission_ids = [x.get('submission_id') for x in connectors] filters = [ ['id', submission_ids] ] submissions = server.query("prod/submission", filters) # get all of the snapshots from the submissions for submission in submissions: search_key = submission.get('__search_key__') print "-"*20 snapshot = server.get_snapshot(search_key, include_paths=True) paths = snapshot.get('__paths__') for path in paths: print path
def execute(my): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol,setup=False) TacticServerStub.set(server) project = my.data.get("project") ticket = my.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) my.class_name = my.data.get('class_name') assert my.class_name # get the script to run script_code = my.data.get("script_code") if script_code: search_type = "config/custom_script" search_key = server.build_search_key(search_type, script_code) script_obj = server.get_by_search_key(search_key) script = script_obj.get('script') my.run_script(script) else: print "Nothing to run"
def execute(my): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol, setup=False) TacticServerStub.set(server) project = my.data.get("project") ticket = my.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) my.class_name = my.data.get('class_name') assert my.class_name my.kwargs = my.data.get('kwargs') if not my.kwargs: my.kwags = {} #trigger = eval("%s(**my.kwargs)" % my.class_name) trigger = Common.create_from_class_path(my.class_name, kwargs=my.kwargs) input_data = my.get_input_data() trigger.set_input(input_data) trigger.execute()
def execute(my): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol, setup=False) TacticServerStub.set(server) project = my.data.get("project") ticket = my.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) my.class_name = my.data.get('class_name') assert my.class_name # get the script to run script_code = my.data.get("script_code") if script_code: search_type = "config/custom_script" search_key = server.build_search_key(search_type, script_code) script_obj = server.get_by_search_key(search_key) script = script_obj.get('script') my.run_script(script) else: print "Nothing to run"
def execute(my): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol,setup=False) TacticServerStub.set(server) project = my.data.get("project") ticket = my.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) my.class_name = my.data.get('class_name') assert my.class_name my.kwargs = my.data.get('kwargs') if not my.kwargs: my.kwags = {} #trigger = eval("%s(**my.kwargs)" % my.class_name) trigger = Common.create_from_class_path(my.class_name, kwargs=my.kwargs) input_data = my.get_input_data() trigger.set_input(input_data) trigger.execute()
def _test_get_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] filters.append(['bin_id', bin_id]) connectors = server.query("prod/submission_in_bin", filters) # get all of the submissions from the bin submission_ids = [x.get('submission_id') for x in connectors] filters = [['id', submission_ids]] submissions = server.query("prod/submission", filters) # get all of the snapshots from the submissions for submission in submissions: search_key = submission.get('__search_key__') print "-" * 20 snapshot = server.get_snapshot(search_key, include_paths=True) paths = snapshot.get('__paths__') for path in paths: print path
def get_server(my): # do a query for the search from tactic_client_lib import TacticServerStub if my.protocol == 'xmlrpc': stub = TacticServerStub(setup=False, protocol=my.protocol) stub.set_server(my.host) stub.set_project(my.project_code) stub.set_ticket(my.ticket) else: stub = TacticServerStub.get() return stub
class BaseClientCbk(object): def set_ticket(self, ticket): self.ticket = ticket def set_options(self, options): self.options = options def get_option(self, name): return self.options.get(name) def _execute(self): # get the server name server_name = self.get_option("server_name") if not server_name: raise ClientCallbackException( "No [server_name] option delivered to callback") server_name = server_name[0] # get the project project_code = self.get_option("project_code") if not project_code: raise ClientCallbackException( "No [project_code] option delivered to callback") project_code = project_code[0] # the entire pipeline is run in a TacticServer Transaction from tactic_client_lib import TacticServerStub self.server = TacticServerStub() self.server.set_server(server_name) self.server.set_ticket(self.ticket) self.server.set_project(project_code) self.server.start("Pipeline checkin") try: self.execute() except Exception, e: self.server.abort() raise else:
class BaseClientCbk(object): def set_ticket(self, ticket): self.ticket = ticket def set_options(self, options): self.options = options def get_option(self, name): return self.options.get(name) def _execute(self): # get the server name server_name = self.get_option("server_name") if not server_name: raise ClientCallbackException("No [server_name] option delivered to callback") server_name = server_name[0] # get the project project_code = self.get_option("project_code") if not project_code: raise ClientCallbackException("No [project_code] option delivered to callback") project_code = project_code[0] # the entire pipeline is run in a TacticServer Transaction from tactic_client_lib import TacticServerStub self.server = TacticServerStub() self.server.set_server(server_name) self.server.set_ticket(self.ticket) self.server.set_project(project_code) self.server.start("Pipeline checkin") try: self.execute() except Exception, e: self.server.abort() raise else:
def _test_create_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] # asset parent_type = "prod/asset" parent_code = "chr001" parent_key = server.build_search_key(parent_type, parent_code) parent = server.get_by_search_key(parent_key) parent_id = parent.get('id') # create a submission data = { 'description': 'A test submission', 'artist': 'joe', 'context': 'model' } submission = server.insert("prod/submission", data, parent_key=parent_key) submission_key = submission.get('__search_key__') submission_id = submission.get('id') file_path = './miso_ramen.jpg' context = "publish" snapshot = server.simple_checkin(submission_key, context, file_path, mode="upload") # no connect to the bin with a connector data = {"bin_id": bin_id, 'submission_id': submission_id} server.insert("prod/submission_in_bin", data)
def _test_create_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] # asset parent_type = "prod/asset" parent_code = "chr001" parent_key = server.build_search_key(parent_type, parent_code) parent = server.get_by_search_key(parent_key) parent_id = parent.get('id') # create a submission data = { 'description': 'A test submission', 'artist': 'joe', 'context': 'model' } submission = server.insert("prod/submission", data, parent_key=parent_key) submission_key = submission.get('__search_key__') submission_id = submission.get('id') file_path = './miso_ramen.jpg' context = "publish" snapshot = server.simple_checkin(submission_key, context, file_path, mode="upload") # no connect to the bin with a connector data = { "bin_id": bin_id, 'submission_id': submission_id } server.insert("prod/submission_in_bin", data)
def login(self): global server from tactic_client_lib import TacticServerStub ticket_path = "c:/sthpw/etc" if os.path.exists(ticket_path) is False: os.makerdirs(ticket_path) name = self.ui.login.text() password = self.ui.password.text() ticket_files = os.listdir("c:/sthpw/etc/") ticket_file = "c:/sthpw/etc/" + name + ".tacticrc" if len(ticket_files) == 0: file_object = open(ticket_file, "w") ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "project=simpleslot" file_object.write(ticket_content) file_object.close() server = TacticServerStub(setup=0) server.login = name server.set_server("192.168.201.10") server.set_project("simpleslot") try: ticket = server.get_ticket(name, password) server.set_ticket(ticket) file_object = open(ticket_file, "w") ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "ticket=" + ticket + "\n" + "project=simpleslot" file_object.write(ticket_content) file_object.close() print "ok" except: print "error" loginWidget.close()
def saveVrayVFB(): username = os.environ.get("USERNAME") from tactic_client_lib import TacticServerStub server = TacticServerStub() #server.set_server("192.168.201.10") #server.set_project("simpleslot") ticket_files = os.listdir("c:/sthpw/etc/") ticket_file = "c:/sthpw/etc/" + username + ".tacticrc" if len(ticket_files) == 0: file_object = open(ticket_file, "w") ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "project=simpleslot" file_object.write(ticket_content) file_object.close() else: file_object = open(ticket_file) ticket_content = file_object.readlines() file_object.close() ticket = ticket_content[2].replace("ticket=", "").replace("\n", "") server.ticket = ticket server.set_server("192.168.201.10") server.set_project("simpleslot") rvname = jc.getNextFileName(1) rv_path = rvname[0] rv_filename = rvname[2] # base_scenename = rvname[1]. project_name = rvname[3][0] item_name = rvname[3][1] process = rvname[3][2] # author = rvname[3][3] # reviewVersion = rvname[3][4] project_type = rvname[3][5] item_type = rvname[3][6] if project_type == "casino": stype = "3d" elif project_type == "assets": stype = "assets" elif project_type == "shot": stype = "shot" tactic_base_path = "//Art-1405260002/d/assets/simpleslot/" src_filename = rv_path + rv_filename dst_filename = tactic_base_path + project_name + "/" + project_type + "/" + process + "/" + rv_filename if os.path.isdir(tactic_base_path + project_name + "/" + project_type + "/" + process + "/") is False: os.makedirs(tactic_base_path + project_name + "/" + project_type + "/" + process + "/") cmd = "vfbControl #saveImage \"" + src_filename + ".exr\"" MaxPlus.Core.EvalMAXScript(cmd) imageMagickCMD = "//Art-1405260002/d/assets/scripts/ImageMagick-6.9.0-6/convert.exe -quality 100 -colorspace RGB \"%s\" -colorspace sRGB \"%s\"" % ( src_filename + ".exr", src_filename + ".jpg") subprocess.call(imageMagickCMD) # deleteEXRCMD = "del \"" + src_filename + ".exr\"" # deleteEXRCMD = deleteEXRCMD.replace("/","\\") # subprocess.call(deleteEXRCMD) os.remove(src_filename + ".exr") shutil.copy2((src_filename + ".jpg"), (dst_filename + ".jpg")) expr = "@SOBJECT(simpleslot/game['name','" + project_name + "'].simpleslot/" + stype + "['name','" + item_name + "'].sthpw/task['process','" + process + "'])" task = server.eval(expr) sk = task[0].get("__search_key__") final_filename = "/mnt/hgfs/assets/simpleslot/" + project_name + "/" + project_type + "/" + process + "/" + rv_filename + ".jpg" server.simple_checkin(sk, process, final_filename, description="VRAY", mode="inplace") print "image uploaded"
import sys sys.path.append("//Art-1405260002/d/assets/client") import datetime from dateutil import parser from tactic_client_lib import TacticServerStub server = TacticServerStub(setup=False) import socket tactic_server_ip = socket.gethostbyname("vg.com") server.set_server(tactic_server_ip) server.set_project("simpleslot") ticket = server.get_ticket("admin", "chicago") server.set_ticket(ticket) #['name','combine_cf'] expr = "@SOBJECT(simpleslot/game)" games = server.eval(expr) test = [] for game in games: sk = game.get("__search_key__") code = game.get("code") name = game.get("name") print name expr = "@MAX(simpleslot/game['code','" + code + "'].sthpw/task.bid_end_date)" try: bed = server.eval(expr) bed = parser.parse(bed)
def saveRV(): username = os.environ.get("USERNAME") from tactic_client_lib import TacticServerStub server = TacticServerStub() #server.set_server("192.168.201.10") #server.set_project("simpleslot") ticket_files = os.listdir("c:/sthpw/etc/") ticket_file = "c:/sthpw/etc/" + username + ".tacticrc" if len(ticket_files) == 0: file_object = open(ticket_file, "w") ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "project=simpleslot" file_object.write(ticket_content) file_object.close() else: file_object = open(ticket_file) ticket_content = file_object.readlines() file_object.close() ticket = ticket_content[2].replace("ticket=", "").replace("\n", "") server.ticket = ticket server.set_server("192.168.201.10") server.set_project("simpleslot") rvname = jc.getNextFileName(1) rv_path = rvname[0] rv_filename = rvname[2] # base_scenename = rvname[1]. project_name = rvname[3][0] item_name = rvname[3][1] process = rvname[3][2] # author = rvname[3][3] # reviewVersion = rvname[3][4] project_type = rvname[3][5] tactic_base_path = "//Art-1405260002/d/assets/simpleslot/" if project_type == "casino": stype = "3d" elif project_type == "assets": stype = "assets" elif project_type == "shot": stype = "shot" src_filename = rv_path + rv_filename dst_filename = tactic_base_path + project_name + "/" + project_type + "/" + process + "/" + rv_filename if os.path.isdir(tactic_base_path + project_name + "/" + project_type + "/" + process + "/") is False: os.makedirs(tactic_base_path + project_name + "/" + project_type + "/" + process + "/") if cmds.intScrollBar("scrollBar", q=1, v=1) == -1: cmds.renderWindowEditor("renderView", e=1, si=1) cmds.intScrollBar("scrollBar", e=1, v=0) orig_format = mel.eval('getAttr "defaultRenderGlobals.imageFormat";') mel.eval('setAttr "defaultRenderGlobals.imageFormat" 8;') cmds.renderWindowEditor("renderView", e=1, wi=src_filename) mel.eval('setAttr "defaultRenderGlobals.imageFormat" ' + str(orig_format) + ';') shutil.copy2((src_filename + ".jpg"), (dst_filename + ".jpg")) expr = "@SOBJECT(simpleslot/game['name','" + project_name + "'].simpleslot/" + stype + "['name','" + item_name + "'].sthpw/task['process','" + process + "'])" task = server.eval(expr) sk = task[0].get("__search_key__") final_filename = "/mnt/hgfs/assets/simpleslot/" + project_name + "/" + project_type + "/" + process + "/" + rv_filename + ".jpg" server.simple_checkin(sk, process, final_filename, description="image", mode="inplace") print "image uploaded" #saveRV()
def execute(self): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol, setup=False) TacticServerStub.set(server) project = self.data.get("project") ticket = self.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) self.class_name = self.data.get('class_name') assert self.class_name self.kwargs = self.data.get('kwargs') if not self.kwargs: self.kwags = {} #trigger = eval("%s(**self.kwargs)" % self.class_name) trigger = Common.create_from_class_path(self.class_name, kwargs=self.kwargs) input_data = self.get_input_data() trigger.set_input(input_data) try: trigger.execute() info = trigger.get_info() result = info.get("result") if result is not None: # map booleans to a message if result in ['true', True]: result = 'complete' elif result in ['false', False]: result = 'revise' self.set_pipeline_status(result) self.info['result'] = result else: self.set_pipeline_status("complete") self.info['result'] = "complete" except Exception as e: #self.set_pipeline_status("error", {"error": str(e)}) self.set_pipeline_status("revise", {"error": str(e)}) import sys, traceback print("Error: ", e) # print the stacktrace tb = sys.exc_info()[2] stacktrace = traceback.format_tb(tb) stacktrace_str = "".join(stacktrace) print("-" * 50) print(stacktrace_str) print(str(e)) print("-" * 50) self.info['result'] = "error" self.info['message'] = str(e)
class Sample3dTest(unittest.TestCase): def setUp(self): pass def test_all(self): print "Running Sample3d Test" from pyasm.security import Batch from pyasm.biz import Project Batch() Project.set_project("sample3d") #self.server = TacticServerStub(protocol="local") self.server = TacticServerStub(protocol="xmlrpc") project_code = "sample3d" self.server.set_project(project_code) self.server.start("Sample3d Test") try: self._test_create_search_type() self._test_create_submission() self._test_get_submission() self._test_shot_sequence_hierarchy() self._test_query_snapshots() #self._test_performance() except Exception: self.server.abort() raise self.server.abort() #try: # self.server.query("prod/asset") #except Exception: # self.server.abort() # raise #self.server.abort() def _test_query_snapshots(self): filters = [] filters.append( ['context', 'model'] ) filters.append( ['search_type', 'prod/asset?project=sample3d'] ) snapshots = self.server.query_snapshots(filters=filters, include_paths=True) import time start = time.time() for snapshot in snapshots: print snapshot.get('__search_key__') print snapshot.get('__paths__') print "parent: ", snapshot.get('__parent__') print time.time() - start def _test_create_search_type(self): search_type = 'test' search_type_obj = self.server.create_search_type(search_type) print search_type_obj def _test_performance(self): for i in range(0,1): assets = self.server.query("prod/asset") for asset in assets: asset_key = asset.get("__search_key__") snapshots = self.server.get_all_children(asset_key,'sthpw/snapshot') #snapshot = self.server.get_snapshot(asset_key,context='model', include_paths=True) #print snapshot.get('__paths__') def _test_get_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] filters.append( ['bin_id', bin_id] ) connectors = server.query("prod/submission_in_bin", filters) # get all of the submissions from the bin submission_ids = [x.get('submission_id') for x in connectors] filters = [ ['id', submission_ids] ] submissions = server.query("prod/submission", filters) # get all of the snapshots from the submissions for submission in submissions: search_key = submission.get('__search_key__') print "-"*20 snapshot = server.get_snapshot(search_key, include_paths=True) paths = snapshot.get('__paths__') for path in paths: print path def _test_create_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] # asset parent_type = "prod/asset" parent_code = "chr001" parent_key = server.build_search_key(parent_type, parent_code) parent = server.get_by_search_key(parent_key) parent_id = parent.get('id') # create a submission data = { 'description': 'A test submission', 'artist': 'joe', 'context': 'model' } submission = server.insert("prod/submission", data, parent_key=parent_key) submission_key = submission.get('__search_key__') submission_id = submission.get('id') file_path = './miso_ramen.jpg' context = "publish" snapshot = server.simple_checkin(submission_key, context, file_path, mode="upload") # no connect to the bin with a connector data = { "bin_id": bin_id, 'submission_id': submission_id } server.insert("prod/submission_in_bin", data) def _test_shot_sequence_hierarchy(self): shot_key = "prod/shot?project=sample3d&code=RC_001_001" shot = self.server.get_by_search_key(shot_key) parent = self.server.get_parent(shot_key) self.assertEquals("RC_001", parent.get("code") )
def execute(self): #protocol = 'xmlrpc' protocol = 'local' if protocol == 'local': server = TacticServerStub.get() else: server = TacticServerStub(protocol=protocol,setup=False) TacticServerStub.set(server) project = self.data.get("project") ticket = self.data.get("ticket") assert project assert ticket server.set_server("localhost") server.set_project(project) server.set_ticket(ticket) self.class_name = self.data.get('class_name') assert self.class_name self.kwargs = self.data.get('kwargs') if not self.kwargs: self.kwags = {} #trigger = eval("%s(**self.kwargs)" % self.class_name) trigger = Common.create_from_class_path(self.class_name, kwargs=self.kwargs) input_data = self.get_input_data() trigger.set_input(input_data) try: trigger.execute() info = trigger.get_info() result = info.get("result") if result is not None: # map booleans to a message if result in ['true', True]: result = 'complete' elif result in ['false', False]: result = 'revise' self.set_pipeline_status(result) self.info['result'] = result else: self.set_pipeline_status("complete") self.info['result'] = "complete" except Exception as e: #self.set_pipeline_status("error", {"error": str(e)}) self.set_pipeline_status("revise", {"error": str(e)}) import sys,traceback print("Error: ", e) # print the stacktrace tb = sys.exc_info()[2] stacktrace = traceback.format_tb(tb) stacktrace_str = "".join(stacktrace) print("-"*50) print(stacktrace_str) print(str(e)) print("-"*50) self.info['result'] = "error" self.info['message'] = str(e)
class ExpressionApiTest(unittest.TestCase): def setUp(self): pass def test_all(self): self.server = TacticServerStub() project_code = "unittest" self.server.set_project(project_code) self.server.start("Expression Test") try: self._setup() self._test_expression() except: self.server.abort() raise else: self.server.abort() def _setup(self): city_data = { 'code': 'los_angeles' } search_type = "unittest/person" self.persons = [] for i in range(0,4): data = { 'name_first': 'person%s' % i, 'name_last': 'Test', 'city_code': 'los_angeles', 'age': '25' } person = self.server.insert(search_type, data) self.persons.append( person ) def _test_expression(self): # get the people sobjects expr = "@SOBJECT(unittest/person)" result = self.server.eval(expr) self.assertEquals(4, len(result)) self.assertEquals("los_angeles", result[0].get("city_code") ) # get a single person expr = "@SOBJECT(unittest/person)" result = self.server.eval(expr, single=True) self.assertEquals("los_angeles", result.get('city_code')) # get the first_name expr = "@GET(unittest/person.name_first)" names = self.server.eval(expr) self.assertEquals(len(names), 4) #self.assertEquals("person0", names[0]) #self.assertEquals("person1", names[1]) # count the number of people expr = "@COUNT(unittest/person)" count = self.server.eval(expr) self.assertEquals(4, count) # get the age of a person expr = "@GET(unittest/person.age)" age = self.server.eval(expr, self.persons[0], single=True) self.assertEquals(25, age) return
class ExpressionApiTest(unittest.TestCase): def setUp(self): pass def test_all(self): self.server = TacticServerStub() project_code = "unittest" self.server.set_project(project_code) self.server.start("Expression Test") try: self._setup() self._test_expression() except: self.server.abort() raise else: self.server.abort() def _setup(self): city_data = {'code': 'los_angeles'} search_type = "unittest/person" self.persons = [] for i in range(0, 4): data = { 'name_first': 'person%s' % i, 'name_last': 'Test', 'city_code': 'los_angeles', 'age': '25' } person = self.server.insert(search_type, data) self.persons.append(person) def _test_expression(self): # get the people sobjects expr = "@SOBJECT(unittest/person)" result = self.server.eval(expr) self.assertEquals(4, len(result)) self.assertEquals("los_angeles", result[0].get("city_code")) # get a single person expr = "@SOBJECT(unittest/person)" result = self.server.eval(expr, single=True) self.assertEquals("los_angeles", result.get('city_code')) # get the first_name expr = "@GET(unittest/person.name_first)" names = self.server.eval(expr) self.assertEquals(len(names), 4) #self.assertEquals("person0", names[0]) #self.assertEquals("person1", names[1]) # count the number of people expr = "@COUNT(unittest/person)" count = self.server.eval(expr) self.assertEquals(4, count) # get the age of a person expr = "@GET(unittest/person.age)" age = self.server.eval(expr, self.persons[0], single=True) self.assertEquals(25, age) return
self.listNameSnapshots = [] # Inicializando a classe que vare todo o servidor buscando caminhos de # imagens do SAM. self.imagens, self.paths, self.paths01 = TacticSearch().getPathFiles("maya") ''' Toda parte de configuracao de servidor ''' projeto_name = 'xxxx' ip_sever = 'xxx.xxx.x.xx' if projeto_name: server = TacticServerStub() server.set_server(ip_sever) server.set_project(projeto_name) print 'OK server' else: print 'server down' search_type = projeto_name + '/shot' print 'USER LOGIN: %s' % (server.get_login()) print server.build_search_type(search_type) ''' Inicializando a busca por arquvos ''' # self.nameSnapshots() def converter_jpg(self, path): # Vai converter todas as imagens que forem necessarias. converter(path)
class Sample3dTest(unittest.TestCase): def setUp(self): pass def test_all(self): print "Running Sample3d Test" from pyasm.security import Batch from pyasm.biz import Project Batch() Project.set_project("sample3d") #self.server = TacticServerStub(protocol="local") self.server = TacticServerStub(protocol="xmlrpc") project_code = "sample3d" self.server.set_project(project_code) self.server.start("Sample3d Test") try: self._test_create_search_type() self._test_create_submission() self._test_get_submission() self._test_shot_sequence_hierarchy() self._test_query_snapshots() #self._test_performance() except Exception: self.server.abort() raise self.server.abort() #try: # self.server.query("prod/asset") #except Exception: # self.server.abort() # raise #self.server.abort() def _test_query_snapshots(self): filters = [] filters.append(['context', 'model']) filters.append(['search_type', 'prod/asset?project=sample3d']) snapshots = self.server.query_snapshots(filters=filters, include_paths=True) import time start = time.time() for snapshot in snapshots: print snapshot.get('__search_key__') print snapshot.get('__paths__') print "parent: ", snapshot.get('__parent__') print time.time() - start def _test_create_search_type(self): search_type = 'test' search_type_obj = self.server.create_search_type(search_type) print search_type_obj def _test_performance(self): for i in range(0, 1): assets = self.server.query("prod/asset") for asset in assets: asset_key = asset.get("__search_key__") snapshots = self.server.get_all_children( asset_key, 'sthpw/snapshot') #snapshot = self.server.get_snapshot(asset_key,context='model', include_paths=True) #print snapshot.get('__paths__') def _test_get_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] filters.append(['bin_id', bin_id]) connectors = server.query("prod/submission_in_bin", filters) # get all of the submissions from the bin submission_ids = [x.get('submission_id') for x in connectors] filters = [['id', submission_ids]] submissions = server.query("prod/submission", filters) # get all of the snapshots from the submissions for submission in submissions: search_key = submission.get('__search_key__') print "-" * 20 snapshot = server.get_snapshot(search_key, include_paths=True) paths = snapshot.get('__paths__') for path in paths: print path def _test_create_submission(self): server = TacticServerStub() server.set_project("sample3d") # choose some arbitrary bin bin_id = 4 filters = [] # asset parent_type = "prod/asset" parent_code = "chr001" parent_key = server.build_search_key(parent_type, parent_code) parent = server.get_by_search_key(parent_key) parent_id = parent.get('id') # create a submission data = { 'description': 'A test submission', 'artist': 'joe', 'context': 'model' } submission = server.insert("prod/submission", data, parent_key=parent_key) submission_key = submission.get('__search_key__') submission_id = submission.get('id') file_path = './miso_ramen.jpg' context = "publish" snapshot = server.simple_checkin(submission_key, context, file_path, mode="upload") # no connect to the bin with a connector data = {"bin_id": bin_id, 'submission_id': submission_id} server.insert("prod/submission_in_bin", data) def _test_shot_sequence_hierarchy(self): shot_key = "prod/shot?project=sample3d&code=RC_001_001" shot = self.server.get_by_search_key(shot_key) parent = self.server.get_parent(shot_key) self.assertEquals("RC_001", parent.get("code"))