예제 #1
0
    def delete_user(self):
        curr_user = self.selected_user
        if curr_user.isTeacher is False:
            curr_vm = cT.get_vm_object(curr_user.assigned_VM)
            user_response = messagebox.askokcancel(
                "Delete", "Are you sure you want to delete this user? "
                "This will result in the irreversible deletion of the "
                "associated VM.",
                parent=self)
            if user_response is False:
                print("Canceled")

            else:
                # delete current user VM
                cT.del_vm(curr_vm)
                # delete current user
                cT.del_user(curr_user)
                # refresh the list of students
                self.update_list()

        else:
            messagebox.showinfo(
                "Warning",
                "This is a teacher and cannot be removed this way.",
                parent=self)
        self.clear_form()
예제 #2
0
 def test_save_user(self):
     new_name = "Testy"
     test_user = cT.user_by_id(self.user)
     test_user.firstName = new_name
     cT.save_user(test_user)
     mod_user = cT.user_by_id(self.user)
     self.assertEqual(mod_user.firstName, new_name)
예제 #3
0
 def toggle_suspend(self):
     if self.suspended is False:
         self.suspended = True
         self.suspend_button.config(text="Enable")
         self.suspend_button.update()
         self.selected_user.isSuspended = False
         cT.save_user(self.selected_user)
     else:
         self.suspended = False
         self.suspend_button.config(text="Suspend")
         self.suspend_button.update()
         self.selected_user.isSuspended = True
         cT.save_user(self.selected_user)
예제 #4
0
 def update_user(self):
     curr_user = self.selected_user
     curr_user.studentID = self.id_entry.get()
     curr_user.set_custom_user_name(curr_user.studentID)
     curr_user.firstName = self.fn_entry.get()
     curr_user.lastName = self.ln_entry.get()
     curr_user.eMail = self.email_entry.get()
     if self.pass_entry.get():
         curr_user.set_custom_password(self.pass_entry.get())
     cT.save_user(curr_user)
     self.update_list()
     messagebox.showinfo("Update",
                         "The user information has been updated.",
                         parent=self)
 def on_select(self, event):
     widget = event.widget
     index = widget.curselection()[0]
     self.selected_vm = cT.get_vm_object(self.user_list[index].assigned_VM)
     info = self.selected_vm.get_info()
     self.ami_out.config(
         text=info['Reservations'][0]['Instances'][0]['ImageId'])
     self.owner_out.config(text=(self.user_list[index].firstName + " " +
                                 self.user_list[index].lastName))
     self.status_out.config(
         text=info['Reservations'][0]['Instances'][0]['State']['Name'])
     self.dwn_button.config(state=tk.ACTIVE,
                            command=lambda: self.download(self.selected_vm))
     self.on_button.config(state=tk.ACTIVE,
                           command=lambda: self.power("ON"))
     self.off_button.config(state=tk.ACTIVE,
                            command=lambda: self.power("OFF"))
예제 #6
0
 def open_site(self):
     global vm
     messagebox.showinfo(
         "Warning",
         "This process may take a while. A window will open on your browser when it's ready.",
         parent=self)
     curr_user = self.selected_user
     if curr_user.assigned_VM is not None:
         vm = cT.get_vm_object(curr_user.assigned_VM)
         vm.start_instance()
         vm.is_instance_ready()
         site = "http://" + vm.get_instance_ip() + "/moodle"
         webbrowser.open(site)
     else:
         messagebox.showinfo(
             "Warning",
             "This is a teacher and does not have a VM assigned.",
             parent=self)
