Ejemplo n.º 1
0
def printInfo(devices_id, num, test_items, stat_dict):
	x = 1
	y = 3
	mode = 'bold'
	fore = 'white'
	back = 'blue'
	fore_error = 'red'
	dev_id = devices_id[num]
	dev_stat = stat_dict[dev_id]
	string = ''

	str_dev = dev_id
	total_error = dev_stat['Total']
	if total_error > 0:
		str_dev += '[%d]' % total_error
		str_dev = myprint.useStyle(str_dev, mode, fore_error, back)
	else:
		str_dev = myprint.useStyle(str_dev, mode, fore, back)
	string += str_dev + '\t'

	for item in test_items:
		str_tmp = item
		cnt_error = dev_stat[item]
		if cnt_error > 0:
			str_tmp += '[%d]' % cnt_error
			str_tmp	= myprint.useStyle(str_tmp, mode, fore_error, back)
		else:
			str_tmp = myprint.useStyle(str_tmp, mode, fore, back)
		string += str_tmp + '\t'

	myprint.printHLine(x, y+num, myprint.terminal_width, ' ', mode, fore, back, False)
	myprint.printString(x, y+num, string)
	myprint.moveCursor(0, myprint.terminal_hight)
	sys.stdout.flush()
Ejemplo n.º 2
0
def printUnknowIP(unknow_ip, len_dev):
	mode = 'bold'
	fore = 'white'
	back = 'blue'
	x = 1
	y = len_dev + 3
	for index, info in enumerate(unknow_ip):
		string = "%s : %s" % info
		myprint.printHLine(x, y+index, myprint.terminal_width, ' ', mode, fore, back, False)
		myprint.printString(x, y+index, string, mode, fore, back, False)
	myprint.moveCursor(0, myprint.terminal_hight)
	sys.stdout.flush()
Ejemplo n.º 3
0
def printUnknowIP(unknow_ip, len_dev):
    mode = 'bold'
    fore = 'white'
    back = 'blue'
    x = 1
    y = len_dev + 3
    for index, info in enumerate(unknow_ip):
        string = "%s : %s" % info
        myprint.printHLine(x, y + index, myprint.terminal_width, ' ', mode,
                           fore, back, False)
        myprint.printString(x, y + index, string, mode, fore, back, False)
    myprint.moveCursor(0, myprint.terminal_hight)
    sys.stdout.flush()
Ejemplo n.º 4
0
def printInfo(value_left, value_right, show_other=False):
	global len_f_left_old
	global len_f_right_old
	mode = ''
	fore = ''
	back = ''
	x = 1
	y = myprint.terminal_hight - 6
	cup1_y = myprint.terminal_hight - 1
	cup2_y = myprint.terminal_hight
	string = info_template % (str(value_left), str(value_right))
	myprint.printString(x, y, string, mode, fore, back, False)
	if show_other:
		printScale(cup1_y-2)
	len_f_left_old = printCup(cup1_y, value_left, len_f_left_old, show_other)
	len_f_right_old = printCup(cup2_y, value_right, len_f_right_old, show_other)
	myprint.moveCursor(1, 4)
	sys.stdout.flush()
Ejemplo n.º 5
0
def printInfo(value_left, value_right, show_other=False):
    global len_f_left_old
    global len_f_right_old
    mode = ''
    fore = ''
    back = ''
    x = 1
    y = myprint.terminal_hight - 6
    cup1_y = myprint.terminal_hight - 1
    cup2_y = myprint.terminal_hight
    string = info_template % (str(value_left), str(value_right))
    myprint.printString(x, y, string, mode, fore, back, False)
    if show_other:
        printScale(cup1_y - 2)
    len_f_left_old = printCup(cup1_y, value_left, len_f_left_old, show_other)
    len_f_right_old = printCup(cup2_y, value_right, len_f_right_old,
                               show_other)
    myprint.moveCursor(1, 4)
    sys.stdout.flush()
Ejemplo n.º 6
0
def printInfo(dev_id, dev_info, num, state):
	mode = 'bold'
	fore = 'black'
	fore_error = 'white'
	back = 'green'
	back_error = 'red'
	back_change = 'yellow'
	x = 1
	y = 3
	if state == 1:
		back = back_change
	elif state == -1:
		fore = fore_error
		back = back_error
	myprint.printHLine(x, y+num, myprint.terminal_width, ' ', mode, fore, back, False)
	string = info_template % (str(dev_id), str(dev_info))
	myprint.printString(x, y+num, string, mode, fore, back, False)
	myprint.moveCursor(0, myprint.terminal_hight)
	sys.stdout.flush()
