Best Python code snippet using tempest_python
cgwire.py
Source:cgwire.py
...49 def all_assets_for_project(self, project_name):50 project_name = fs_conf.path_mapping["project"][project_name]51 sid = Sid(project_name + '/a')52 sids = []53 project = gazu.project.get_project_by_name(get_key_project(project_name))54 assets = gazu.asset.all_assets_for_project(project)55 for asset in assets:56 asset_sid = sid.copy()57 asset_sid.name = asset.get('name')58 asset_sid.cat = gazu.asset.get_asset_type(asset.get('entity_type_id')).get('name')59 # Fix cat FS / CGW60 for cat_fs in FS.get_children(asset_sid.get_as('project')):61 if str(asset_sid.get('cat')).lower() in cat_fs.get('cat'):62 asset_sid.set('cat', cat_fs)63 asset_sid.conform()64 sids.append(asset_sid)65 return sorted(sids)66 def all_for_project(self, project_name):67 sids = self.all_assets_for_project(project_name) + self.all_shots_for_project(project_name)68 return sorted(sids)69 def all_shots_for_project(self, project_name):70 project_name = fs_conf.path_mapping["project"][project_name]71 sid = Sid(project_name + '/s')72 sids = []73 project = gazu.project.get_project_by_name(get_key_project(project_name))74 shots = gazu.shot.all_shots_for_project(project)75 for shot in shots:76 shot_sid = sid.copy()77 shot_sid.shot = shot.get('name')78 shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name')79 shot_sid.conform()80 sids.append(shot_sid)81 return sorted(sids)82 def get_all_status(self, sidParam):83 sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping84 #sid = Sid(sid.project + '/s')85 tasksAll = []86 if sid.is_shot():87 print ("Sid : " + sid.shot)88 print (sid.get_as("shot"))89 print ("Project : " + sid.project)90 shotName = sid.shot91 projectNameCGWire = ""92 for key in project_mapping["project"]:93 if (project_mapping["project"].get(key) == sid.project):94 projectNameCGWire = key95 print("nameCGWire : " + projectNameCGWire)96 #project = gazu.project.get_project_by_name(project_mapping["project"].get(projectNameCGWire))97 project = gazu.project.get_project_by_name(projectNameCGWire)98 #print (project)99 shots = gazu.shot.all_shots_for_project(project)100 for shot in shots:101 # print ('')102 # print ("Get : " + shot.get('name') + " Name : " + shotName)103 # if(shot.get('name') == shotName):104 if(shot.get('name') == "SH01"):105 shot_sid = sid.copy()106 shot_sid.shot = shot.get('name')107 tasksAll = gazu.task.all_tasks_for_shot(shot)108 # shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name')109 # shot_sid.conform()110 # print ("Shot : " + shot_sid.shot + " " + "Seq : " + shot_sid.seq)111 # sids.append(shot_sid)112 return tasksAll113 elif sid.is_asset():114 print ("Sid : " + sid.task)115 print (sid.get_as("asset"))116 print ("Project : " + sid.project)117 assetName = sid.name118 projectNameCGWire = ""119 for key in project_mapping["project"]:120 if (project_mapping["project"].get(key) == sid.project):121 projectNameCGWire = key122 print("nameCGWire : " + projectNameCGWire)123 #project = gazu.project.get_project_by_name(project_mapping["project"].get(projectNameCGWire))124 project = gazu.project.get_project_by_name(projectNameCGWire)125 #print (project)126 assets = gazu.asset.all_assets_for_project(project)127 for asset in assets:128 print ('')129 print ("Get : " + asset.get('name'))130 # if(shot.get('name') == assetName):131 if(asset.get('name') == "test_character_1"):132 asset_sid = sid.copy()133 asset_sid.shot = asset.get('name')134 tasksAll = gazu.task.all_tasks_for_asset(asset)135 print136 for t in tasksAll:137 print (t)138 # shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name')139 # shot_sid.conform()140 # print ("Shot : " + shot_sid.shot + " " + "Seq : " + shot_sid.seq)141 # sids.append(shot_sid)142 return tasksAll143 else:144 return tasksAll145 def get_status(self, sidParam):146 sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping147 #sid = Sid(sid.project + '/s')148 task_status = ''149 if sid.is_shot():150 shotName = sid.shot151 projectNameCGWire = ""152 for key in project_mapping["project"]:153 if (project_mapping["project"].get(key) == sid.project):154 projectNameCGWire = key155 project = gazu.project.get_project_by_name(projectNameCGWire)156 shots = gazu.shot.all_shots_for_project(project)157 shotFound = []158 for shot in shots:159 if(shot.get('name').lower() == shotName):160 shotFound = shot161 tasks = gazu.task.all_tasks_for_shot(shotFound)162 task = ''163 for t in tasks:164 #print (t)165 if(t.get('task_type_name').lower() == sid.task.lower()):166 task = t167 #print (t.get('task_status_name'))168 #print("Tasks status")169 pprint(gazu.task.get_task_status(task))170 task_status = gazu.task.get_task_status(task)171 return task_status['short_name']172 elif sid.is_asset():173 assetName = sid.name174 print 'asset name : ' + assetName175 # TO delete!!!!176 # assetName = "crab"177 projectNameCGWire = ""178 #print("sid.task :")179 #print(sid.task)180 for key in project_mapping["project"]:181 if (project_mapping["project"].get(key) == sid.project):182 projectNameCGWire = key183 project = gazu.project.get_project_by_name(projectNameCGWire)184 assets = gazu.asset.all_assets_for_project(project)185 assetFound = []186 for asset in assets:187 #print (asset)188 if(asset.get('name').lower() == assetName):189 assetFound = asset190 print "ASSET FOUND : " + str(assetFound)191 tasks = gazu.task.all_tasks_for_asset(assetFound)192 task = ''193 for t in tasks:194 # print (t)195 # print(t.get('task_type_name').lower() + " "+ sid.task.lower())196 if(t.get('task_type_name').lower() == sid.task.lower()):197 task = t198 #print (t.get('task_status_name'))199 #print("Tasks status : ")200 #pprint(gazu.task.get_task_status(task))201 task_status = gazu.task.get_task_status(task)202 return task_status['short_name']203 else:204 return task_status205 def set_status(self, sidParam, code_status, comment):206 sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping207 #sid = Sid(sid.project + '/s')208 task_status = ''209 if sid.is_shot():210 shotName = sid.shot211 # TO Delete212 # shotName = "sh01"213 projectNameCGWire = ""214 for key in project_mapping["project"]:215 if (project_mapping["project"].get(key) == sid.project):216 projectNameCGWire = key217 project = gazu.project.get_project_by_name(projectNameCGWire)218 shots = gazu.shot.all_shots_for_project(project)219 shotFound = []220 for shot in shots:221 #print (shot)222 if(shot.get('name').lower() == shotName):223 shotFound = shot224 tasks = gazu.task.all_tasks_for_shot(shotFound)225 task = ''226 for t in tasks:227 #print (t)228 if(t.get('task_type_name').lower() == sid.task.lower()):229 task = t230 #print (t.get('task_status_name'))231 # print("Tasks status")232 # pprint(gazu.task.get_task_status(task))233 task_status = gazu.task.get_task_status(task)234 gazu.task.add_comment(task, gazu.task.get_task_status_by_short_name(code_status), comment)235 elif sid.is_asset():236 assetName = sid.name237 # TO delete!!!!238 # assetName = "test_character_1"239 projectNameCGWire = ""240 # print("sid.task :")241 # print(sid.task)242 for key in project_mapping["project"]:243 if (project_mapping["project"].get(key) == sid.project):244 projectNameCGWire = key245 project = gazu.project.get_project_by_name(projectNameCGWire)246 assets = gazu.asset.all_assets_for_project(project)247 assetFound = []248 for asset in assets:249 # print (asset)250 if(asset.get('name').lower() == assetName):251 assetFound = asset252 tasks = gazu.task.all_tasks_for_asset(assetFound)253 task = ''254 for t in tasks:255 # print (t)256 # print(t.get('task_type_name').lower() + " "+ sid.task.lower())257 if(t.get('task_type_name').lower() == sid.task.lower()):258 task = t259 # print (t.get('task_status_name'))...
vistors.py
Source:vistors.py
...5from bidong.storage.models import AP, Online, Projects6fake = faker.Factory.create()7host_project = '20170905'8vistor_project = '20170904æµè¯'9def get_project_by_name(name):10 rv = session.query(Projects.id).filter_by(name=name).first()11 return rv.id if rv else 012def load():13 host_id = get_project_by_name(host_project)14 vistor_id = get_project_by_name(vistor_project)15 if not host_id or not vistor_id:16 print("error! project not exists")17 return18 print("Get Host=> %s, Guest=> %s" % (host_id, vistor_id))19 rv = session.query(AP.mac).filter_by(pn=host_id).first()20 if not rv:21 print("AP NOT FOUND")22 return23 ap_mac = rv.mac24 rvs = session.query(Account.user, AccountProfile.account_id).filter(25 Account.id == AccountProfile.account_id,26 AccountProfile.pn == vistor_id27 ).all()28 rvs = [rv for rv in rvs]...
project_service.py
Source:project_service.py
1from pytheas.data.projects import Project2import urllib.parse3def get_project_names():4 return [p.project_name for p in Project.objects()]5def get_project_by_name(project_name):6 return Project.objects(project_name=project_name).first()7def get_project_by_url_name(project_name_url):8 return Project.objects(project_name=urllib.parse.unquote_plus(project_name_url))9def get_project_details(project_name):10 project = get_project_by_name(project_name)11 return {12 'name': project.project_name,13 'description': project.description,14 'start_date': project.start_date,15 'end_date': project.end_date,16 'name_url': urllib.parse.quote_plus(project.project_name),17 }18def get_subprojects(project_name):19 project = get_project_by_name(project_name)20 return [21 {'name': subproject,22 'name_url': urllib.parse.quote_plus(subproject)23 } for subproject in project.subprojects...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!