Exemple #1
0
 def accept(self):
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("Folder"), i18n("Folder name is missing"))
     elif not len(self.editLabel.text()):
         QtGui.QMessageBox.warning(self, i18n("Folder"), i18n("Folder label is missing"))
     else:
         QtGui.QDialog.accept(self)
Exemple #2
0
    def __slot_load_failsafe_rules(self):
        """
            Triggered when user clicks 'Load Failsafe Rules' button.
        """
        msg = QtGui.QMessageBox(self)
        msg.setIcon(QtGui.QMessageBox.Question)
        msg.setText(i18n("Failsafe firewall rules will be loaded."))
        msg.setInformativeText(i18n("Do you want to continue?"))
        msg.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
        msg.setDefaultButton(QtGui.QMessageBox.No)

        if msg.exec_() != QtGui.QMessageBox.Yes:
            return

        fp = tempfile.NamedTemporaryFile(delete=False)
        name = fp.name
        fp.write(file("/usr/share/ahenk-lider/firewall-failsafe.fwb").read())
        fp.close()

        self.plainTextEdit.setPlainText("")

        fw_name = re.findall('Firewall.*iptables.*name="([a-zA-Z0-9\-_]+)"', file(name).read())[0]

        process = subprocess.Popen(["/usr/bin/fwb_ipt", "-q", "-f", name, "-o", "%s.sh" % name, fw_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        if process.wait() != 0:
            return

        self.rules_xml = file(name).read()
        self.rules_compiled = file(name + ".sh").read()

        self.plainTextEdit.setPlainText(i18n("Failsafe rules were loaded"))
Exemple #3
0
 def accept(self):
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("Group"), i18n("Group name is missing"))
     elif len(self.get_members()) < 1:
         QtGui.QMessageBox.warning(self, i18n("Group"), i18n("There has to be at least one member."))
     else:
         QtGui.QDialog.accept(self)
Exemple #4
0
 def accept(self):
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("Folder"),
                                   i18n("Folder name is missing"))
     elif not len(self.editLabel.text()):
         QtGui.QMessageBox.warning(self, i18n("Folder"),
                                   i18n("Folder label is missing"))
     else:
         QtGui.QDialog.accept(self)
Exemple #5
0
 def accept(self):
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("Group"),
                                   i18n("Group name is missing"))
     elif len(self.get_members()) < 1:
         QtGui.QMessageBox.warning(
             self, i18n("Group"),
             i18n("There has to be at least one member."))
     else:
         QtGui.QDialog.accept(self)
Exemple #6
0
 def accept(self):
     """
         Checks written passwords are same or not. If not, warn user.
     """
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("User"), i18n("Username is missing"))
     elif not (self.editPassword.text() == self.editConfirmPassword.text()):
         QtGui.QMessageBox.warning(self, i18n("User"), i18n("Passwords do not match."))
     else:
         QtGui.QDialog.accept(self)
Exemple #7
0
 def accept(self):
     """
         Checks written passwords are same or not. If not, warn user.
     """
     if not len(self.editName.text()):
         QtGui.QMessageBox.warning(self, i18n("User"),
                                   i18n("Username is missing"))
     elif not (self.editPassword.text() == self.editConfirmPassword.text()):
         QtGui.QMessageBox.warning(self, i18n("User"),
                                   i18n("Passwords do not match."))
     else:
         QtGui.QDialog.accept(self)
