Esempio n. 1
0
    def save_user_level(self, actual_level):
        self.user_levels[self.today] = actual_level

        file_manager.save_csv_dict(
            self.users_path + self.var_entorno["user_name"] + "_level.csv",
            self.user_levels)

        color.p(
            "[+] SUCCESS: Level of user " + self.var_entorno["user_name"] +
            " saved", "gre")
Esempio n. 2
0
    def delete_user(self, name):
        actual_users = self.users
        if name in actual_users:
            del actual_users[name]

            file_manager.save_csv_dict(self.users_file, actual_users)
            self.update_info()
            color.p("[+] SUCCESS: Usuario " + name + " eliminado con exito",
                    "gre")
        else:
            color.p("[-] ERROR: No existe ningun usuario con ese nombre",
                    "red")
Esempio n. 3
0
def read_csv_dict(file_name):
    data_r = {}
    try:
        with open(file_name, 'r') as f:
            reader = csv.reader(f)
            for line in reader:
                data_r[line[0]] = line[1:]

        color.p("[+] SUCCESS: reading " + file_name, "gre")
    except Exception as e:
        color.p("[-] ERROR: reading .csv : " + str(e), "red")
        exit(1)
    return data_r
Esempio n. 4
0
    def create_user(self, name, sex, age, weigth, height):
        actual_users = self.users
        if name not in actual_users:

            IMC = other_tool.calc_IMC(weigth, height)
            new_user = [sex, age, weigth, height, IMC]
            actual_users[name] = new_user

            file_manager.save_csv_dict(self.users_file, actual_users)
            self.update_info()
            color.p("[+] SUCCESS: Usuario " + name + " creado con exito",
                    "gre")

        else:
            color.p("[-] ERROR: Ya existe un usuario con ese nombre", "red")
Esempio n. 5
0
def save_csv_dict(file_name, data_dict):
    data = []

    for key, value in data_dict.items():
        tmp = [key]
        tmp.extend(value)
        data.append(tmp)

    try:
        with open(file_name, "w") as f:
            writer = csv.writer(f)
            writer.writerows(data)
        color.p("[+] SUCCESS: saving " + file_name, "gre")
    except Exception as e:
        color.p("[-] ERROR: saving .csv : " + str(e), "red")
Esempio n. 6
0
    def generate_WOD(self):
        conf.var_entorno["wod_type"] = self.combo_WODs.currentText()
        self.check_material()

        self.actual_WOD = self.WOD_tool.get_random_WOD(
            conf.var_entorno["wod_type"], conf.all_exercises,
            conf.user_history)

        wod_text = ""
        for exer in self.actual_WOD[0]:
            wod_text = wod_text + str(exer)

        self.text_wod_content.setText(wod_text)

        color.p("[*] INFO: WOD Generated ", "blu")
Esempio n. 7
0
    def addUser(self):
        global conf
        name = self.in_name.text()
        age = self.in_age.text()
        weigth = self.in_weigth.text()
        height = self.in_height.text()

        color.p("[*] INFO: Creating User -> " + name + " (" + self.sex + ")",
                "blu")

        if name in conf.users:
            color.p("[-] ERROR: User name already exists ", "red")
        else:
            conf.create_user(name, self.sex, int(age), int(weigth),
                             int(height))
            self.combo_users.addItem(name)
Esempio n. 8
0
    def start_WOD(self):

        color.p("[*] INFO: Starting WOD ", "blu")
        self.max_timer = 3
        self.timer.start(10)  #llama a la funcion timer cada X ms
Esempio n. 9
0
 def selUser(self):
     global conf
     user_sel = self.combo_users.currentText()
     conf.var_entorno["user_name"] = user_sel
     conf.update_info()
     color.p("[+] SUCCESS: User selected -> " + user_sel, "gre")