def confirm_clicked(self, x): CreateOrgPopup.popup.dismiss() # validate the credentials print(CreateOrgPopup.org, CreateOrgPopup.pas) organisation = CreateOrgPopup.org password = CreateOrgPopup.pas fs = FileSystem() # first check if an organisation with this name already exists popup_msg = "" err = False try: if (len(password) == 0): raise ValueError() fs.getOrganisationKey(organisation, password) popup_msg = "Organisation already exists!" err = True except FileNotFoundError: # the organisation does not exist fs.createOrganisation(organisation, password) cache['organisation'] = organisation cache['password'] = password popup_msg = "Organisation created successfully!" except ValueError: err = True popup_msg = "Please provide a password!" finally: layout = BoxLayout(orientation='vertical') popup_title = "Error" if err else "Confirmation" label1 = Label(text=popup_title) label = Label(text=popup_msg) button = Button(text='Dismiss') layout.add_widget(label) layout.add_widget(button) popup = Popup(title=popup_title, content=layout, size_hint=(None, None), size=(400, 250)) popup.open() button.bind(on_press=popup.dismiss)
def confirm_clicked(self, x): PopupInput.popup.dismiss() # validate the credentials print(PopupInput.org, PopupInput.pas) organisation = PopupInput.org password = PopupInput.pas fs = FileSystem() popup_msg = "" err = True try: fs.getOrganisationKey(organisation, password) popup_msg = "Logged in to: " + organisation cache['organisation'] = organisation cache['password'] = password err = False except FileNotFoundError: # the organisation does not exis popup_msg = "Organisation not found!" except TypeError: # password not provided popup_msg = "Password not provided!" except ValueError: # invalid password popup_msg = "Invalid Password!" finally: layout = BoxLayout(orientation='vertical') popup_title = "Error" if err else "Confirmation" label1 = Label(text=popup_title) label = Label(text=popup_msg) button = Button(text='Dismiss') layout.add_widget(label) layout.add_widget(button) popup = Popup(title=popup_title, content=layout, size_hint=(None, None), size=(400, 250)) popup.open() button.bind(on_press=popup.dismiss)