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_reset(args): if os.path.exists(COMO_BATTERY_FILE): sure = raw_input("Are you sure? this will remove everything! [y/n] ") if sure == "y": os.remove(COMO_BATTERY_FILE) info("removed database") else: warning("no como database")
def create_database(): warning("Creating ~/.como") open(COMO_BATTERY_FILE, 'w').close() return Dataset(headers=['time', 'capacity', 'cycles'])