How to use get_configparser method in tempest

Best Python code snippet using tempest_python

config.py

Source:config.py Github

copy

Full Screen

...8CFG_PATH = "/etc/gotify/imap2gotify.toml"9__CONFIG__ = None10import libi2g11log = libi2g.get_logger()12def get_configparser(path=CFG_PATH):13 global __CONFIG__14 15 if __CONFIG__ is not None:16 return __CONFIG__17 18 # Read config file - halt script on failure19 try:20 config_file = open(path,'r+')21 except IOError:22 log.critical('configuration file is missing')23 raise24 25 config = configparser.SafeConfigParser()26 config.readfp(config_file)27 28 __CONFIG__ = config29 30 return config31 32def get_config(section=None, option=None, **kwargs):33 34 config = get_configparser()35 36 if section is None and option is None:37 return config38 39 if section is None:40 raise ValueError('Section to Query must be defined!')41 42 if section.lower() == 'rules':43 return get_rules()44 45 try:46 result = config.items(section)47 except configparser.NoSectionError:48 log.exception('no %s section in configuration file', section.upper())49 50 if option is None:51 return result52 53 try:54 result = config.get(section, option)55 except configparser.NoOptionError:56 if 'default' in kwargs:57 log.warn('no %s %s specified in configuration file, set default %s', section, option, str(kwargs['default']))58 59 result = kwargs['default']60 else:61 log.exception('no %s %s specified in configuration file', section, option)62 63 # Change Type of Result64 try:65 if 'type' in kwargs: # set type explicit66 type_kw = kwargs['type']67 else:68 if 'default' in kwargs:69 type_kw = type(kwargs['default'])70 71 result = type_kw(result)72 except:73 log.exception('%s %s setting invalid - not %s', section, option, kwargs['type'])74 75 return result76def get_rules(rule=None, option=None, **kwargs):77 78 config = get_configparser()79 80 # dictionary with rules in Configfile81 rules = {82 # predefined rules83 'debug' : { 'subject':'DEBUG', 'priority':'1' },84 'info' : { 'subject':'INFO', 'priority':'2' },85 'warning' : { 'subject':'WARNING', 'priority':'3' },86 'critical' : { 'subject':'CRITICAL', 'priority':'4' },87 'error' : { 'subject':'ERROR', 'priority':'5' },88 'fatal' : { 'subject':'FATAL', 'priority':'6' },89 }90 91 # Find sections with 'rules.name'92 for section in config.sections():...

Full Screen

Full Screen

Configuration.py

Source:Configuration.py Github

copy

Full Screen

...20 @staticmethod21 def filepath_to_config_ini():22 return Configuration._filepath_to_config_ini23 # Class methods for wrapping configparser 24 def get_configparser(self):25 """26 @fn get_configparser27 """28 config = configparser.ConfigParser()29 config.read(str(self.filepath_to_config_ini()))30 return config31 def get_alphavantage_API_key(self):32 """33 @fn get_alphavantage_API_key34 """35 return get_configparser()["Authentication"]["alphavantage_API_key"]36 def get_quandl_API_key(self):37 """38 @fn get_quandl_API_key39 """...

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 tempest 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