import struct DEBUG = False class bcolors: GREY = '\033[90m' ORANGE = '\033[91m' GREEN = '\033[92m' YELLOW = '\033[93m' BLUE = '\033[94m' PURPLE = '\033[95m' CYAN = '\033[96m' WHITE = '\033[97m' DEFAULT = '\033[99m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' def print_data(name, data, length = None, color = bcolors.DEFAULT): if not DEBUG: return if data == None or not len(data): return if length == None: length = len(data) print color + name, for c in data[:length]: print "0x%02X"%(ord(c)), print bcolors.ENDC def print_debug(str): if not DEBUG: return print str