Exemple #8
0
    def __slot_load_failsafe_rules(self):
        """
            Triggered when user clicks 'Load Failsafe Rules' button.
        """
        msg = QtGui.QMessageBox(self)
        msg.setIcon(QtGui.QMessageBox.Question)
        msg.setText(i18n("Failsafe firewall rules will be loaded."))
        msg.setInformativeText(i18n("Do you want to continue?"))
        msg.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
        msg.setDefaultButton(QtGui.QMessageBox.No)

        if msg.exec_() != QtGui.QMessageBox.Yes:
            return

        fp = tempfile.NamedTemporaryFile(delete=False)
        name = fp.name
        fp.write(file("/usr/share/ahenk-lider/firewall-failsafe.fwb").read())
        fp.close()

        self.plainTextEdit.setPlainText("")

        fw_name = re.findall('Firewall.*iptables.*name="([a-zA-Z0-9\-_]+)"',
                             file(name).read())[0]

        process = subprocess.Popen([
            "/usr/bin/fwb_ipt", "-q", "-f", name, "-o",
            "%s.sh" % name, fw_name
        ],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        if process.wait() != 0:
            return

        self.rules_xml = file(name).read()
        self.rules_compiled = file(name + ".sh").read()

        self.plainTextEdit.setPlainText(i18n("Failsafe rules were loaded"))
    def __check_fields(self, set_focus=False):
        """
            Checks fields for errors:

            Returns: True if valid, else False
        """
        # if self.editDomain.isModified() and not len(self.editDomain.text()):
        if not len(self.comboDomain.currentText()):
            self.labelWarning.setText(i18n("Domain name is required."))
            if set_focus:
                self.comboDomain.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        if self.editHost.isModified() and not len(self.editHost.text()):
            self.labelWarning.setText(i18n("Server address is required."))
            if set_focus:
                self.editHost.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        if self.editUser.isModified() and not len(self.editUser.text()):
            self.labelWarning.setText(i18n("User name is required."))
            if set_focus:
                self.editUser.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        self.labelWarning.setText("")
        return True
Exemple #10
0
    def __check_fields(self, set_focus=False):
        """
            Checks fields for errors:

            Returns: True if valid, else False
        """
        # if self.editDomain.isModified() and not len(self.editDomain.text()):
        if not len(self.comboDomain.currentText()):
            self.labelWarning.setText(i18n("Domain name is required."))
            if set_focus:
                self.comboDomain.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        if self.editHost.isModified() and not len(self.editHost.text()):
            self.labelWarning.setText(i18n("Server address is required."))
            if set_focus:
                self.editHost.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        if self.editUser.isModified() and not len(self.editUser.text()):
            self.labelWarning.setText(i18n("User name is required."))
            if set_focus:
                self.editUser.setFocus(QtCore.Qt.OtherFocusReason)
            return False
        self.labelWarning.setText("")
        return True
Exemple #11
0
    def talk_message(self, sender, command, arguments=None):
        """
            Main window calls this method when an XMPP message is received.
        """
        startset = []
        stopset = []
        print "-----  TALK MESSAGE IS CALLED  -----"
        print command


        print "---- information ----"
        print "start set size %d" %len(self.start_set)
        print self.start_set
        print "stop set size %d" %len(self.stop_set)
        print self.stop_set

        for services in self.start_set:
            #print services
            for service in services.split(","):
                #print service
                startset.append(service)


        for services in self.stop_set:
            #print services
            for service in services.split(","):
                #print service
                stopset.append(service)


        if command == "service.info":

            self.tableWidget.setRowCount(len(arguments))
            print "----------- ARGUMENTS --------------"
            index = 0

            arguments.sort(key=lambda t : tuple(t[0].lower()))
            print arguments

            for name, desc, status in arguments:
                item_description = QtGui.QTableWidgetItem(str(desc))
                self.tableWidget.setItem(index, 0, item_description)

                item_name = QtGui.QTableWidgetItem(str(name))
                self.tableWidget.setItem(index, 3, item_name)

                item_status = QtGui.QTableWidgetItem()

                if status in ['started', 'on', 'conditional_started']:
                    item_status.setText(i18n("Running"))
                    state = True
                else:
                    item_status.setText(i18n("Stopped"))
                    state = False

                for start in startset:
                    if start== str(name):
                        item_status.setIcon(wrappers.Icon("flag-green"))

                for stop in stopset:
                    if stop == str(name):
                        item_status.setIcon(wrappers.Icon("flag-red"))


                self.tableWidget.setItem(index, 1, item_status)

                if status in ['stopped', 'on']:
                    item_autostart = QtGui.QTableWidgetItem(i18n("Yes"))
                elif status in ['conditional_started', 'conditional_stopped']:
                    item_autostart = QtGui.QTableWidgetItem(i18n("Conditional"))
                else:
                    item_autostart = QtGui.QTableWidgetItem(i18n("No"))
                self.tableWidget.setItem(index, 2, item_autostart)

                if state:
                    self._set_service_item_color(index, SERV_START_COLOR)
                else:
                    self._set_service_item_color(index, SERV_STOP_COLOR)

                index += 1
        elif command in ["service.start.status", "service.stop.status"]:
            msg = QtGui.QMessageBox.information(self, i18n("Status"), arguments)
Exemple #12
0
    def talk_message(self, sender, command, arguments=None):
        """
            Main window calls this method when an XMPP message is received.
        """
        startset = []
        stopset = []
        print "-----  TALK MESSAGE IS CALLED  -----"
        print command

        print "---- information ----"
        print "start set size %d" % len(self.start_set)
        print self.start_set
        print "stop set size %d" % len(self.stop_set)
        print self.stop_set

        for services in self.start_set:
            #print services
            for service in services.split(","):
                #print service
                startset.append(service)

        for services in self.stop_set:
            #print services
            for service in services.split(","):
                #print service
                stopset.append(service)

        if command == "service.info":

            self.tableWidget.setRowCount(len(arguments))
            print "----------- ARGUMENTS --------------"
            index = 0

            arguments.sort(key=lambda t: tuple(t[0].lower()))
            print arguments

            for name, desc, status in arguments:
                item_description = QtGui.QTableWidgetItem(str(desc))
                self.tableWidget.setItem(index, 0, item_description)

                item_name = QtGui.QTableWidgetItem(str(name))
                self.tableWidget.setItem(index, 3, item_name)

                item_status = QtGui.QTableWidgetItem()

                if status in ['started', 'on', 'conditional_started']:
                    item_status.setText(i18n("Running"))
                    state = True
                else:
                    item_status.setText(i18n("Stopped"))
                    state = False

                for start in startset:
                    if start == str(name):
                        item_status.setIcon(wrappers.Icon("flag-green"))

                for stop in stopset:
                    if stop == str(name):
                        item_status.setIcon(wrappers.Icon("flag-red"))

                self.tableWidget.setItem(index, 1, item_status)

                if status in ['stopped', 'on']:
                    item_autostart = QtGui.QTableWidgetItem(i18n("Yes"))
                elif status in ['conditional_started', 'conditional_stopped']:
                    item_autostart = QtGui.QTableWidgetItem(
                        i18n("Conditional"))
                else:
                    item_autostart = QtGui.QTableWidgetItem(i18n("No"))
                self.tableWidget.setItem(index, 2, item_autostart)

                if state:
                    self._set_service_item_color(index, SERV_START_COLOR)
                else:
                    self._set_service_item_color(index, SERV_STOP_COLOR)

                index += 1
        elif command in ["service.start.status", "service.stop.status"]:
            msg = QtGui.QMessageBox.information(self, i18n("Status"),
                                                arguments)