コード例 #1
0
 def accept(self):
     dest_dir = "%s"% SETTINGS.USER_CONNECTIONS_AVAILABLE_FOLDER
     
     filepath = unicode(QtGui.QFileDialog.getSaveFileName(self,
         directory=dest_dir, filter="conf"))
     if filepath:
         LOGGER.info("saving %s"% filepath)
         f = open(filepath, "w")
         f.write(self.text_edit.toPlainText())
         f.close()
         
         # make a symlink for the admin application
         linkpath = os.path.join(SETTINGS.CONNECTION_CONFDIRS[0], 
                 os.path.basename(filepath))
         
         LOGGER.info("making link %s"% linkpath)
             
         try:
             if os.path.exists(linkpath):
                 os.remove(linkpath)
             os.symlink(filepath, linkpath)
         except AttributeError:
             # for python2.7 on windows. os.symlink doesn't work.
             shutil.copyfile(filepath, linkpath)
         ServerFunctionDialog.accept(self)
コード例 #2
0
    def accept(self):
        dest_dir = "%s" % SETTINGS.USER_CONNECTIONS_AVAILABLE_FOLDER

        filepath = unicode(
            QtGui.QFileDialog.getSaveFileName(self,
                                              directory=dest_dir,
                                              filter="conf"))
        if filepath:
            LOGGER.info("saving %s" % filepath)
            f = open(filepath, "w")
            f.write(self.text_edit.toPlainText())
            f.close()

            # make a symlink for the admin application
            linkpath = os.path.join(SETTINGS.CONNECTION_CONFDIRS[0],
                                    os.path.basename(filepath))

            LOGGER.info("making link %s" % linkpath)

            try:
                if os.path.exists(linkpath):
                    os.remove(linkpath)
                os.symlink(filepath, linkpath)
            except AttributeError:
                # for python2.7 on windows. os.symlink doesn't work.
                shutil.copyfile(filepath, linkpath)
            ServerFunctionDialog.accept(self)
コード例 #3
0
 def accept(self):
     attempting = True
     result = None
     while attempting:
         try:
             self.waiting.emit(True)
             result = self.apply_changes()
             attempting = False
         except ProxyClient.PermissionError:
             LOGGER.info("user '%s' can not alter postgres groups"%
                 self.proxy_client.user.name)
             self.waiting.emit(False)
             attempting = self.switch_to_admin_user()
         finally:
             self.waiting.emit(False)
     if result is not None:
         LOGGER.debug(result)
         QtGui.QMessageBox.information(self, _("Result"),
             _("Changes Applied"))
     ServerFunctionDialog.accept(self)
     self.function_completed.emit()
コード例 #4
0
    def but_clicked(self):
        but = self.sender()
        user = unicode(but.text())
        if QtGui.QMessageBox.question(self, _("Confirm"),
            u"%s '%s'?"% (_("Remove user"), user),
            QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel,
            QtGui.QMessageBox.Cancel) == QtGui.QMessageBox.Cancel:
            return

        attempting = True
        result = None
        while attempting:
            try:
                self.waiting.emit(True)
                result = self.proxy_client.call("drop_user", user)
                attempting = False
            except ProxyClient.PermissionError:
                LOGGER.info("user '%s' can not drop a postgres user"%
                    self.proxy_client.user.name)
                self.waiting.emit(False)
                attempting = self.switch_to_admin_user()
            finally:
                self.waiting.emit(False)
        if result is not None:
            if result.payload == True:
                message = u"%s '%s'"% (_("Successfully removed user"), user)
                mess_func = QtGui.QMessageBox.information
            else:
                message = u"%s '%s'<hr />%s"% (
                    _("Unable to remove user"), user,
                    _("For information, please check the server log")
                    )
                mess_func = QtGui.QMessageBox.warning

            mess_func(self, _("Result"), message)

            LOGGER.info(message)
        ServerFunctionDialog.accept(self)
        self.function_completed.emit()
コード例 #5
0
    def but_clicked(self):
        but = self.sender()
        user = unicode(but.text())
        if QtGui.QMessageBox.question(
                self, _("Confirm"), u"%s '%s'?" % (_("Remove user"), user),
                QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel,
                QtGui.QMessageBox.Cancel) == QtGui.QMessageBox.Cancel:
            return

        attempting = True
        result = None
        while attempting:
            try:
                self.waiting.emit(True)
                result = self.proxy_client.call("drop_user", user)
                attempting = False
            except ProxyClient.PermissionError:
                LOGGER.info("user '%s' can not drop a postgres user" %
                            self.proxy_client.user.name)
                self.waiting.emit(False)
                attempting = self.switch_to_admin_user()
            finally:
                self.waiting.emit(False)
        if result is not None:
            if result.payload == True:
                message = u"%s '%s'" % (_("Successfully removed user"), user)
                mess_func = QtGui.QMessageBox.information
            else:
                message = u"%s '%s'<hr />%s" % (
                    _("Unable to remove user"), user,
                    _("For information, please check the server log"))
                mess_func = QtGui.QMessageBox.warning

            mess_func(self, _("Result"), message)

            LOGGER.info(message)
        ServerFunctionDialog.accept(self)
        self.function_completed.emit()