How to use __get method in yandex-tank

Best Python code snippet using yandex-tank

gtr2.py

Source:gtr2.py Github

copy

Full Screen

...48 new_d[self.__camel_to_underscore(k)] = new_list49 else:50 new_d[self.__camel_to_underscore(k)] = self.__convert_dates(v)51 return new_d52 def __get(self, method: str, params: Dict = {}) -> Dict:53 url = self.__url + method54 if self.__debug:55 print("|- Query:", url)56 print("|- Params:", params)57 request_params = {}58 key_conversions = {59 "query": "q",60 "page": "p",61 "page_size": "s",62 "sort": "so",63 "search_fields": "f",64 "sort_fields": "sf",65 }66 for k, v in key_conversions.items():67 if k in params:68 request_params[v] = params[k]69 if self.__debug:70 print("|- Request Query:", request_params)71 headers = {72 "Content-Type": "application/json",73 "Accept": "application/vnd.rcuk.gtr.json-v7",74 }75 r = requests.get(url, headers=headers, params=request_params, timeout=5)76 if r.ok:77 return self.__convert_json(r.json())78 else:79 print("|- ", r.status_code)80 raise Exception("|- Error with request")81 def schema(self, item: str):82 url = self.__url + "/" + item83 headers = {"Accept": "application/vnd.rcuk.gtr.xml-v7"}84 r = requests.get(url, headers=headers, timeout=5)85 if not r.ok:86 print("|- ", r.status_code)87 raise Exception("|- Error with request")88 return r.text89 ### Get Objects Methods90 def people(self, query: PeopleQuery = {}) -> PeopleResponse:91 """92 Search the people on Gateway to Research.93 ```94 from gtr import GtR2Client95 from pprint import pprint96 gtr = GtR2Client()97 people = gtr.people()98 pprint(people, depth=2)99 ```100 """101 return self.__get("/persons", query)102 def projects(self, query: ProjectsQuery = {}) -> ProjectsResponse:103 """104 Search the projects on Gateway to Research.105 ```106 from gtr import GtR2Client, ProjectsQuery107 from pprint import pprint108 gtr = GtR2Client()109 query: ProjectsQuery = {110 "page_size": 10, 111 "query": "manufacturing"112 }113 projects = gtr.projects(query)114 pprint(projects, depth=2)115 ```116 """117 return self.__get("/projects", query)118 def organisations(self, query: OrganisationsQuery = {}) -> OrganisationsResponse:119 return self.__get("/organisations", query)120 def funds(self, query: FundsQuery = {}) -> FundsResponse:121 return self.__get("/funds", query)122 def outcomes(self, query: OutcomesQuery = {}) -> OutcomesResponse:123 return self.__get("/outcomes", query)124 def keyfindings(self, query: OutcomesQuery = {}) -> KeyFindingsResponse:125 return self.__get("/outcomes/keyfindings", query)126 def impactsummaries(self, query: OutcomesQuery = {}) -> ImpactSummariesResponse:127 return self.__get("/outcomes/impactsummaries", query)128 def publications(self, query: OutcomesQuery = {}) -> PublicationsResponse:129 return self.__get("/outcomes/publications", query)130 def collaborations(self, query: OutcomesQuery = {}) -> CollaborationsResponse:131 return self.__get("/outcomes/collaborations", query)132 def intellectual_properties(133 self, query: OutcomesQuery = {}134 ) -> IntellectualPropertiesResponse:135 return self.__get("/outcomes/intellectualproperties", query)136 def policy_influences(self, query: OutcomesQuery = {}) -> PolicyInfluencesResponse:137 return self.__get("/outcomes/policyinfluences", query)138 def products(self, query: OutcomesQuery = {}) -> ProductsResponse:139 return self.__get("/outcomes/products", query)140 def research_materials(141 self, query: OutcomesQuery = {}142 ) -> ResearchMaterialsResponse:143 return self.__get("/outcomes/research_materials", query)144 def spin_outs(self, query: OutcomesQuery = {}) -> SpinOutResponse:145 return self.__get("/outcomes/spinouts", query)146 def further_fundings(self, query: OutcomesQuery = {}) -> FurtherFundingsResponse:147 return self.__get("/outcomes/furtherfundings", query)148 def disseminations(self, query: OutcomesQuery = {}) -> DisseminationsResponse:149 return self.__get("/outcomes/disseminations", query)150 ### Get Object methods151 def person(self, id: str) -> Person:152 return self.__get("/persons/" + id)153 def project(self, id: str) -> Project:154 return self.__get("/project/" + id)155 def organisation(self, id: str) -> Organisation:156 return self.__get("/organisations/" + id)157 def fund(self, id: str) -> Fund:158 return self.__get("/funds/" + id)159 def key_finding(self, id: str) -> Person:160 return self.__get("/keyfindings/" + id)161 def impact_summary(self, id: str) -> ImpactSummary:162 return self.__get("/impactsummaries/" + id)163 def publication(self, id: str) -> Publication:164 return self.__get("/publication/" + id)165 def collaboration(self, id: str) -> Collaboration:166 return self.__get("/collaboration/" + id)167 def intellectual_propety(self, id: str) -> IntellectualProperty:168 return self.__get("/intellectualproperties/" + id)169 def policy_influence(self, id: str) -> PolicyInfluence:170 return self.__get("/policyinfluences/" + id)171 def product(self, id: str) -> Product:172 return self.__get("/products/" + id)173 def research_material(self, id: str) -> ResearchMaterial:174 return self.__get("/researchmaterials/" + id)175 def spin_out(self, id: str) -> SpinOut:176 return self.__get("/spinouts/" + id)177 def further_funding(self, id: str) -> FurtherFunding:178 return self.__get("/furtherfundings/" + id)179 def dissemination(self, id: str) -> Dissemination:180 return self.__get("/disseminations/" + id)181 ## Get Associated Object Methods182 def person_projects(self, id: str) -> ProjectsResponse:183 return self.__get("/persons/" + id + "/projects")184 def person_organisations(self, id: str) -> OrganisationsResponse:185 return self.__get("/persons/" + id + "/organisations")186 def project_organisations(self, id: str) -> OrganisationsResponse:187 return self.__get("/projects/" + id + "/organisations")188 def project_persons(self, id: str) -> PeopleResponse:189 return self.__get("/projects/" + id + "/persons")190 def project_funds(self, id: str) -> FundsResponse:191 return self.__get("/projects/" + id + "/funds")192 def project_outcomes(self, id: str) -> OutcomesResponse:193 return self.__get("/projects/" + id + "/outcomes")194 def project_key_findings(self, id: str) -> KeyFindingsResponse:195 return self.__get("/projects/" + id + "/outcomes/keyfindings")196 def project_impact_summaries(self, id: str) -> ImpactSummariesResponse:197 return self.__get("/projects/" + id + "/outcomes/impactsummaries")198 def project_publications(self, id: str) -> PublicationsResponse:199 return self.__get("/projects/" + id + "/outcomes/publications")200 def project_collaborations(self, id: str) -> CollaborationsResponse:201 return self.__get("/projects/" + id + "/outcomes/collaborations")202 def project_intellectual_properties(203 self, id: str204 ) -> IntellectualPropertiesResponse:205 return self.__get("/projects/" + id + "/outcomes/intellectualproperties")206 def project_products(self, id: str) -> ProductsResponse:207 return self.__get("/projects/" + id + "/outcomes/products")208 def project_research_materials(self, id: str) -> ResearchMaterialsResponse:209 return self.__get("/projects/" + id + "/outcomes/researchmaterials")210 def project_spin_outs(self, id: str) -> SpinOutResponse:211 return self.__get("/projects/" + id + "/outcomes/spinouts")212 def project_disseminations(self, id: str) -> DisseminationsResponse:...

