def printDivider(): cmd_color_printers.printWhite( "\n" + "*" * 15 + "\t\t" + time.strftime("%Y-%m-%d %H-%M-%S", time.localtime(time.time())) + "\t\t" + "*" * 15 + "\n" )
def WriteLog(msg = '', type = logType.INFO): if msg == '': log = '\n' else: log = '[%s]%s\n'%(dateHelper.GetLocalTime(), msg) if type == logType.INFO: cmd_color_printers.printDarkGreen(log) elif type == logType.WARN: cmd_color_printers.printDarkYellow(log) elif type == logType.ERROR: cmd_color_printers.printRed(log) elif type == logType.RESULT: cmd_color_printers.printYellow(log) elif type == logType.TITLE: cmd_color_printers.printGreen(log) else: cmd_color_printers.printWhite(log) WriteToStorage(log)
for node in root[0]: if node.attrib["date"] == targetDate1 or node.attrib["date"] == targetDate2: noData = False for child in node: for child_detail in child.attrib.keys(): # if child.attrib["type"] == "go" and int(child.attrib["price"]) < 600: if child.attrib["type"] == "go": price = int(child.attrib["price"]) content = generateContent( child.attrib["name"], node.attrib["date"], child.attrib["price"], child.attrib["discount"] ) if price <= 800: cmd_color_printers.printRed(content) duration = emergencyRefreshDuration elif price <= 1000: cmd_color_printers.printYellow(content) duration = regularRefreshDuration elif price <= 1200: cmd_color_printers.printGreen(content) duration = regularRefreshDuration else: cmd_color_printers.printWhite(content) duration = regularRefreshDuration break if noData: cmd_color_printers.printDarkGray("\t\t\t暂无数据……\n\n") time.sleep(5) noData = True