def afterDownloadResponse(self): if self.downloadResponse == StatusCode.OK: GenericDialog(self.root, title="Success!", message="File saved to Desktop") elif self.downloadResponse == StatusCode.INTERNAL: GenericDialog(self.root, title="Error!", message="Internal server error!") else: GenericDialog(self.root, title="Error!", message="Some other error occurred!")
def loginInitiator(self): self.emailStr = self.email.get() self.passwordStr = self.password.get() if not validateEmail(self.emailStr): GenericDialog(self.root, title="Validation Error", message="Invalid Email Address!") elif self.passwordStr == "" or len(self.passwordStr) < 8: GenericDialog(self.root, title="Validation Error", message="Password must be 8 characters long!") else: self.waitDialog = StickyDialog(self.root, message="Please wait!") userLoginThread = UserLogin(self.queue, email=self.emailStr, password=self.passwordStr) userLoginThread.start() self.root.after(100, self.checkQueueForLogin)
def afterACLUpdateResponse(self): if self.aclUpdateResponse == StatusCode.OK: GenericDialog(self.root, title="Success!", message="ACL Updated") elif self.aclUpdateResponse == StatusCode.FAILED_PRECONDITION: GenericDialog(self.root, title="Error!", message="No such user email found!") elif self.aclUpdateResponse == StatusCode.NOT_FOUND: GenericDialog(self.root, title="Error!", message="File not found.\nRefresh and try again!") elif self.aclUpdateResponse == StatusCode.INTERNAL: GenericDialog(self.root, title="Error!", message="Internal server error!") else: GenericDialog(self.root, title="Error!", message="Some other error occurred!")
def afterDbResponse(self): if self.dbWriteResponse: self.frame.destroy() HomeScreen(self.root, user=self.user) else: GenericDialog( self.root, title="Database Error!", message="Unable to save login info!\nProgram will exit now.") self.root.quit()
def signOut(self): print("signout called") result = RemoveUserLoginInfo().remove() if result: self.root.destroy() loginScreen.LoginScreen(self.masterParent) else: GenericDialog( self.root, title="Database Error!", message="Unable to remove login info!\nProgram will exit now.")
def signOut(self): result = RemoveUserLoginInfo().remove() if result: self.masterFrame.grab_release() self.masterFrame.destroy() loginScreen.LoginScreen(self.root) else: GenericDialog( self.root, title="Database Error!", message="Unable to remove login info!\nProgram will exit now.")
def afterFileUploadResponse(self): if self.uploadStatusResponse == StatusCode.INTERNAL: GenericDialog(self.root, title="Error!", message="Internal server error!") elif self.uploadStatusResponse == StatusCode.UNAVAILABLE: GenericDialog(self.root, title="Error!", message="Server not available!") elif self.uploadStatusResponse == StatusCode.UNAUTHENTICATED: self.signOut() elif self.uploadStatusResponse == StatusCode.OK: GenericDialog( self.root, title="Success!", message="File Uploaded Successfully!\nPlease refresh!") else: GenericDialog(self.root, title="Error!", message="Some other error occurred!") self.enableMenuBar()
def afterLoginResponse(self): if isinstance(self.loginResponse, ussPb.LoginResponse): # print(self.loginResponse) self.saveUserInfoInitiator() elif self.loginResponse == StatusCode.INTERNAL: GenericDialog(self.root, title="Server Error", message="Internal server error!") elif self.loginResponse == StatusCode.NOT_FOUND: GenericDialog(self.root, title="Error", message="User not found!") elif self.loginResponse == StatusCode.FAILED_PRECONDITION: GenericDialog(self.root, title="Validation Error", message="Wrong password!") elif self.loginResponse == StatusCode.UNAVAILABLE: GenericDialog(self.root, title="Internal Error", message="Server not available!") else: GenericDialog(self.root, title="Unknown Error", message="Some other error occurred!")
def afterSignUpResponse(self): if self.signUpResponse == StatusCode.OK: GenericDialog(self.root, title="Success", message="User account created.\nYou can now login!") elif self.signUpResponse == StatusCode.ALREADY_EXISTS: GenericDialog( self.root, title="Account Error", message="User account already exists.\nPlease login!") elif self.signUpResponse == StatusCode.INTERNAL: GenericDialog(self.root, title="Error", message="Internal Server Error!") elif self.signUpResponse == StatusCode.UNAVAILABLE: GenericDialog(self.root, title="Error", message="Could not connect to server!") else: GenericDialog(self.root, title="Unknown Error", message="Error Code: " + self.signUpResponse + "!")
def signUpInitiator(self): name = self.username.get() email = self.email.get() password = self.password.get() confPassword = self.confirmPassword.get() if name == "" or not validateUsername(name) or len(name) > 32: GenericDialog( self.root, title="Validation Error", message= "Invalid name!\nContains only alphabets.\nMax length: 32.") elif not validateEmail(email): GenericDialog(self.root, title="Validation Error", message="Invalid Email Address!") elif password != confPassword: GenericDialog(self.root, title="Validation Error", message="Passwords do not match!") elif password == confPassword and len(password) < 8: GenericDialog(self.root, title="Validation Error", message="Password minimum length: 8") elif password == confPassword and len(password) > 64: GenericDialog(self.root, title="Validation Error", message="Password maximum length: 64") else: # initiate sign up self.waitDialog = StickyDialog(self.root, message="Please wait!") userSignUpThread = UserSignUp(queue=self.queue, username=name, email=email, password=password) userSignUpThread.start() self.root.after(100, self.checkQueue)
def grantAccess(self): print("granting") toEmail = self.emailEntry.get() self.remove() if validateEmail(email=toEmail): self.waitDialog = StickyDialog(self, message="Granting! Please wait...") updateAclGrantThread = UpdateFileACL(queue=self.queue, owner=self.fileDetails[0], name=self.fileDetails[1], grant=True, toEmail=toEmail) updateAclGrantThread.start() self.checkACLUpdateQueue() else: GenericDialog(self, title="Error!", message="Invalid Email Address!")
def openNewUploadFile(self): fileTypes = [("Text Documents", "*.txt")] dialog = filedialog.Open(master=self.root, filetypes=fileTypes) self.disableMenuBar() self.filePath = dialog.show() # check if file size is greater than 5 MB if self.filePath != "": self.fileStats = os.stat(self.filePath) print("size in bytes = ", self.fileStats.st_size) if self.fileStats.st_size > 5242880: GenericDialog(master=self.root, title="Size Error!", message="Max file size allowed: 5MB") self.enableMenuBar() else: # start uploading file self.initiateFileUpload(self.filePath) print("valid file size") else: self.enableMenuBar()