Full Screen

Full Screen

lang.py

Source:lang.py Github

copy

Full Screen

...17 def __init__(self, lang_dir, lang):18 self.lang_dir = lang_dir19 self.lang = configparser.ConfigParser()20 self.lang.read(os.path.join(self.lang_dir, lang + ".ini"), encoding="utf8")21 self.lang_name = self.__get("Header", "name")22 self.lang_code = self.__get("Header", "code")23 def get_language_list(self):24 """Get a list of language files present"""25 __lang = configparser.ConfigParser()26 # Only scan the folder if there is not already a list of languages27 if not self.__languages:28 for file in os.listdir(os.path.join(self.lang_dir)):29 # The language code is the file name30 code = os.path.splitext(os.path.basename(file))[0]31 # Load the language file to get the name32 __lang.read(os.path.join(self.lang_dir, code + ".ini"), encoding="utf8") #cp125033 name = __lang.get("Header", "name", fallback=None)34 # Only append the language if a code and name were found35 if code and name:36 self.__languages.append((code, name))37 # Return the list of languages38 return self.__languages39 def __get(self, section, key, *args):40 key = str(key)41 string = self.lang.get(section, key, fallback="<{0}:{1} not found>".format(section, key))42 return string.format(*args)43 def act_check_updates(self):44 return self.__get("Action", "1")45 def act_launch_mod(self, module_name):46 return self.__get("Action", "2", module_name)47 def act_select_module_dir(self):48 return self.__get("Action", "3")49 def act_open_mod_dir(self):50 return self.__get("Action", "4")51 def act_exit(self):52 return self.__get("Action", "5")53 def act_install(self, path):54 return self.__get("Action", "6", path)55 def act_install_custom(self):56 return self.__get("Action", "7")57 def act_about(self):58 return self.__get("Action", "8")59 def men_file(self):60 return self.__get("Menu", "1")61 def men_language(self):62 return self.__get("Menu", "2")63 def men_channel(self):64 return self.__get("Menu", "3")65 def men_debug(self):66 return self.__get("Menu", "4")67 def men_help(self):68 return self.__get("Menu", "5")69 def sta_ready(self):70 return self.__get("Status", "1")71 def sta_waiting_on_user(self):72 return self.__get("Status", "2")73 def sta_error_hash(self):74 return self.__get("Status", "3")75 def sta_checking_version(self):76 return self.__get("Status", "4")77 def sta_checking_files(self):78 return self.__get("Status", "5")79 def sta_already_updated(self):80 return self.__get("Status", "6")81 def sta_download_progress(self, files_completed, files_total):82 return self.__get("Status", "7", files_completed, files_total)83 def sta_download_complete(self, files_downloaded):84 return self.__get("Status", "8", files_downloaded)85 def sta_lang_changed(self):86 return self.__get("Status", "9", self.lang_name)87 def tex_about(self, module_name, updater_version):88 return self.__get("Text", "1", module_name, updater_version, module_name)89 def tex_version_available(self, module_name, module_version):90 return self.__get("Text", "2", module_name, module_version)91 def tex_error_download(self, error_count):92 return self.__get("Text", "7", error_count)93 def tex_error_hash(self):94 return self.__get("Text", "3")95 def tex_enter_password(self):96 return self.__get("Text", "4")97 def tex_select_directory(self):98 return self.__get("Text", "5")99 def tex_self_update(self, new_version):100 return self.__get("Text", "8", new_version)101 def tex_invalid_directory(self):102 return self.__get("Text", "6")103 def title_normal(self, module_name):104 return self.__get("Title", "1", module_name)105 def title_about(self, module_name):106 return self.__get("Title", "2", module_name)107 def title_error(self, module_name):108 return self.__get("Title", "3", module_name)109 def title_updates(self, module_name):110 return self.__get("Title", "4", module_name)111 def title_auth(self, module_name):...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...10 elif setting.value_type == 'int':11 return int(setting.value)12 elif setting.value_type == 'bool':13 return setting.value.lower() == 'true'14def __get(key, default=None):15 setting = Setting.query.filter_by(key=key).first()16 if setting:17 return get_setting_value(setting)18 else:19 return default20def contains_id(setting_id):21 return Setting.query.filter_by(id=setting_id).count() > 022def update_setting(setting_id, key, name, value, value_type='text'):23 if setting_id and contains_id(setting_id):24 Setting.query.filter_by(id=setting_id).update({'name': name, 'value': value, 'value_type': value_type})25 else:26 setting = Setting(key, name, value, value_type)27 db.session.add(setting)28 db.session.commit()29def update_setting_by_key(key, value):30 Setting.query.filter_by(key=key).update({'value': value})31 db.session.commit()32def all_settings():33 return Setting.query.filter(Setting.name != '').all()34def get_port():35 return __get('port', 65432)36def get_address():37 return __get('address', '0.0.0.0')38def get_cert_file():39 return __get('cert_file', '')40def get_key_file():41 return __get('key_file', '')42def get_login_title():43 return __get('login_title', 'Sign in')44def get_v2_config_path():45 return __get('v2_config_path', '/etc/v2ray/config.json')46def get_v2_restart_cmd():47 return __get('v2_restart_cmd', 'systemctl restart v2ray')48def get_v2_stop_cmd():49 return __get('v2_stop_cmd', 'systemctl stop v2ray')50def get_v2_start_cmd():51 return __get('v2_start_cmd', 'systemctl start v2ray')52def get_v2_config_check_interval():53 return __get('v2_config_check_interval', 10)54def get_v2_template_config():55 return __get('v2_template_config')56def get_traffic_job_interval():57 return __get('traffic_job_interval', 30)58def get_base_path():59 return __get('base_path', '')60def get_v2ctl_cmd_path():61 return __get('v2ctl_cmd_path', '/usr/bin/v2ray/v2ctl')62def get_secret_key():63 return __get('secret_key', os.urandom(24))64def get_current_version():65 return '5.2.1'66def add_if_not_exist(setting, update=False):67 if Setting.query.filter_by(key=setting.key).count() > 0:68 if update:69 Setting.query.filter_by(key=setting.key).update({70 'name': setting.name,71 'value': setting.value,72 'value_type': setting.value_type,73 })74 return75 db.session.add(setting)76def reset_config():77 init_db(True)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful