def verify_show_platform_fan_output(duthost, raw_output_lines): """ @summary: Verify output of `show platform fan`. Expected output is "Fan Not detected" or a table of fan status data conaining expect number of columns. """ # workaround to make this test compatible with 201911 and master if parse_version(duthost.kernel_version) > parse_version('4.9.0'): NUM_EXPECTED_COLS = 8 else: NUM_EXPECTED_COLS = 6 fans = {} pytest_assert(len(raw_output_lines) > 0, "There must be at least one line of output on '{}'".format(duthost.hostname)) if len(raw_output_lines) == 1: pytest_assert(raw_output_lines[0].encode('utf-8').strip() == "Fan Not detected", "Unexpected fan status output on '{}'".format(duthost.hostname)) else: pytest_assert(len(raw_output_lines) > 2, "There must be at least two lines of output if any fan is detected on '{}'".format(duthost.hostname)) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) field_names = util.get_fields(raw_output_lines[0], field_ranges) pytest_assert(len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns on '{}'".format(NUM_EXPECTED_COLS, duthost.hostname)) fan_num = 0 for line in raw_output_lines[2:]: field_values = util.get_fields(line, field_ranges) fans['fan' + str(fan_num)] = {} for field_index, a_field in enumerate(field_names): fans['fan' + str(fan_num)][a_field] = field_values[field_index] fan_num += 1 return fans
def register_usr(phone, r): fields = get_fields(r) for field in signup_order: if fields[field] == "": if field == 'first_name': return "Enter a name everyone will see 'name:<username>'"
def parse_chassis_module(output, expected_headers): assert len(output) > 2 f_ranges = get_field_range(output[1]) headers = get_fields(output[0], f_ranges) for header_v in expected_headers: pytest_assert(header_v in headers, "Missing header {}".format(header_v)) result = {} for a_line in output[2:]: field_val = get_fields(a_line, f_ranges) mod_idx = field_val[0] result[mod_idx] = {} cur_field = 1 for a_header in headers[1:]: result[mod_idx][a_header] = field_val[cur_field] cur_field += 1 return result
def get_form(self,obj,orm): fields=get_fields(obj,orm).values() redirf=form.Hidden(name='redirect',value='list') fields.append(redirf) f = form.Form(*fields)() defaults=dict([(i.name,i.value) for i in f.inputs]) source={} for k,v in web.input().items(): #convert integers to int values v=form.utils.intget(v) or v source[k]=v defaults.update(source) f.fill(source=defaults) return f
def scan(): filename = sys.argv[1] print (filename) caption_file = open(filename) i = 0 for line in caption_file: (id, business_id, caption) = util.get_fields(line) i += 1 if caption == '': continue if i > NLINES: break #caption = "the brown cow ran over the pathetic farmer's lovely wife" parseLine(id, business_id, caption)