How to use _read_warnings method in autotest

Best Python code snippet using autotest_python

schedule_item.py

Source:schedule_item.py Github

copy

Full Screen

...132 parsed_response = ET.fromstring(resp)133 return cls.from_element(parsed_response, ns)134 @classmethod135 def from_element(cls, parsed_response, ns):136 warnings = cls._read_warnings(parsed_response, ns)137 all_schedule_items = []138 all_schedule_xml = parsed_response.findall('.//t:schedule', namespaces=ns)139 for schedule_xml in all_schedule_xml:140 (id_, name, state, created_at, updated_at, schedule_type, next_run_at,141 end_schedule_at, execution_order, priority, interval_item) = cls._parse_element(schedule_xml, ns)142 schedule_item = cls(name, priority, schedule_type, execution_order, interval_item)143 schedule_item._set_values(id_=id_,144 name=None,145 state=state,146 created_at=created_at,147 updated_at=updated_at,148 schedule_type=None,149 next_run_at=next_run_at,150 end_schedule_at=end_schedule_at,151 execution_order=None,152 priority=None,153 interval_item=None,154 warnings=warnings)155 all_schedule_items.append(schedule_item)156 return all_schedule_items157 @staticmethod158 def _parse_interval_item(parsed_response, frequency, ns):159 start_time = parsed_response.get("start", None)160 start_time = datetime.strptime(start_time, "%H:%M:%S").time()161 end_time = parsed_response.get("end", None)162 if end_time is not None:163 end_time = datetime.strptime(end_time, "%H:%M:%S").time()164 interval_elems = parsed_response.findall(".//t:intervals/t:interval", namespaces=ns)165 interval = []166 for interval_elem in interval_elems:167 interval.extend(interval_elem.attrib.items())168 if frequency == IntervalItem.Frequency.Daily:169 return DailyInterval(start_time)170 if frequency == IntervalItem.Frequency.Hourly:171 interval_occurrence, interval_value = interval.pop()172 # We use fractional hours for the two minute-based intervals.173 # Need to convert to hours from minutes here174 if interval_occurrence == IntervalItem.Occurrence.Minutes:175 interval_value = float(interval_value) / 60176 return HourlyInterval(start_time, end_time, interval_value)177 if frequency == IntervalItem.Frequency.Weekly:178 interval_values = [i[1] for i in interval]179 return WeeklyInterval(start_time, *interval_values)180 if frequency == IntervalItem.Frequency.Monthly:181 interval_occurrence, interval_value = interval.pop()182 return MonthlyInterval(start_time, interval_value)183 @staticmethod184 def _parse_element(schedule_xml, ns):185 id = schedule_xml.get('id', None)186 name = schedule_xml.get('name', None)187 state = schedule_xml.get('state', None)188 created_at = parse_datetime(schedule_xml.get('createdAt', None))189 updated_at = parse_datetime(schedule_xml.get('updatedAt', None))190 schedule_type = schedule_xml.get('type', None)191 frequency = schedule_xml.get('frequency', None)192 next_run_at = parse_datetime(schedule_xml.get('nextRunAt', None))193 end_schedule_at = parse_datetime(schedule_xml.get('endScheduleAt', None))194 execution_order = schedule_xml.get('executionOrder', None)195 priority = schedule_xml.get('priority', None)196 if priority:197 priority = int(priority)198 interval_item = None199 frequency_detail_elem = schedule_xml.find('.//t:frequencyDetails', namespaces=ns)200 if frequency_detail_elem is not None:201 interval_item = ScheduleItem._parse_interval_item(frequency_detail_elem, frequency, ns)202 return id, name, state, created_at, updated_at, schedule_type, \203 next_run_at, end_schedule_at, execution_order, priority, interval_item204 @staticmethod205 def parse_add_to_schedule_response(response, ns):206 parsed_response = ET.fromstring(response.content)207 warnings = ScheduleItem._read_warnings(parsed_response, ns)208 all_task_xml = parsed_response.findall('.//t:task', namespaces=ns)209 error = "Status {}: {}".format(response.status_code, response.reason) \210 if response.status_code < 200 or response.status_code >= 300 else None211 task_created = len(all_task_xml) > 0212 return error, warnings, task_created213 @staticmethod214 def _read_warnings(parsed_response, ns):215 all_warning_xml = parsed_response.findall('.//t:warning', namespaces=ns)216 warnings = list() if len(all_warning_xml) > 0 else None217 for warning_xml in all_warning_xml:218 warnings.append(warning_xml.get('message', None))...

Full Screen

Full Screen

K2450_Config.py

Source:K2450_Config.py Github

copy

Full Screen

