def _showRepositoryConfigDialog(self): repoconfig_dialog = RepositoryConfigDialog(self, CONF.getCouchURI(), CONF.getCouchIsReplicated(), CONF.getCouchReplics(), callback=None) result = repoconfig_dialog.exec_loop() if result == qt.QDialog.Accepted: repourl, isReplicated, replics = repoconfig_dialog.getData() api.devlog("repourl = %s" % repourl) wm = self._main_app.getWorkspaceManager() if not CouchDbManager.testCouch(repourl): self.showPopup(""" Repository URL Not valid, check if service is available and that connection string is from the form: http[s]://hostname:port""") return CONF.setCouchUri(repourl) CONF.setCouchIsReplicated(isReplicated) CONF.setCouchReplics(replics) CONF.saveConfig() wm.closeWorkspace() wm.resource() wm.openWorkspace('untitled') mwin = self._main_app.getMainWindow() mwin.getWorkspaceTreeView().loadAllWorkspaces() mwin.getWorkspaceTreeView().setDefaultWorkspace()
def _showRepositoryConfigDialog(self): repoconfig_dialog = RepositoryConfigDialog(self, CONF.getCouchURI(), CONF.getCouchIsReplicated(), CONF.getCouchReplics(), callback=None) result = repoconfig_dialog.exec_loop() if result == qt.QDialog.Accepted: repourl, isReplicated, replics = repoconfig_dialog.getData() api.devlog("repourl = %s" % repourl) wm = self._main_app.getWorkspaceManager() if not CouchDbManager.testCouch(repourl): self.showPopup(""" Repository URL Not valid, check if service is available and that connection string is from the form: http[s]://hostname:port""") return CONF.setCouchUri(repourl) CONF.setCouchIsReplicated(isReplicated) CONF.setCouchReplics(replics) CONF.saveConfig() wm.closeWorkspace() wm.resource() wm.openWorkspace('untitled') mwin = self._main_app.getMainWindow() mwin.getWorkspaceTreeView().loadAllWorkspaces() mwin.getWorkspaceTreeView().setDefaultWorkspace()
def connect_to_couch(self, couch_uri, parent=None): """Tries to connect to a CouchDB on a specified Couch URI. Returns the success status of the operation, False for not successful, True for successful """ if parent is None: parent = self.window if not CouchDbManager.testCouch(couch_uri): errorDialog(parent, "Could not connect to Faraday Server.", ("Are you sure it is running and that you can " "connect to it? \n Make sure your username and " "password are still valid.")) success = False elif couch_uri.startswith("https://"): if not checkSSL(couch_uri): errorDialog(self.window, "The SSL certificate validation has failed") success = False else: CONF.setCouchUri(couch_uri) CONF.saveConfig() self.reload_workspaces() self.open_last_workspace() success = True self.lost_connection_dialog_raised = False return success
def do_activate(self): """If there's no window, create one and present it (show it to user). If there's a window, just present it. Also add the log handler and the notifier to the application""" # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = AppWindow(self.sidebar, self.ws_sidebar, self.hosts_sidebar, self.terminal, self.console_log, self.statusbar, application=self, title="Faraday " + str(CONF.getVersion())) self.window.set_icon(self.icon) self.window.present() self.loghandler = GUIHandler() model.guiapi.setMainApp(self) addHandler(self.loghandler) self.loghandler.registerGUIOutput(self.window) notifier = model.log.getNotifier() notifier.widget = self.window model.guiapi.notification_center.registerWidget(self.window) if not CouchDbManager.testCouch(CONF.getCouchURI()): self.lost_db_connection( handle_connection_lost=self.handle_connection_lost, connect_to_a_different_couch=self.force_change_couch_url)
def handle_no_active_workspace(self): """If there's been a problem opening a workspace or for some reason we suddenly find our selves without one, force the user to select one if possible, or if not, to create one. """ def change_flag(widget): self.workspace_dialogs_raised = not self.workspace_dialogs_raised if self.workspace_dialogs_raised: return False if not CouchDbManager.testCouch(CONF.getCouchURI()): # make sure it is not because we're not connected to Couch # there's another whole strategy for that. return False self.workspace_dialogs_raised = True available_workspaces = self.workspace_manager.getWorkspacesNames() workspace_model = self.ws_sidebar.workspace_model if available_workspaces: dialog = ForceChooseWorkspaceDialog(self.window, workspace_model, self.change_workspace) else: dialog = ForceNewWorkspaceDialog(self.window, self.createWorkspace, self.workspace_manager, self.ws_sidebar, self.exit_faraday) dialog.connect("destroy", change_flag) dialog.show_all()
def do_activate(self): """If there's no window, create one and present it (show it to user). If there's a window, just present it. Also add the log handler and the notifier to the application""" # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = AppWindow(self.sidebar, self.ws_sidebar, self.hosts_sidebar, self.terminal, self.console_log, self.statusbar, application=self, title="Faraday " + str(CONF.getVersion())) self.window.set_icon(self.icon) self.window.present() self.loghandler = GUIHandler() model.guiapi.setMainApp(self) addHandler(self.loghandler) self.loghandler.registerGUIOutput(self.window) notifier = model.log.getNotifier() notifier.widget = self.window model.guiapi.notification_center.registerWidget(self.window) if not CouchDbManager.testCouch(CONF.getCouchURI()): self.lost_db_connection( handle_connection_lost=self.handle_connection_lost, connect_to_a_different_couch=self.force_change_couch_url)
def connect_to_couch(self, couch_uri, parent=None): """Tries to connect to a CouchDB on a specified Couch URI. Returns the success status of the operation, False for not successful, True for successful """ if parent is None: parent = self.window if not CouchDbManager.testCouch(couch_uri): errorDialog(parent, "Could not connect to Faraday Server.", ("Are you sure it is running and that you can " "connect to it? \n Make sure your username and " "password are still valid.")) success = False elif couch_uri.startswith("https://"): if not checkSSL(couch_uri): errorDialog(self.window, "The SSL certificate validation has failed") success = False else: CONF.setCouchUri(couch_uri) CONF.saveConfig() self.reload_workspaces() self.open_last_workspace() success = True self.lost_connection_dialog_raised = False return success
def handle_no_active_workspace(self): """If there's been a problem opening a workspace or for some reason we suddenly find our selves without one, force the user to select one if possible, or if not, to create one. """ def change_flag(widget): self.workspace_dialogs_raised = not self.workspace_dialogs_raised if self.workspace_dialogs_raised: return False if not CouchDbManager.testCouch(CONF.getCouchURI()): # make sure it is not because we're not connected to Couch # there's another whole strategy for that. return False self.workspace_dialogs_raised = True available_workspaces = self.workspace_manager.getWorkspacesNames() workspace_model = self.ws_sidebar.workspace_model if available_workspaces: dialog = ForceChooseWorkspaceDialog(self.window, workspace_model, self.change_workspace) else: dialog = ForceNewWorkspaceDialog(self.window, self.createWorkspace, self.workspace_manager, self.ws_sidebar, self.exit_faraday) dialog.connect("destroy", change_flag) dialog.show_all()
def on_click_OK(self, button): """Defines what happens when user clicks OK button""" repourl = self.entry.get_text() if not CouchDbManager.testCouch(repourl): errorDialog(self, "The provided URL is not valid", "Are you sure CouchDB is running?") elif repourl.startswith("https://"): if not checkSSL(repourl): errorDialog("The SSL certificate validation has failed") else: CONF.setCouchUri(repourl) CONF.saveConfig() self.reloadWorkspaces() self.destroy()
def on_click_OK(self, button): """Defines what happens when user clicks OK button""" repourl = self.entry.get_text() if not CouchDbManager.testCouch(repourl): errorDialog(self, "The provided URL is not valid", "Are you sure CouchDB is running?") elif repourl.startswith("https://"): if not checkSSL(repourl): errorDialog("The SSL certificate validation has failed") else: CONF.setCouchUri(repourl) CONF.saveConfig() self.reloadWorkspaces() self.destroy()