def get_valid_users(): valid_users = [] all_users = cT.get_list_users() for user in all_users: if user.assigned_VM is not None: valid_users.append(user) return valid_users
def update_list(self): self.user_list.delete(0, tk.END) self.users = cT.get_list_users() for user in self.users: if user.isTeacher is not None: text = "{}, {}" text = text.format(user.lastName, user.firstName) self.user_list.insert(tk.END, text) self.user_list.update()
def create_multi_user(self): cs_file = self.csv_entry.get() self.deactivate_buttons() if cs_file != "": user_csv_list = [] with open(cs_file, 'r', newline='') as CSV_FILE: reader = csv.reader(CSV_FILE) next(reader) for user_list in reader: user_csv_list.append(user_list) # Sets up the progress bar self.csv_progress['maximum'] = len(user_csv_list) * 2 bar = 0 # Creates user and assigns vm for new_user in user_csv_list: if new_user: if cT.user_by_id(int(new_user[0])) is None: success = cT.create_single_user( new_user[0].strip(), new_user[1].strip(), new_user[2].strip(), new_user[3].strip()) if not success[1]: messagebox.showinfo( "Warning", "Unable to notify user {0} of their account's password." .format(new_user[0]), parent=self) bar += 1 self.csv_progress["value"] = bar self.csv_progress.update() # waits for all machines to finish loading and shuts them down for curr_user in cT.get_list_users(): if curr_user.isTeacher is False: curr_vm = cT.get_vm_object(curr_user.assigned_VM) curr_vm.is_instance_ready() curr_vm.stop_instance() bar += 1 self.csv_progress["value"] = bar self.csv_progress.update() messagebox.showinfo("Done", "Process completed.", parent=self) self.csv_progress["value"] = 0 self.csv_progress.update() else: messagebox.showinfo( "Missing Info", "You need to first load a .csv file and provide a valid AMI.", parent=self) self.clear_multi_user_fields() self.activate_buttons()
def get_valid_users(): all_users = cT.get_list_users() return all_users