예제 #7
0
    def __init__(self, parent, controller):

        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self,
                         text="Teacher Interface:",
                         font=controller.title_font)
        label.grid(row=1, column=1, pady=3, padx=10, sticky=tk.W)
        self.config = cT.load_config()
        self.has_list = False

        # Management Buttons
        man_label = tk.Label(self, text="Manage", font="none 12 bold")
        man_label.grid(row=2, column=1, sticky=tk.W, padx=10)
        manage_buttons = tk.Frame(self)
        manage_buttons.grid(row=3, column=1, sticky=tk.EW, padx=10)
        self.users_button = tk.Button(
            manage_buttons,
            text="Users",
            command=lambda: self.controller.show_frame("UserManagementPage"))
        self.VM_button = tk.Button(
            manage_buttons,
            text="VMs",
            command=lambda: self.controller.show_frame("VMManagementPage"))
        self.settings_button = tk.Button(
            manage_buttons,
            text="Settings",
            command=lambda: self.controller.show_frame("SettingsPage"))
        self.VM_button.pack(side=tk.LEFT)
        self.users_button.pack(side=tk.LEFT)
        self.settings_button.pack(side=tk.LEFT)

        # Add Single Student Section
        add_label = tk.Label(self,
                             text="Add Single Student",
                             font="none 12 bold")
        add_label.grid(row=4, column=1, sticky=tk.W, pady=10, padx=10)
        id_label = tk.Label(self, text="Student ID")
        id_label.grid(row=5, column=1, sticky=tk.W, padx=10)
        em_label = tk.Label(self, text="Email")
        em_label.grid(row=5, column=2, sticky=tk.W, padx=10)
        self.id_entry = tk.Entry(self,
                                 width=20,
                                 font="none 12 bold",
                                 highlightthickness=0)
        self.id_entry.grid(row=6, column=1, padx=10, sticky=tk.W)
        self.em_entry = tk.Entry(self,
                                 width=20,
                                 font="none 12 bold",
                                 highlightthickness=0)
        self.em_entry.grid(row=6, column=2, padx=10, sticky=tk.W)
        fn_label = tk.Label(self, text="First Name")
        fn_label.grid(row=7, column=1, sticky=tk.W, padx=10)
        ln_label = tk.Label(self, text="Last Name")
        ln_label.grid(row=7, column=2, sticky=tk.W, padx=10)
        self.fn_entry = tk.Entry(self,
                                 width=20,
                                 font="none 12 bold",
                                 highlightthickness=0)
        self.fn_entry.grid(row=8, column=1, padx=10, sticky=tk.W)
        self.ln_entry = tk.Entry(self,
                                 width=20,
                                 font="none 12 bold",
                                 highlightthickness=0)
        self.ln_entry.grid(row=8, column=2, padx=10, sticky=tk.W)

        # Add Student Via CSV
        add_mul_label = tk.Label(self,
                                 text="Add Multiple",
                                 font="none 12 bold")
        add_mul_label.grid(row=10, column=1, sticky=tk.W, pady=10, padx=10)
        csv_label = tk.Label(self, text="CSV File")
        csv_label.grid(row=11, column=1, sticky=tk.W, padx=10)
        pro_label = tk.Label(self, text="Progress")
        pro_label.grid(row=11, column=2, sticky=tk.W, padx=10)
        self.csv_entry = tk.Entry(self,
                                  width=20,
                                  font="none 12 bold",
                                  highlightthickness=0)
        self.csv_entry.insert(0, "Add file via button bellow.")
        self.csv_entry.grid(row=12, column=1, sticky=tk.W, padx=10, pady=3)
        self.csv_progress = Progressbar(self,
                                        orient='horizontal',
                                        length=165,
                                        mode='determinate')
        self.csv_progress.grid(row=12, column=2, sticky=tk.W, padx=10, pady=3)
        self.add_button = tk.Button(self,
                                    text="Add",
                                    command=lambda: self.add_one_user())
        self.add_button.grid(row=9, column=2, sticky="E", padx=10, pady=3)
        self.open_button = tk.Button(self,
                                     text="File",
                                     command=lambda: self.open_file())
        self.open_button.grid(row=13, column=1, sticky="E", padx=10, pady=5)
        self.start_button = tk.Button(self,
                                      text="Start",
                                      command=lambda: self.create_multi_user())
        self.start_button.grid(row=13, column=2, sticky="E", padx=10, pady=5)

        # List of buttons for enabling and disabling
        self.buttons_list = [
            self.add_button, self.open_button, self.start_button,
            self.users_button, self.VM_button, self.settings_button
        ]
예제 #8
0
 def get_valid_users():
     all_users = cT.get_list_users()
     return all_users
 def shutdown_all(self):
     for vm_user in self.user_list:
         curr_vm = cT.get_vm_object(vm_user.assigned_VM)
         curr_vm.stop_instance()
 def power_all(self):
     for vm_user in self.user_list:
         curr_vm = cT.get_vm_object(vm_user.assigned_VM)
         curr_vm.start_instance()
예제 #11
0
 def setUp(self) -> None:
     self.user = 5879456
     self.name = "Test"
     self.last_name = "Subject"
     self.eMail = "*****@*****.**"
     cT.create_single_user(self.user, self.name, self.last_name, self.eMail)
예제 #12
0
 def test_vm_created(self):
     test_user = cT.user_by_id(self.user)
     self.assertIsNotNone(cT.get_vm_object(test_user.assigned_VM))
예제 #13
0
 def test_user_created(self):
     test_user = cT.user_by_id(self.user)
     self.assertEqual(test_user.firstName, self.name)
예제 #14
0
 def tearDown(self) -> None:
     test_user = cT.user_by_id(self.user)
     test_vm = cT.get_vm_object(test_user.assigned_VM)
     cT.del_user(test_user)
     cT.del_vm(test_vm)