1"""2A Configuration Class for the Keithley 2450 sequenced load3written by markus(a)schrodt.at4LICENSE: GPL-3.0-or-later5"""67import configparser8import logging91011class K2450_Config(object):12 def __init__(self):13 self.visa_address = ""14 self.file_name = ""15 self.time_step = 0.116 self.invert = False17 self.auto_zero = False18 self.auto_delay = True19 self.manual_delay = 0.00120 self.uvlo_enable = False21 self.uvlo_voltage = 0.122 self.protect_voltage = 223 self.protect_enable = True24 self.limit_voltage = 525 self.source_range = 126 self.auto_source_range = True27 self.four_wire = False28 self.meas_range = 20029 self.auto_meas_range = False30 self.nplc = 0.0131 self.auto_nplc = True32 self.beep = False33 self.assure_timing = False34 self.initial_delay = 135 self._read_warnings = 03637 def save_file(self, filename):38 config = configparser.ConfigParser()39 config['INTERFACE']= {'visa address': self.visa_address}4041 config['FILE'] = {'file name': self.file_name,42 'time step sec': self.time_step,43 'invert': self.invert}4445 config['SOURCE'] = {'auto zero': self.auto_zero,46 'auto delay': self.auto_delay,47 'manual delay sec': self.manual_delay,48 'uvlo enable': self.uvlo_enable,49 'uvlo voltage': self.uvlo_voltage,50 'protect voltage': self.protect_voltage,51 'protect enable': self.protect_enable,52 'limit voltage': self.limit_voltage,53 'source range': self.source_range,54 'auto source range': self.auto_source_range}5556 config['MEASURE'] = {'four wire': self.four_wire,57 'measurement range': self.meas_range,58 'auto measurement range': self.auto_meas_range,59 'nplc': self.nplc,60 'auto nplc': self.auto_nplc,61 'initial delay': self.initial_delay}6263 config['MISC'] = {'beep': self.beep,64 'assure timing': self.assure_timing}6566 with open(filename, 'w') as configfile:67 config.write(configfile)6869 def make_protect_string(self,value):70 if value is None:71 return 'None'72 else:73 return str(value)7475 def load_file(self, filename):76 config = configparser.ConfigParser()77 try:78 config.read(filename)79 self._read_warnings = 08081 try:82 self.visa_address = config['INTERFACE'].get('visa address', fallback=self.visa_address)83 except:84 self._read_warnings += 18586 try:87 self.file_name = config['FILE'].get('file name', fallback=self.file_name)88 except:89 self._read_warnings += 19091 try:92 self.time_step = config['FILE'].getfloat('time step sec', fallback=self.time_step)93 except:94 self._read_warnings += 19596 try:97 self.invert = config['FILE'].getboolean('invert', fallback=self.invert)98 except:99 self._read_warnings += 1100101 try:102 self.auto_zero = config['SOURCE'].getboolean('auto zero', fallback=self.auto_zero)103 except:104 self._read_warnings += 1105106 try:107 self.auto_delay = config['SOURCE'].getboolean('auto delay', fallback=self.auto_delay)108 except:109 self._read_warnings += 1110111 try:112 self.manual_delay = config['SOURCE'].getfloat('manual delay sec', fallback=self.manual_delay)113 except:114 self._read_warnings += 1115116 try:117 self.uvlo_enable = config['SOURCE'].getboolean('uvlo enable', fallback=self.uvlo_enable)118 except:119 self._read_warnings += 1120121 try:122 self.uvlo_voltage = config['SOURCE'].getfloat('uvlo voltage', fallback=self.uvlo_voltage)123 except:124 self._read_warnings += 1125126 try:127 self.protect_voltage = config['SOURCE'].getfloat('protect voltage', fallback=self.protect_voltage)128 except:129 self._read_warnings += 1130131 try:132 self.protect_enable = config['SOURCE'].getboolean('protect enable', fallback=self.protect_enable)133 except:134 self._read_warnings += 1135136 try:137 self.limit_voltage = config['SOURCE'].getfloat('limit voltage', fallback=self.limit_voltage)138 except:139 self._read_warnings += 1140141 try:142 self.four_wire = config['MEASURE'].getboolean('four wire', fallback=self.four_wire)143 except:144 self._read_warnings += 1145146 try:147 self.meas_range = config['MEASURE'].getfloat('measurement range', fallback=self.meas_range)148 except:149 self._read_warnings += 1150151 try:152 self.auto_meas_range = config['MEASURE'].getboolean('auto measurement range', fallback=self.auto_meas_range)153 except:154 self._read_warnings += 1155156 try:157 self.source_range = config['SOURCE'].getfloat('source range', fallback=self.source_range)158 except:159 self._read_warnings += 1160161 try:162 self.auto_source_range = config['SOURCE'].getboolean('auto source range', fallback=self.auto_source_range)163 except:164 self._read_warnings += 1165166 try:167 self.nplc = config['SOURCE'].getfloat('nplc', fallback=self.nplc)168 except:169 self._read_warnings += 1170171 try:172 self.auto_nplc = config['MEASURE'].getboolean('auto nplc', fallback=self.auto_nplc)173 except:174 self._read_warnings += 1175176 try:177 self.initial_delay = config['MEASURE'].getfloat('initial delay', fallback=self.initial_delay)178 except:179 self._read_warnings += 1180181 try:182 self.beep = config['MISC'].getboolean('beep', fallback=self.beep)183 except:184 self._read_warnings += 1185186 try:187 self.assure_timing = config['MISC'].getboolean('check timing', fallback=self.assure_timing)188 except:189 self._read_warnings += 1190191 logging.info('K2450 Cfg: config read')192 if self._read_warnings > 0:193 logging.warning('K2450 Cfg: %d read error(s)' % self._read_warnings)194195 except:196 logging.error('K2450 Cfg: could not read config')197198199if __name__ == '__main__':200 smu_cfg = K2450_Config()201 smu_cfg.load_file('test.ini')202 print(smu_cfg.visa_address) ...

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