Ejemplo n.º 7
0
def printInfo(dev_id, dev_info, num, state):
    mode = 'bold'
    fore = 'black'
    fore_error = 'white'
    back = 'green'
    back_error = 'red'
    back_change = 'yellow'
    x = 1
    y = 3
    if state == 1:
        back = back_change
    elif state == -1:
        fore = fore_error
        back = back_error
    myprint.printHLine(x, y + num, myprint.terminal_width, ' ', mode, fore,
                       back, False)
    string = info_template % (str(dev_id), str(dev_info))
    myprint.printString(x, y + num, string, mode, fore, back, False)
    myprint.moveCursor(0, myprint.terminal_hight)
    sys.stdout.flush()
Ejemplo n.º 8
0
def printInfo_plus(devices_id, num, test_items, stat_dict, stat_dict_old):
	x = 1
	y = 3
	y_cur = y
	mode = 'bold'
	fore = 'white'
	fore_title = fore
	fore_error = 'red'
	fore_select = fore
	back = 'blue'
	back_title = 'green'
	back_error = back
	back_select = 'yellow'

	title_devid = 'DeviceID'

	num_next = num + 1
	if num >= len(devices_id)-1:
		num_next = 0

	dev_id = devices_id[num]
	dev_stat = stat_dict[dev_id]

	len_max_devid = max(len(title_devid), len(dev_id)) + 2
	list_len_max = map(lambda x: len(x)+2, test_items)
	list_len_max = [len_max_devid] + list_len_max

	str_row = '+'
	for line in list_len_max:
		str_row += '-' * line + '+'
	str_row = myprint.useStyle(str_row, mode, fore_title, back_title)

	title_list = [title_devid] + test_items
	str_title = '|'
	for field, len_max in zip(title_list, list_len_max):
		field = ' ' + str(field) + ' '
		str_title += str(field).ljust(len_max) + '|'
	str_title = myprint.useStyle(str_title, mode, fore_title, back_title)

	myprint.printString(x, y_cur, str_row)
	y_cur += 1
	myprint.printString(x, y_cur, str_title)
	y_cur += 1
	myprint.printString(x, y_cur, str_row)
	y_cur += 1

	for index, dev_id in enumerate(devices_id):
		dev_stat = stat_dict[dev_id]
		line = ''
		str_node_out = ''
		fore_cur = fore
		back_cur = back
		if index == num_next:
			str_node_out = myprint.useStyle('|', mode, fore_select, back_select)
			# str_node = myprint.useStyle('|', mode, fore_select, back_select)
			fore_cur = fore_select
			back_cur = back_select
		else:
			str_node_out = myprint.useStyle('|', mode, fore_title, back_title)
		str_node = myprint.useStyle('|', mode, fore_cur, back_cur)
		line += str_node_out

		str_tmp = ' ' + str(dev_id) + ' '
		str_tmp = str_tmp.ljust(len_max_devid)
		if dev_stat['Total'] > 0:
			str_tmp = myprint.useStyle(str_tmp, mode, fore_error, back_cur)
		else:
			str_tmp = myprint.useStyle(str_tmp, mode, fore_cur, back_cur)
		line += str_tmp + str_node

		for i, item in enumerate(test_items):
			cnt_error = dev_stat[item]
			len_max = list_len_max[i+1]
			str_tmp = ' ' + str(cnt_error) + ' '
			str_tmp = str_tmp.ljust(len_max)
			if cnt_error == 0 or (stat_dict_old[dev_id][item] == cnt_error):
			# if cnt_error > 0:
				str_tmp = myprint.useStyle(str_tmp, mode, fore_cur, back_cur)
			else:
				str_tmp = myprint.useStyle(str_tmp, mode, fore_error, back_cur)
			line += str_tmp
			if i != len(test_items)-1:
				line += str_node
		line += str_node_out
		myprint.printString(x, y_cur, line)
		y_cur += 1

	myprint.printString(x, y_cur, str_row)
	myprint.moveCursor(0, myprint.terminal_hight)
	sys.stdout.flush()