def cmd_data(args): if not os.path.exists(COMO_BATTERY_FILE): puts(colored.yellow("No como database.")) else: data = read_database() title("Como Database") with indent(6, quote=' '): puts("Number of Entries: %d" % len(data)) puts("First save: " + str(data['time'][0])) puts("Last save: " + str(data['time'][-1])) timedelta = datetime.utcnow() - datetime.strptime( data['time'][0], "%Y-%m-%dT%H:%M:%S") puts("Age of Database: %s Days" % str(timedelta.days)) # History Graphs if not is_win: history = [] for element in data['capacity']: history.append(int(element)) cycles = [] for element in data['cycles']: if element: cycles.append(int(element)) else: cycles.append(element) history = [h - min(history) for h in history] cycles = [ c - min(c for c in cycles if type(c) == int) if type(c) == int else c for c in cycles ] text1 = str(spark_string(history).encode('utf-8')) text2 = str(spark_string(cycles).encode('utf-8')) warning("Capacity:") puts(text1) warning("Cycles:") puts(text2)
def cmd_info(args): title("Como Info") bat = get_battery() with indent(6, quote=' '): puts("Battery Serial: %s" % bat['serial']) puts("Max Capacity: %s" % bat['maxcap']) puts("Capacity: %s" % bat['curcap']) if is_osx or is_lin: puts("Number of cycles: %s" % bat['cycles']) puts("Design Capacity: %s" % bat['designcap']) if is_osx: puts("Mac model: %s" % subprocess.check_output( "sysctl -n hw.model", shell=True).rstrip("\n")) puts("Age of Computer: %s months" % get_age()) # puts("Temperature: %s ℃" % (int(bat['temp']) / 100.)) if is_osx or is_win: puts("Voltage: %s" % bat['voltage']) puts("Amperage: %s" % bat['amperage']) puts("Wattage: %s" % (bat['voltage'] * bat['amperage'] / 1000000.))