def kill_all(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) start_fw.kill_fw() try: start_fw.kill_gui_user(self.current_user) except Exception as e: self.filelogger.send_log( "error", "Error While Killing Previous GUI {}".format(str(e))) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) self.filelogger.send_log( "warning", " previous gui was killed by " + self.current_user + " : gui ") self.btn_kill_fw.setEnabled(False) sleep(2) self.load_new_rules() sleep(3) self.auto_refresh() self.lbl_error_start.setText(u"<b>SONLANDIRILDI</b>")
def start_fwbuilder(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if start_fw.check_if_runs() == False: with open(self.full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) fw_path = CP.get_configs()["fw_path"] start_fw.start_fwbuilder(self.git) self.logger.send_log( "info", " Firewall Builder Started with Local settings") self.filelogger.send_log( "info", " Firewall Builder Started with Local settings") else: self.warn_if_fw_runs() subprocess.call([ "xdotool search --name \"Firewall Builder\" windowactivate windowsize 90\% 90\%" ], shell=True)
def load_new_rules(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if start_fw.check_if_runs() is True: self.warn_if_fw_runs() else: self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" self.pull_repo() self.logger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.filelogger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False)
def get_file_list(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) fw_path = CP.get_path_configs()["fw_path"] files = [] fwb_list = [] for (dirpath, dirnames, file_names) in os.walk(fw_path): files.extend(file_names) break for f in files: f_name, f_extension = os.path.splitext(f) if f_extension == ".fwb": fwb_list.append(str(f)) if len(fwb_list) != 0: self.cmb_fw_file_name.addItems(fwb_list) fwb_file_name = CP.get_path_configs()["fwb_file_name"] index = self.cmb_fw_file_name.findText(str(fwb_file_name)) if index != -1: self.cmb_fw_file_name.setCurrentIndex(index)
def save_config_gitlab(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) config_gitlab = {} config_gitlab["url"] = self.ledit_gitlab_url.text() config_gitlab["user"] = self.ledit_gitlab_user.text() config_gitlab["pass"] = self.ledit_gitlab_pass.text() config_gitlab["confirm_branch"] = self.ledit_confirm_branch.text() config_gitlab["master_branch"] = self.ledit_master_branch.text() config_gitlab["project_name"] = self.ledit_project_name.text() self.progressBar_gitlab.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar(self.progressBar_gitlab) CP.set_gitlab_config(config_gitlab) self.logger.send_log("warning", " gitlab configs changed") self.filelogger.send_log("warning", " gitlab configs changed") result = self.check_and_refresh() self.centralwidget.setEnabled(True) self.progressBar_gitlab.setValue(0) self.progressBar_gitlab.setVisible(False) if result == True: self.lbl_error_message.setText( u"<p>Ayarlarınız başarılı bir şekilde kaydedildi.</p>")
def save_config_path(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) config_paths = {} config_paths["fwb_file_name"] = str( self.cmb_fw_file_name.currentText()) config_paths["fw_copy_path"] = self.ledit_fw_copy_path.text() config_paths["poc_user"] = self.ledit_poc_user.text() config_paths["poc_ip"] = self.ledit_poc_ip.text() config_paths["port_number"] = self.ledit_poc_port_number.text() config_paths["poc_copy_location"] = self.ledit_poc_copy_path.text() config_paths["std_out_err"] = self.ledit_std_out_err.text() self.progressBar_path.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar(self.progressBar_path) CP.set_path_config(config_paths) self.logger.send_log("warning", " path configs changed") self.filelogger.send_log("warning", " path configs changed") result = self.check_and_refresh() self.centralwidget.setEnabled(True) self.progressBar_path.setValue(0) self.progressBar_path.setVisible(False) if result == True: self.lbl_error_message.setText( u"<p>Ayarlarınız başarılı bir şekilde kaydedildi.</p>")
def load_new_rules(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if GC.check_mergerequest( self.git, CP.get_configs()["gitlab_project_id"]) == False: self.refresh_method() elif start_fw.check_if_runs() is True: self.warn_if_fw_runs() else: self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" if os.path.exists(full_path + "onay.dmr"): os.remove(full_path + "onay.dmr") self.pull_repo() self.logger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.filelogger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.lbl_merge_control.setText(u"<p></p>") self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False)
from dmrlogger import Filelogger from time import sleep import subprocess abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" if os.path.exists(full_path + "current_user.dmr"): with open(full_path + "current_user.dmr") as current_user: user = current_user.readline() else: user = subprocess.check_output(["whoami"]) logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", user) filelogger = Filelogger("FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", user) def gitlab_connect(gitlab_url, user, password): git = gitlab.Gitlab(gitlab_url) git.login(user=user, password=password) return git def check_mergerequest(git, project_id): sleep(1) mergerequests = git.getmergerequests(project_id) if mergerequests != False:
def setupUi(self, FwStartWindow): FwStartWindow.setObjectName(_fromUtf8("FwStartWindow")) FwStartWindow.move(200, 100) FwStartWindow.resize(800, 600) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( FwStartWindow.sizePolicy().hasHeightForWidth()) FwStartWindow.setSizePolicy(sizePolicy) FwStartWindow.setMinimumSize(QtCore.QSize(800, 600)) FwStartWindow.setMaximumSize(QtCore.QSize(800, 600)) FwStartWindow.setStyleSheet( _fromUtf8("background-color: rgb(255, 236, 207);")) self.centralwidget = QtGui.QWidget(FwStartWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.btn_deny_control = QtGui.QPushButton(self.centralwidget) self.btn_deny_control.setGeometry(QtCore.QRect(340, 430, 181, 50)) self.frame = QtGui.QFrame(self.centralwidget) self.frame.setGeometry(QtCore.QRect(490, 120, 301, 181)) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_deny_control.sizePolicy().hasHeightForWidth()) self.btn_deny_control.setSizePolicy(sizePolicy) self.btn_deny_control.setMinimumSize(QtCore.QSize(160, 50)) self.btn_deny_control.setAcceptDrops(False) self.btn_deny_control.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_deny_control.setObjectName(_fromUtf8("btn_deny_control")) self.btn_start_fwbuilder = QtGui.QPushButton(self.centralwidget) self.btn_start_fwbuilder.setGeometry(QtCore.QRect(150, 430, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_start_fwbuilder.sizePolicy().hasHeightForWidth()) self.btn_start_fwbuilder.setSizePolicy(sizePolicy) self.btn_start_fwbuilder.setMinimumSize(QtCore.QSize(160, 50)) self.btn_start_fwbuilder.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_start_fwbuilder.setObjectName( _fromUtf8("btn_start_fwbuilder")) self.lbl_last_merge = QtGui.QLabel(self.centralwidget) self.lbl_last_merge.setGeometry(QtCore.QRect(240, 530, 505, 41)) self.lbl_last_merge.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.lbl_last_merge.setFont(font) self.lbl_last_merge.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_last_merge.setText(_fromUtf8("")) self.lbl_last_merge.setObjectName(_fromUtf8("lbl_last_merge")) self.lbl_error_start = QtGui.QLabel(self.centralwidget) self.lbl_error_start.setGeometry(QtCore.QRect(20, 260, 375, 41)) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.lbl_error_start.setFont(font) self.lbl_error_start.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_error_start.setText(_fromUtf8("")) self.lbl_error_start.setObjectName(_fromUtf8("lbl_error_start")) self.btn_kill_fw = QtGui.QPushButton(self.centralwidget) self.btn_kill_fw.setGeometry(QtCore.QRect(10, 300, 51, 50)) self.btn_kill_fw.setMinimumSize(QtCore.QSize(120, 50)) self.btn_kill_fw.setAcceptDrops(False) self.btn_kill_fw.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_kill_fw.setObjectName(_fromUtf8("btn_kill_fw")) self.btn_kill_fw.setEnabled(False) self.btn_watch_merge = QtGui.QPushButton(self.centralwidget) self.btn_watch_merge.setGeometry(QtCore.QRect(530, 430, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_watch_merge.sizePolicy().hasHeightForWidth()) self.btn_watch_merge.setSizePolicy(sizePolicy) self.btn_watch_merge.setMinimumSize(QtCore.QSize(160, 50)) self.btn_watch_merge.setAcceptDrops(False) self.btn_watch_merge.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_watch_merge.setObjectName(_fromUtf8("btn_watch_merge")) self.progressBar = QtGui.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(120, 10, 571, 31)) self.progressBar.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar.setFont(font) self.progressBar.setStyleSheet(_fromUtf8("")) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName(_fromUtf8("progressBar")) self.btn_merge_control = QtGui.QPushButton(self.centralwidget) self.btn_merge_control.setGeometry(QtCore.QRect(580, 60, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_merge_control.sizePolicy().hasHeightForWidth()) self.btn_merge_control.setSizePolicy(sizePolicy) self.btn_merge_control.setMinimumSize(QtCore.QSize(160, 50)) self.btn_merge_control.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_merge_control.setObjectName(_fromUtf8("btn_merge_control")) self.lbl_merge_control = QtGui.QLabel(self.frame) self.lbl_merge_control.setGeometry(QtCore.QRect(1, 1, 300, 180)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_merge_control.sizePolicy().hasHeightForWidth()) self.lbl_merge_control.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily(_fromUtf8("Sans Serif")) font.setPointSize(9) font.setBold(False) font.setItalic(False) font.setWeight(50) font.setStrikeOut(False) font.setStyleStrategy(QtGui.QFont.PreferDefault) self.lbl_merge_control.setFont(font) self.lbl_merge_control.setAutoFillBackground(False) self.lbl_merge_control.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_merge_control.setLocale( QtCore.QLocale(QtCore.QLocale.Turkish, QtCore.QLocale.Turkey)) self.lbl_merge_control.setObjectName(_fromUtf8("lbl_merge_control")) FwStartWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(FwStartWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setStyleSheet(_fromUtf8("")) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu_edit = QtGui.QMenu(self.menubar) self.menu_edit.setObjectName(_fromUtf8("menu_edit")) self.menu_help = QtGui.QMenu(self.menubar) self.menu_help.setObjectName(_fromUtf8("menu_help")) FwStartWindow.setMenuBar(self.menubar) self.action_refresh = QtGui.QAction(FwStartWindow) self.action_refresh.setObjectName(_fromUtf8("action_refresh")) self.action_settings = QtGui.QAction(FwStartWindow) self.action_settings.setObjectName(_fromUtf8("action_settings")) self.action_definitions = QtGui.QAction(FwStartWindow) self.action_definitions.setObjectName(_fromUtf8("action_definitions")) self.action_about = QtGui.QAction(FwStartWindow) self.action_about.setObjectName(_fromUtf8("action_about")) self.action_exit = QtGui.QAction(FwStartWindow) self.action_exit.setObjectName(_fromUtf8("action_exit")) self.menu_edit.addAction(self.action_refresh) self.menu_edit.addAction(self.action_settings) self.menu_edit.addAction(self.action_exit) self.menu_help.addAction(self.action_definitions) self.menu_help.addAction(self.action_about) self.menubar.addAction(self.menu_edit.menuAction()) self.menubar.addAction(self.menu_help.menuAction()) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.auto_refresh) self.def_window = None self.about_window = None self.retranslateUi(FwStartWindow) self.git = False self.git_status = False self.child = False self.old_config = {} self.active_user = "******" self.current_user = "******" abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "r") as current_user: self.active_user = current_user.readline() self.full_path = full_path self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) #stylesheets FwStartWindow.setStyleSheet( _fromUtf8("QMainWindow#FwStartWindow {border-image: url(" + full_path + "img/ahtapot_logo.png);}")) self.set_confirmation_status() QtCore.QObject.connect(self.action_settings, QtCore.SIGNAL(_fromUtf8("triggered()")), self.change_windows) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL(_fromUtf8("triggered()")), exit) QtCore.QObject.connect(self.action_refresh, QtCore.SIGNAL(_fromUtf8("triggered()")), self.refresh_method) QtCore.QObject.connect(self.action_definitions, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_def_window) QtCore.QObject.connect(self.action_about, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_about_window) QtCore.QObject.connect(self.btn_start_fwbuilder, QtCore.SIGNAL(_fromUtf8("clicked()")), self.start_fwbuilder) QtCore.QObject.connect(self.btn_merge_control, QtCore.SIGNAL(_fromUtf8("clicked()")), self.check_git_merge) QtCore.QObject.connect(self.btn_deny_control, QtCore.SIGNAL(_fromUtf8("clicked()")), self.load_new_rules) QtCore.QObject.connect(self.btn_watch_merge, QtCore.SIGNAL(_fromUtf8("clicked()")), self.watch_new_rules) QtCore.QObject.connect(self.btn_kill_fw, QtCore.SIGNAL(_fromUtf8("clicked()")), self.kill_all) QtCore.QMetaObject.connectSlotsByName(FwStartWindow)
class Ui_FwStartWindow(QtGui.QWidget): def setupUi(self, FwStartWindow): FwStartWindow.setObjectName(_fromUtf8("FwStartWindow")) FwStartWindow.move(200, 100) FwStartWindow.resize(800, 600) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( FwStartWindow.sizePolicy().hasHeightForWidth()) FwStartWindow.setSizePolicy(sizePolicy) FwStartWindow.setMinimumSize(QtCore.QSize(800, 600)) FwStartWindow.setMaximumSize(QtCore.QSize(800, 600)) FwStartWindow.setStyleSheet( _fromUtf8("background-color: rgb(255, 236, 207);")) self.centralwidget = QtGui.QWidget(FwStartWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.btn_deny_control = QtGui.QPushButton(self.centralwidget) self.btn_deny_control.setGeometry(QtCore.QRect(340, 430, 181, 50)) self.frame = QtGui.QFrame(self.centralwidget) self.frame.setGeometry(QtCore.QRect(490, 120, 301, 181)) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_deny_control.sizePolicy().hasHeightForWidth()) self.btn_deny_control.setSizePolicy(sizePolicy) self.btn_deny_control.setMinimumSize(QtCore.QSize(160, 50)) self.btn_deny_control.setAcceptDrops(False) self.btn_deny_control.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_deny_control.setObjectName(_fromUtf8("btn_deny_control")) self.btn_start_fwbuilder = QtGui.QPushButton(self.centralwidget) self.btn_start_fwbuilder.setGeometry(QtCore.QRect(150, 430, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_start_fwbuilder.sizePolicy().hasHeightForWidth()) self.btn_start_fwbuilder.setSizePolicy(sizePolicy) self.btn_start_fwbuilder.setMinimumSize(QtCore.QSize(160, 50)) self.btn_start_fwbuilder.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_start_fwbuilder.setObjectName( _fromUtf8("btn_start_fwbuilder")) self.lbl_last_merge = QtGui.QLabel(self.centralwidget) self.lbl_last_merge.setGeometry(QtCore.QRect(240, 530, 505, 41)) self.lbl_last_merge.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.lbl_last_merge.setFont(font) self.lbl_last_merge.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_last_merge.setText(_fromUtf8("")) self.lbl_last_merge.setObjectName(_fromUtf8("lbl_last_merge")) self.lbl_error_start = QtGui.QLabel(self.centralwidget) self.lbl_error_start.setGeometry(QtCore.QRect(20, 260, 375, 41)) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.lbl_error_start.setFont(font) self.lbl_error_start.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_error_start.setText(_fromUtf8("")) self.lbl_error_start.setObjectName(_fromUtf8("lbl_error_start")) self.btn_kill_fw = QtGui.QPushButton(self.centralwidget) self.btn_kill_fw.setGeometry(QtCore.QRect(10, 300, 51, 50)) self.btn_kill_fw.setMinimumSize(QtCore.QSize(120, 50)) self.btn_kill_fw.setAcceptDrops(False) self.btn_kill_fw.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_kill_fw.setObjectName(_fromUtf8("btn_kill_fw")) self.btn_kill_fw.setEnabled(False) self.btn_watch_merge = QtGui.QPushButton(self.centralwidget) self.btn_watch_merge.setGeometry(QtCore.QRect(530, 430, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_watch_merge.sizePolicy().hasHeightForWidth()) self.btn_watch_merge.setSizePolicy(sizePolicy) self.btn_watch_merge.setMinimumSize(QtCore.QSize(160, 50)) self.btn_watch_merge.setAcceptDrops(False) self.btn_watch_merge.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_watch_merge.setObjectName(_fromUtf8("btn_watch_merge")) self.progressBar = QtGui.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(120, 10, 571, 31)) self.progressBar.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar.setFont(font) self.progressBar.setStyleSheet(_fromUtf8("")) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName(_fromUtf8("progressBar")) self.btn_merge_control = QtGui.QPushButton(self.centralwidget) self.btn_merge_control.setGeometry(QtCore.QRect(580, 60, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_merge_control.sizePolicy().hasHeightForWidth()) self.btn_merge_control.setSizePolicy(sizePolicy) self.btn_merge_control.setMinimumSize(QtCore.QSize(160, 50)) self.btn_merge_control.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_merge_control.setObjectName(_fromUtf8("btn_merge_control")) self.lbl_merge_control = QtGui.QLabel(self.frame) self.lbl_merge_control.setGeometry(QtCore.QRect(1, 1, 300, 180)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_merge_control.sizePolicy().hasHeightForWidth()) self.lbl_merge_control.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily(_fromUtf8("Sans Serif")) font.setPointSize(9) font.setBold(False) font.setItalic(False) font.setWeight(50) font.setStrikeOut(False) font.setStyleStrategy(QtGui.QFont.PreferDefault) self.lbl_merge_control.setFont(font) self.lbl_merge_control.setAutoFillBackground(False) self.lbl_merge_control.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_merge_control.setLocale( QtCore.QLocale(QtCore.QLocale.Turkish, QtCore.QLocale.Turkey)) self.lbl_merge_control.setObjectName(_fromUtf8("lbl_merge_control")) FwStartWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(FwStartWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setStyleSheet(_fromUtf8("")) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu_edit = QtGui.QMenu(self.menubar) self.menu_edit.setObjectName(_fromUtf8("menu_edit")) self.menu_help = QtGui.QMenu(self.menubar) self.menu_help.setObjectName(_fromUtf8("menu_help")) FwStartWindow.setMenuBar(self.menubar) self.action_refresh = QtGui.QAction(FwStartWindow) self.action_refresh.setObjectName(_fromUtf8("action_refresh")) self.action_settings = QtGui.QAction(FwStartWindow) self.action_settings.setObjectName(_fromUtf8("action_settings")) self.action_definitions = QtGui.QAction(FwStartWindow) self.action_definitions.setObjectName(_fromUtf8("action_definitions")) self.action_about = QtGui.QAction(FwStartWindow) self.action_about.setObjectName(_fromUtf8("action_about")) self.action_exit = QtGui.QAction(FwStartWindow) self.action_exit.setObjectName(_fromUtf8("action_exit")) self.menu_edit.addAction(self.action_refresh) self.menu_edit.addAction(self.action_settings) self.menu_edit.addAction(self.action_exit) self.menu_help.addAction(self.action_definitions) self.menu_help.addAction(self.action_about) self.menubar.addAction(self.menu_edit.menuAction()) self.menubar.addAction(self.menu_help.menuAction()) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.auto_refresh) self.def_window = None self.about_window = None self.retranslateUi(FwStartWindow) self.git = False self.git_status = False self.child = False self.old_config = {} self.active_user = "******" self.current_user = "******" abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "r") as current_user: self.active_user = current_user.readline() self.full_path = full_path self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) #stylesheets FwStartWindow.setStyleSheet( _fromUtf8("QMainWindow#FwStartWindow {border-image: url(" + full_path + "img/ahtapot_logo.png);}")) self.set_confirmation_status() QtCore.QObject.connect(self.action_settings, QtCore.SIGNAL(_fromUtf8("triggered()")), self.change_windows) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL(_fromUtf8("triggered()")), exit) QtCore.QObject.connect(self.action_refresh, QtCore.SIGNAL(_fromUtf8("triggered()")), self.refresh_method) QtCore.QObject.connect(self.action_definitions, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_def_window) QtCore.QObject.connect(self.action_about, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_about_window) QtCore.QObject.connect(self.btn_start_fwbuilder, QtCore.SIGNAL(_fromUtf8("clicked()")), self.start_fwbuilder) QtCore.QObject.connect(self.btn_merge_control, QtCore.SIGNAL(_fromUtf8("clicked()")), self.check_git_merge) QtCore.QObject.connect(self.btn_deny_control, QtCore.SIGNAL(_fromUtf8("clicked()")), self.load_new_rules) QtCore.QObject.connect(self.btn_watch_merge, QtCore.SIGNAL(_fromUtf8("clicked()")), self.watch_new_rules) QtCore.QObject.connect(self.btn_kill_fw, QtCore.SIGNAL(_fromUtf8("clicked()")), self.kill_all) QtCore.QMetaObject.connectSlotsByName(FwStartWindow) def retranslateUi(self, FwStartWindow): FwStartWindow.setWindowTitle( _translate("FwStartWindow", " Ahtapot - GDYS", None)) self.btn_deny_control.setText( _translate("FwStartWindow", "Onaylanmış Ayarlar\n" " ile Çalıştır", None)) self.btn_start_fwbuilder.setText( _translate("FwStartWindow", "Yerel Ayarlar \n" " ile Çalıştır", None)) self.btn_watch_merge.setText( _translate("FwStartWindow", "Onaylanmış Ayarları\n" " Göster", None)) self.btn_merge_control.setText( _translate("FwStartWindow", "Onay Kontrol", None)) self.btn_kill_fw.setText(_translate("FwStartWindow", "Sonlandır", None)) self.lbl_merge_control.setText( _translate("FwStartWindow", "<html><head/><body><p><br/></p></body></html>", None)) self.menu_edit.setTitle(_translate("FwStartWindow", "Düzenle", None)) self.menu_help.setTitle(_translate("FwStartWindow", "Yardım", None)) self.action_refresh.setText(_translate("FwStartWindow", "Yenile", None)) self.action_refresh.setShortcut( _translate("MainWindow", "Ctrl+R", None)) self.action_settings.setText( _translate("FwStartWindow", "Yapılandırma Ayarları", None)) self.action_settings.setShortcut( _translate("MainWindow", "Ctrl+S", None)) self.action_definitions.setText( _translate("FwStartWindow", "Açıklamalar", None)) self.action_definitions.setShortcut( _translate("MainWindow", "Ctrl+D", None)) self.action_about.setText(_translate("FwStartWindow", "Hakkında", None)) self.action_about.setShortcut(_translate("MainWindow", "Ctrl+A", None)) self.action_exit.setText(_translate("FwStartWindow", "Çıkış", None)) self.action_exit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) self.timer.start(15000) def set_windows(self, old, new): self.old_window = old self.new_window = new def change_windows(self): self.child.setupUi(self.new_window) self.child.parent = self self.child.about_window = self.about_window FwSettingsDefWindow = QtGui.QMainWindow() ui_settings_def = fwsettingsdef.Ui_Form() ui_settings_def.setupUi(FwSettingsDefWindow) self.child.def_window = FwSettingsDefWindow self.child.current_user = self.current_user self.new_window.show() def show_def_window(self): self.def_window.show() def show_about_window(self): self.about_window.show() def set_error_message(self, message): self.lbl_error_start.setText(message) def check_and_refresh(self): check_path = start_fw.check_config_paths(CP.get_path_configs()) check_gitlab_conn = GC.check_gitlab_connection(CP.get_gitlab_configs()) self.old_config = CP.get_configs() if check_gitlab_conn[0] == True: self.git = check_gitlab_conn[1] GC.set_project_id( self.git, CP.get_gitlab_connection()["gitlab_project_name"]) check_gitlab_sett = GC.check_gitlab_settings( self.git, CP.get_gitlab_configs()) if check_path == True and check_gitlab_conn[ 0] == True and check_gitlab_sett == True: self.lbl_error_start.setText("") self.btn_merge_control.setEnabled(True) self.btn_deny_control.setEnabled(True) self.btn_start_fwbuilder.setEnabled(True) self.btn_watch_merge.setEnabled(True) self.check_git_merge(self.git) self.warn_if_fw_runs() return True else: self.btn_merge_control.setEnabled(False) self.btn_deny_control.setEnabled(False) self.btn_start_fwbuilder.setEnabled(False) self.btn_watch_merge.setEnabled(False) self.lbl_merge_control.setText("") self.lbl_merge_control.setText("") if check_path != True: self.set_error_message(check_path) elif check_gitlab_conn[0] != True: self.set_error_message(check_gitlab_conn[0]) else: self.set_error_message(check_gitlab_sett) return False def check_git_merge(self, git): self.lbl_error_start.setText("<p></p>") self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() #git = GC.gitlab_connect(CP.get_configs()["gitlab_url"],CP.get_configs()["gitlab_user"],CP.get_configs()["gitlab_pass"]) #<<<< git_status = GC.check_mergerequest( git, CP.get_configs()["gitlab_project_id"]) #<<<<< self.git_status = git_status self.set_last_commit( GC.get_master_commit_id(git, CP.get_configs()["gitlab_project_id"], CP.get_configs()["gitlab_master_branch"])) if git_status == False: self.lbl_merge_control.setText( u"<p>Sistemde onay bekleyen kurallar bulunuyor.<br/>Son durumunu kontrol etmek için lütfen <br/>\"Onay Kontrol\" butonuna basınız.<br/><b>Not:</b> Onayda bekleyen istek olduğu sürece <br/>FWBuilder sadece okunabilir modda çalışacaktır</p>" ) self.btn_deny_control.setEnabled(False) self.btn_watch_merge.setEnabled(True) else: if GC.get_mergerequest_status( git, CP.get_configs()["gitlab_project_id"] ) == "closed" and GC.check_merge_confirm() == True: self.lbl_merge_control.setText( u"<p><b>Son kural değişiklikleri reddedilmiş :</b> <br/>" + git.getmergerequestcomments( CP.get_configs()["gitlab_project_id"], git.getmergerequests(CP.get_configs( )["gitlab_project_id"])[0]["id"])[-1]["note"] + "</p>") elif GC.get_mergerequest_status( git, CP.get_configs()["gitlab_project_id"]) == "merged": self.check_merge_file() self.btn_merge_control.setEnabled(False) self.btn_start_fwbuilder.setEnabled(True) self.btn_deny_control.setEnabled(True) self.btn_watch_merge.setEnabled(True) self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False) def start_fwbuilder(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if start_fw.check_if_runs() == False: with open(self.full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) fw_path = CP.get_configs()["fw_path"] start_fw.start_fwbuilder(self.git) self.logger.send_log( "info", " Firewall Builder Started with Local settings") self.filelogger.send_log( "info", " Firewall Builder Started with Local settings") else: self.warn_if_fw_runs() subprocess.call([ "xdotool search --name \"Firewall Builder\" windowactivate windowsize 90\% 90\%" ], shell=True) def refresh_method(self): self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() self.lbl_error_start.setText(u"<p></p>") if self.git != False: GC.set_project_id( self.git, CP.get_gitlab_connection()["gitlab_project_name"]) self.check_and_refresh() self.warn_if_fw_runs() self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False) def check_merge_file(self): if GC.check_merge_confirm() == True: self.lbl_merge_control.setText( u"<p>Onaylanmış yapılandırma mevcut, <br/>yüklemeniz tavsiye edilir.<br/> Aksi halde varolan ayarlarla başlatılıcaktır.</p>" ) else: self.lbl_merge_control.setText(u"<p></p>") def pull_repo(self): fw_path = CP.get_configs()["fw_path"] master_branch = CP.get_configs()["gitlab_master_branch"] confirm_branch = CP.get_configs()["gitlab_confirm_branch"] fwb_file_name = CP.get_configs()["fwb_file_name"] cmd_git_undo = "cd " + fw_path + "&& git checkout -- ." cmd_git_branch = "cd " + fw_path + "&& git checkout " + master_branch cmd_git_pull = "cd " + fw_path + "&& git pull --rebase origin " + master_branch subprocess.call([cmd_git_undo], shell=True) subprocess.call([cmd_git_branch], shell=True) subprocess.call([cmd_git_pull], shell=True) start_fw.kill_fw() fw_path = CP.get_configs()["fw_path"] cmd_git_branch = "cd " + fw_path + "&& git checkout " + confirm_branch cmd_git_check_file = "cd " + fw_path + " && git checkout " + master_branch + " -- " + fwb_file_name subprocess.call([cmd_git_branch], shell=True) subprocess.call([cmd_git_check_file], shell=True) start_fw.start_fwbuilder(self.git) def load_new_rules(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if GC.check_mergerequest( self.git, CP.get_configs()["gitlab_project_id"]) == False: self.refresh_method() elif start_fw.check_if_runs() is True: self.warn_if_fw_runs() else: self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" if os.path.exists(full_path + "onay.dmr"): os.remove(full_path + "onay.dmr") self.pull_repo() self.logger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.filelogger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.lbl_merge_control.setText(u"<p></p>") self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False) def set_last_commit(self, commit_date): if commit_date != False: self.lbl_last_merge.setText(u"<b>Son Onaylanmış Commit ID :</b> " + commit_date) def set_progressbar(self): self.progressBar.setValue(30) sleep(1) self.progressBar.setValue(60) sleep(1) self.progressBar.setValue(100) def watch_new_rules(self): start_fw.start_fwbuilder_temp() def warn_if_fw_runs(self): if start_fw.check_if_runs() == True: with open(self.full_path + "current_user.dmr", "r") as active_user: self.active_user = active_user.readline() self.lbl_error_start.setText( u"<b>UYARI:</b> Şuan kullanılan başka bir Firewall Builder mevcut.<br/><b>Kullanıcı : </b>" + self.active_user) self.btn_kill_fw.setEnabled(True) self.btn_deny_control.setEnabled(False) else: if self.git_status != False: self.btn_deny_control.setEnabled(True) self.btn_kill_fw.setEnabled(False) def set_confirmation_status(self): status = str(CP.get_gitlab_configs()["gitlab_confirmation"]) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with_confirmation = full_path + "installers/" + "with_confirm.py" without_confirmation = full_path + "installers/" + "without_confirm.py" installer = full_path + "installer.py" cmd_cp_with = "cp " + with_confirmation + " " + installer cmd_cp_without = "cp " + without_confirmation + " " + installer if status == "on": subprocess.call([cmd_cp_with], shell=True) else: subprocess.call([cmd_cp_without], shell=True) def auto_refresh(self): self.centralwidget.setEnabled(False) self.lbl_error_start.setText(u"<p></p>") if self.git != False: GC.set_project_id( self.git, CP.get_gitlab_connection()["gitlab_project_name"]) self.auto_check_and_refresh() self.warn_if_fw_runs() self.centralwidget.setEnabled(True) def auto_check_and_refresh(self): new_config = CP.get_configs() check_gitlab_conn = [False, False] check_path = start_fw.check_config_paths(CP.get_path_configs()) if new_config != self.old_config: check_gitlab_conn = GC.check_gitlab_connection( CP.get_gitlab_configs()) else: check_gitlab_conn[0] = True check_gitlab_conn[1] = self.git if check_gitlab_conn[0] == True: if check_gitlab_conn[1] != self.git: self.git = check_gitlab_conn[1] check_gitlab_sett = GC.check_gitlab_settings( self.git, CP.get_gitlab_configs()) if check_path == True and check_gitlab_conn[ 0] == True and check_gitlab_sett == True: self.lbl_error_start.setText("") self.btn_merge_control.setEnabled(True) self.btn_deny_control.setEnabled(True) self.btn_start_fwbuilder.setEnabled(True) self.btn_watch_merge.setEnabled(True) self.auto_check_git_merge(self.git) self.warn_if_fw_runs() return True else: self.git_status = False self.btn_merge_control.setEnabled(False) self.btn_deny_control.setEnabled(False) self.btn_start_fwbuilder.setEnabled(False) self.btn_watch_merge.setEnabled(False) self.lbl_merge_control.setText("") self.lbl_merge_control.setText("") if check_path != True: self.set_error_message(check_path) elif check_gitlab_conn[0] != True: self.set_error_message(check_gitlab_conn[0]) else: self.set_error_message(check_gitlab_sett) return False def auto_check_git_merge(self, git): self.lbl_error_start.setText("<p></p>") self.centralwidget.setEnabled(False) git_status = GC.check_mergerequest( git, CP.get_configs()["gitlab_project_id"]) #<<<<< self.git_status = git_status self.set_last_commit( GC.get_master_commit_id(git, CP.get_configs()["gitlab_project_id"], CP.get_configs()["gitlab_master_branch"])) if git_status == False: self.lbl_merge_control.setText( u"<p>Sistemde onay bekleyen kurallar bulunuyor.<br/>Son durumunu kontrol etmek için lütfen <br/>\"Onay Kontrol\" butonuna basınız.<br/><b>Not:</b> Onayda bekleyen istek olduğu sürece <br/>FWBuilder sadece okunabilir modda çalışacaktır</p>" ) self.btn_deny_control.setEnabled(False) self.btn_watch_merge.setEnabled(True) else: if GC.get_mergerequest_status( git, CP.get_configs()["gitlab_project_id"] ) == "closed" and GC.check_merge_confirm() == True: self.lbl_merge_control.setText( u"<p><b>Son kural değişiklikleri reddedilmiş :</b> <br/>" + git.getmergerequestcomments( CP.get_configs()["gitlab_project_id"], git.getmergerequests(CP.get_configs( )["gitlab_project_id"])[0]["id"])[-1]["note"] + "</p>") elif GC.get_mergerequest_status( git, CP.get_configs()["gitlab_project_id"]) == "merged": self.check_merge_file() self.btn_merge_control.setEnabled(False) self.btn_start_fwbuilder.setEnabled(True) self.btn_deny_control.setEnabled(True) self.btn_watch_merge.setEnabled(True) self.centralwidget.setEnabled(True) def kill_all(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) start_fw.kill_fw() try: start_fw.kill_gui_user(self.current_user) except Exception as e: self.filelogger.send_log( "error", "Error While Killing Previous GUI {}".format(str(e))) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) self.filelogger.send_log( "warning", " previous gui was killed by " + self.current_user + " : gui ") self.btn_kill_fw.setEnabled(False) sleep(2) self.load_new_rules() sleep(3) self.auto_refresh() self.lbl_error_start.setText(u"<b>SONLANDIRILDI</b>")
class Ui_FwStartWindow(QtGui.QWidget): def setupUi(self, FwStartWindow): FwStartWindow.setObjectName(_fromUtf8("FwStartWindow")) FwStartWindow.move(200, 100) FwStartWindow.resize(800, 600) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( FwStartWindow.sizePolicy().hasHeightForWidth()) FwStartWindow.setSizePolicy(sizePolicy) FwStartWindow.setMinimumSize(QtCore.QSize(800, 600)) FwStartWindow.setMaximumSize(QtCore.QSize(800, 600)) FwStartWindow.setStyleSheet( _fromUtf8("background-color: rgb(255, 236, 207);")) self.centralwidget = QtGui.QWidget(FwStartWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.btn_con_set = QtGui.QPushButton(self.centralwidget) self.btn_con_set.setGeometry(QtCore.QRect(340, 430, 181, 50)) self.frame = QtGui.QFrame(self.centralwidget) self.frame.setGeometry(QtCore.QRect(490, 120, 301, 181)) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName(_fromUtf8("frame")) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_con_set.sizePolicy().hasHeightForWidth()) self.btn_con_set.setSizePolicy(sizePolicy) self.btn_con_set.setMinimumSize(QtCore.QSize(160, 50)) self.btn_con_set.setAcceptDrops(False) self.btn_con_set.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_con_set.setObjectName(_fromUtf8("btn_con_set")) self.btn_loc_set = QtGui.QPushButton(self.centralwidget) self.btn_loc_set.setGeometry(QtCore.QRect(150, 430, 181, 50)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_loc_set.sizePolicy().hasHeightForWidth()) self.btn_loc_set.setSizePolicy(sizePolicy) self.btn_loc_set.setMinimumSize(QtCore.QSize(160, 50)) self.btn_loc_set.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_loc_set.setObjectName(_fromUtf8("btn_loc_set")) self.lbl_error_start = QtGui.QLabel(self.centralwidget) self.lbl_error_start.setGeometry(QtCore.QRect(20, 260, 375, 41)) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.lbl_error_start.setFont(font) self.lbl_error_start.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_error_start.setText(_fromUtf8("")) self.lbl_error_start.setObjectName(_fromUtf8("lbl_error_start")) self.btn_kill_fw = QtGui.QPushButton(self.centralwidget) self.btn_kill_fw.setGeometry(QtCore.QRect(10, 300, 51, 50)) self.btn_kill_fw.setMinimumSize(QtCore.QSize(120, 50)) self.btn_kill_fw.setAcceptDrops(False) self.btn_kill_fw.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_kill_fw.setObjectName(_fromUtf8("btn_kill_fw")) self.btn_kill_fw.setEnabled(False) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.progressBar = QtGui.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(120, 10, 571, 31)) self.progressBar.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar.setFont(font) self.progressBar.setStyleSheet(_fromUtf8("")) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName(_fromUtf8("progressBar")) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.lbl_warning = QtGui.QLabel(self.frame) self.lbl_warning.setGeometry(QtCore.QRect(1, 1, 300, 180)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_warning.sizePolicy().hasHeightForWidth()) self.lbl_warning.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily(_fromUtf8("Sans Serif")) font.setPointSize(9) font.setBold(False) font.setItalic(False) font.setWeight(50) font.setStrikeOut(False) font.setStyleStrategy(QtGui.QFont.PreferDefault) self.lbl_warning.setFont(font) self.lbl_warning.setAutoFillBackground(False) self.lbl_warning.setStyleSheet(_fromUtf8("color: rgb(0, 0, 0);")) self.lbl_warning.setLocale( QtCore.QLocale(QtCore.QLocale.Turkish, QtCore.QLocale.Turkey)) self.lbl_warning.setObjectName(_fromUtf8("lbl_warning")) FwStartWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(FwStartWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setStyleSheet(_fromUtf8("")) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu_edit = QtGui.QMenu(self.menubar) self.menu_edit.setObjectName(_fromUtf8("menu_edit")) self.menu_help = QtGui.QMenu(self.menubar) self.menu_help.setObjectName(_fromUtf8("menu_help")) FwStartWindow.setMenuBar(self.menubar) self.action_refresh = QtGui.QAction(FwStartWindow) self.action_refresh.setObjectName(_fromUtf8("action_refresh")) self.action_definitions = QtGui.QAction(FwStartWindow) self.action_definitions.setObjectName(_fromUtf8("action_definitions")) self.action_about = QtGui.QAction(FwStartWindow) self.action_about.setObjectName(_fromUtf8("action_about")) self.action_exit = QtGui.QAction(FwStartWindow) self.action_exit.setObjectName(_fromUtf8("action_exit")) self.menu_edit.addAction(self.action_refresh) self.menu_edit.addAction(self.action_exit) self.menu_help.addAction(self.action_definitions) self.menu_help.addAction(self.action_about) self.menubar.addAction(self.menu_edit.menuAction()) self.menubar.addAction(self.menu_help.menuAction()) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.auto_refresh) self.def_window = None self.about_window = None self.retranslateUi(FwStartWindow) self.child = False self.old_config = {} self.active_user = "******" self.current_user = "******" abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "r") as current_user: self.active_user = current_user.readline() self.full_path = full_path self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) #stylesheets FwStartWindow.setStyleSheet( _fromUtf8("QMainWindow#FwStartWindow {border-image: url(" + full_path + "img/ahtapot_logo.png);}")) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL(_fromUtf8("triggered()")), exit) QtCore.QObject.connect(self.action_refresh, QtCore.SIGNAL(_fromUtf8("triggered()")), self.refresh_method) QtCore.QObject.connect(self.action_definitions, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_def_window) QtCore.QObject.connect(self.action_about, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_about_window) QtCore.QObject.connect(self.btn_loc_set, QtCore.SIGNAL(_fromUtf8("clicked()")), self.start_fwbuilder) QtCore.QObject.connect(self.btn_con_set, QtCore.SIGNAL(_fromUtf8("clicked()")), self.load_new_rules) QtCore.QObject.connect(self.btn_kill_fw, QtCore.SIGNAL(_fromUtf8("clicked()")), self.kill_all) QtCore.QMetaObject.connectSlotsByName(FwStartWindow) def retranslateUi(self, FwStartWindow): FwStartWindow.setWindowTitle( _translate("FwStartWindow", " Ahtapot - GDYS", None)) self.btn_con_set.setText( _translate("FwStartWindow", "Derlenmiş Ayarlar\n" " ile Çalıştır", None)) self.btn_loc_set.setText( _translate("FwStartWindow", "Yerel Ayarlar \n" " ile Çalıştır", None)) self.btn_kill_fw.setText(_translate("FwStartWindow", "Sonlandır", None)) self.lbl_warning.setText( _translate( "FwStartWindow", "<p>Derlenmiş Ayarlar ile Çalıştır<br/>butonu Yerel Ayarların üzerine<br/> yazar!!!.</p>", None)) self.menu_edit.setTitle(_translate("FwStartWindow", "Düzenle", None)) self.menu_help.setTitle(_translate("FwStartWindow", "Yardım", None)) self.action_refresh.setText(_translate("FwStartWindow", "Yenile", None)) self.action_refresh.setShortcut( _translate("MainWindow", "Ctrl+R", None)) self.action_definitions.setText( _translate("FwStartWindow", "Açıklamalar", None)) self.action_definitions.setShortcut( _translate("MainWindow", "Ctrl+D", None)) self.action_about.setText(_translate("FwStartWindow", "Hakkında", None)) self.action_about.setShortcut(_translate("MainWindow", "Ctrl+A", None)) self.action_exit.setText(_translate("FwStartWindow", "Çıkış", None)) self.action_exit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) self.timer.start(3000) def set_windows(self, old, new): self.old_window = old self.new_window = new def show_def_window(self): self.def_window.show() def show_about_window(self): self.about_window.show() def set_error_message(self, message): self.lbl_error_start.setText(message) def start_fwbuilder(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if start_fw.check_if_runs() == False: with open(self.full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) fw_path = CP.get_configs()["fw_path"] start_fw.start_fwbuilder() self.logger.send_log( "info", " Firewall Builder Started with Local settings") self.filelogger.send_log( "info", " Firewall Builder Started with Local settings") else: self.warn_if_fw_runs() subprocess.call([ "xdotool search --name \"Firewall Builder\" windowactivate windowsize 90\% 90\%" ], shell=True) def refresh_method(self): self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() self.lbl_error_start.setText(u"<p></p>") self.warn_if_fw_runs() self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False) def pull_repo(self): fw_path = CP.get_configs()["fw_path"] fwb_file_name = CP.get_configs()["fwb_file_name"] cmd_git_pull = "cd " + fw_path + "&& git pull" cmd_git_checkout = "cd " + fw_path + "&& git checkout " + fwb_file_name subprocess.call([cmd_git_checkout], shell=True) subprocess.call([cmd_git_pull], shell=True) start_fw.kill_fw() fw_path = CP.get_configs()["fw_path"] start_fw.start_fwbuilder() def load_new_rules(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) self.lbl_error_start.setText("<p></p>") if start_fw.check_if_runs() is True: self.warn_if_fw_runs() else: self.progressBar.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar() abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" self.pull_repo() self.logger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.filelogger.send_log( "warning", " Rule Settings pulled from Master and Firewall Builder Started" ) self.centralwidget.setEnabled(True) self.progressBar.setValue(0) self.progressBar.setVisible(False) def set_progressbar(self): self.progressBar.setValue(30) sleep(1) self.progressBar.setValue(60) sleep(1) self.progressBar.setValue(100) def warn_if_fw_runs(self): if start_fw.check_if_runs() == True: with open(self.full_path + "current_user.dmr", "r") as active_user: self.active_user = active_user.readline() self.lbl_error_start.setText( u"<b>UYARI:</b> Şuan kullanılan başka bir Firewall Builder mevcut.<br/><b>Kullanıcı : </b>" + self.active_user) self.btn_kill_fw.setEnabled(True) self.btn_con_set.setEnabled(False) else: self.btn_kill_fw.setEnabled(False) def auto_refresh(self): self.centralwidget.setEnabled(False) self.lbl_error_start.setText(u"<p></p>") self.auto_check_and_refresh() self.warn_if_fw_runs() self.centralwidget.setEnabled(True) def auto_check_and_refresh(self): new_config = CP.get_configs() self.lbl_error_start.setText("") self.btn_con_set.setEnabled(True) self.btn_loc_set.setEnabled(True) self.warn_if_fw_runs() return True def kill_all(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) start_fw.kill_fw() try: start_fw.kill_gui_user(self.current_user) except Exception as e: self.filelogger.send_log( "error", "Error While Killing Previous GUI {}".format(str(e))) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with open(full_path + "current_user.dmr", "w") as current_user: current_user.write(self.current_user) self.filelogger.send_log( "warning", " previous gui was killed by " + self.current_user + " : gui ") self.btn_kill_fw.setEnabled(False) sleep(2) self.load_new_rules() sleep(3) self.auto_refresh() self.lbl_error_start.setText(u"<b>SONLANDIRILDI</b>")
def setupUi(self, FwSettingsWindow): FwSettingsWindow.setObjectName(_fromUtf8("FwSettingsWindow")) FwSettingsWindow.move(250, 150) FwSettingsWindow.resize(740, 530) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( FwSettingsWindow.sizePolicy().hasHeightForWidth()) FwSettingsWindow.setSizePolicy(sizePolicy) FwSettingsWindow.setMinimumSize(QtCore.QSize(740, 530)) FwSettingsWindow.setMaximumSize(QtCore.QSize(740, 530)) FwSettingsWindow.setStyleSheet( _fromUtf8("background-color: rgb(255, 236, 207);")) self.centralwidget = QtGui.QWidget(FwSettingsWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.tabWidget = QtGui.QTabWidget(self.centralwidget) self.tabWidget.setGeometry(QtCore.QRect(20, 90, 711, 401)) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.tab_path = QtGui.QWidget() self.tab_path.setEnabled(False) self.tab_path.setObjectName(_fromUtf8("tab_path")) self.btn_config_save = QtGui.QPushButton(self.tab_path) self.btn_config_save.setGeometry(QtCore.QRect(550, 280, 101, 41)) self.btn_config_save.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_config_save.setObjectName(_fromUtf8("btn_config_save")) self.layoutWidget = QtGui.QWidget(self.tab_path) self.layoutWidget.setGeometry(QtCore.QRect(20, 20, 631, 281)) self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.label_13 = QtGui.QLabel(self.layoutWidget) self.label_13.setObjectName(_fromUtf8("label_13")) self.verticalLayout_2.addWidget(self.label_13) self.label_2 = QtGui.QLabel(self.layoutWidget) self.label_2.setObjectName(_fromUtf8("label_2")) self.verticalLayout_2.addWidget(self.label_2) self.label_12 = QtGui.QLabel(self.layoutWidget) self.label_12.setObjectName(_fromUtf8("label_12")) self.verticalLayout_2.addWidget(self.label_12) self.label_3 = QtGui.QLabel(self.layoutWidget) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout_2.addWidget(self.label_3) self.label_4 = QtGui.QLabel(self.layoutWidget) self.label_4.setObjectName(_fromUtf8("label_4")) self.verticalLayout_2.addWidget(self.label_4) self.label_5 = QtGui.QLabel(self.layoutWidget) self.label_5.setObjectName(_fromUtf8("label_5")) self.verticalLayout_2.addWidget(self.label_5) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.cmb_fw_file_name = QtGui.QComboBox(self.layoutWidget) self.cmb_fw_file_name.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.cmb_fw_file_name.setObjectName(_fromUtf8("cmb_fw_file_name")) self.verticalLayout.addWidget(self.cmb_fw_file_name) self.ledit_fw_copy_path = QtGui.QLineEdit(self.layoutWidget) self.ledit_fw_copy_path.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_fw_copy_path.setObjectName(_fromUtf8("ledit_fw_copy_path")) self.verticalLayout.addWidget(self.ledit_fw_copy_path) self.ledit_std_out_err = QtGui.QLineEdit(self.layoutWidget) self.ledit_std_out_err.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_std_out_err.setObjectName(_fromUtf8("ledit_std_out_err")) self.verticalLayout.addWidget(self.ledit_std_out_err) self.ledit_poc_ip = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_ip.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_ip.setObjectName(_fromUtf8("ledit_poc_ip")) self.verticalLayout.addWidget(self.ledit_poc_ip) self.ledit_poc_user = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_user.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_user.setObjectName(_fromUtf8("ledit_poc_user")) self.verticalLayout.addWidget(self.ledit_poc_user) self.ledit_poc_copy_path = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_copy_path.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_copy_path.setObjectName( _fromUtf8("ledit_poc_copy_path")) self.verticalLayout.addWidget(self.ledit_poc_copy_path) self.ledit_poc_port_number = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_port_number.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_port_number.setObjectName( _fromUtf8("ledit_poc_port_number")) self.verticalLayout.addWidget(self.ledit_poc_port_number) self.horizontalLayout.addLayout(self.verticalLayout) self.progressBar_path = QtGui.QProgressBar(self.tab_path) self.progressBar_path.setGeometry(QtCore.QRect(40, 320, 501, 31)) self.progressBar_path.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar_path.setFont(font) self.progressBar_path.setStyleSheet(_fromUtf8("")) self.progressBar_path.setProperty("value", 0) self.progressBar_path.setObjectName(_fromUtf8("progressBar_path")) self.tabWidget.addTab(self.tab_path, _fromUtf8("")) self.tab_gitlab = QtGui.QWidget() self.tab_gitlab.setEnabled(False) self.tab_gitlab.setObjectName(_fromUtf8("tab_gitlab")) self.layoutWidget_2 = QtGui.QWidget(self.tab_gitlab) self.layoutWidget_2.setGeometry(QtCore.QRect(30, 30, 641, 271)) self.layoutWidget_2.setObjectName(_fromUtf8("layoutWidget_2")) self.horizontalLayout_3 = QtGui.QHBoxLayout(self.layoutWidget_2) self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.verticalLayout_5 = QtGui.QVBoxLayout() self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5")) self.label_11 = QtGui.QLabel(self.layoutWidget_2) self.label_11.setObjectName(_fromUtf8("label_11")) self.verticalLayout_5.addWidget(self.label_11) self.label_15 = QtGui.QLabel(self.layoutWidget_2) self.label_15.setObjectName(_fromUtf8("label_15")) self.verticalLayout_5.addWidget(self.label_15) self.label_16 = QtGui.QLabel(self.layoutWidget_2) self.label_16.setObjectName(_fromUtf8("label_16")) self.verticalLayout_5.addWidget(self.label_16) self.label_17 = QtGui.QLabel(self.layoutWidget_2) self.label_17.setObjectName(_fromUtf8("label_17")) self.verticalLayout_5.addWidget(self.label_17) self.label_18 = QtGui.QLabel(self.layoutWidget_2) self.label_18.setObjectName(_fromUtf8("label_18")) self.verticalLayout_5.addWidget(self.label_18) self.label_19 = QtGui.QLabel(self.layoutWidget_2) self.label_19.setObjectName(_fromUtf8("label_19")) self.verticalLayout_5.addWidget(self.label_19) self.label_20 = QtGui.QLabel(self.layoutWidget_2) self.label_20.setObjectName(_fromUtf8("label_20")) self.verticalLayout_2.addWidget(self.label_20) self.horizontalLayout_4.addLayout(self.verticalLayout_5) self.verticalLayout_6 = QtGui.QVBoxLayout() self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6")) self.ledit_gitlab_url = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_url.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_url.setObjectName(_fromUtf8("ledit_gitlab_url")) self.verticalLayout_6.addWidget(self.ledit_gitlab_url) self.ledit_gitlab_user = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_user.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_user.setObjectName(_fromUtf8("ledit_gitlab_user")) self.verticalLayout_6.addWidget(self.ledit_gitlab_user) self.ledit_gitlab_pass = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_pass.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_pass.setObjectName(_fromUtf8("ledit_gitlab_pass")) self.ledit_gitlab_pass.setEchoMode(QtGui.QLineEdit.Password) self.verticalLayout_6.addWidget(self.ledit_gitlab_pass) self.ledit_confirm_branch = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_confirm_branch.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_confirm_branch.setObjectName( _fromUtf8("ledit_confirm_branch")) self.verticalLayout_6.addWidget(self.ledit_confirm_branch) self.ledit_master_branch = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_master_branch.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_master_branch.setObjectName( _fromUtf8("ledit_master_branch")) self.verticalLayout_6.addWidget(self.ledit_master_branch) self.ledit_project_name = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_project_name.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_project_name.setObjectName(_fromUtf8("ledit_project_name")) self.verticalLayout_6.addWidget(self.ledit_project_name) self.horizontalLayout_4.addLayout(self.verticalLayout_6) self.horizontalLayout_3.addLayout(self.horizontalLayout_4) self.btn_config_save_gitlab = QtGui.QPushButton(self.tab_gitlab) self.btn_config_save_gitlab.setGeometry(QtCore.QRect( 550, 280, 101, 41)) self.btn_config_save_gitlab.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_config_save_gitlab.setObjectName( _fromUtf8("btn_config_save_gitlab")) self.progressBar_gitlab = QtGui.QProgressBar(self.tab_gitlab) self.progressBar_gitlab.setGeometry(QtCore.QRect(40, 320, 501, 31)) self.progressBar_gitlab.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar_gitlab.setFont(font) self.progressBar_gitlab.setStyleSheet(_fromUtf8("")) self.progressBar_gitlab.setProperty("value", 0) self.progressBar_gitlab.setObjectName(_fromUtf8("progressBar_gitlab")) self.tabWidget.addTab(self.tab_gitlab, _fromUtf8("")) self.btn_unlock = QtGui.QPushButton(self.centralwidget) self.btn_unlock.setGeometry(QtCore.QRect(630, 40, 101, 41)) self.btn_unlock.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_unlock.setObjectName(_fromUtf8("btn_unlock")) self.lbl_error_message = QtGui.QLabel(self.centralwidget) self.lbl_error_message.setGeometry(QtCore.QRect(10, 40, 611, 31)) font = QtGui.QFont() font.setFamily(_fromUtf8("Sans Serif")) font.setBold(False) font.setUnderline(True) font.setWeight(50) self.lbl_error_message.setFont(font) self.lbl_error_message.setStyleSheet( _fromUtf8("color: rgb(255, 0, 0);")) self.lbl_error_message.setText(_fromUtf8("")) self.lbl_error_message.setObjectName(_fromUtf8("lbl_error_message")) self.layoutWidget1 = QtGui.QWidget(self.centralwidget) self.layoutWidget1.setGeometry(QtCore.QRect(20, 10, 231, 34)) self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_6 = QtGui.QLabel(self.layoutWidget1) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_2.addWidget(self.label_6) self.cmb_switch_confirm = QtGui.QComboBox(self.layoutWidget) self.cmb_switch_confirm.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.cmb_switch_confirm.setObjectName(_fromUtf8("cmb_fw_file_name")) self.cmb_switch_confirm.setEnabled(False) self.horizontalLayout_2.addWidget(self.cmb_switch_confirm) FwSettingsWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(FwSettingsWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 740, 22)) self.menubar.setStyleSheet(_fromUtf8("")) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu_edit = QtGui.QMenu(self.menubar) self.menu_edit.setStyleSheet(_fromUtf8("")) self.menu_edit.setObjectName(_fromUtf8("menu_edit")) self.menu_help = QtGui.QMenu(self.menubar) self.menu_help.setObjectName(_fromUtf8("menu_help")) FwSettingsWindow.setMenuBar(self.menubar) self.action_exit = QtGui.QAction(FwSettingsWindow) self.action_exit.setObjectName(_fromUtf8("action_exit")) self.menu_definitions = QtGui.QAction(FwSettingsWindow) self.menu_definitions.setObjectName(_fromUtf8("menu_definitions")) self.menu_about = QtGui.QAction(FwSettingsWindow) self.menu_about.setObjectName(_fromUtf8("menu_about")) self.menu_edit.addAction(self.action_exit) self.menu_help.addAction(self.menu_definitions) self.menu_help.addAction(self.menu_about) self.menubar.addAction(self.menu_edit.menuAction()) self.menubar.addAction(self.menu_help.menuAction()) self.retranslateUi(FwSettingsWindow) self.tabWidget.setCurrentIndex(0) self.def_window = None self.about_window = None #QtCore.QObject.connect(FwSettingsWindow, QtCore.SIGNAL(_fromUtf8("destroyed()")), self.close_event) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL(_fromUtf8("triggered()")), FwSettingsWindow.close) #FwSettingsWindow.destroyed.connect(self.close_event) QtCore.QMetaObject.connectSlotsByName(FwSettingsWindow) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" #stylesheets FwSettingsWindow.setStyleSheet( _fromUtf8("QMainWindow#FwSettingsWindow {border-image: url(" + full_path + "img/ahtapot_logo.png);}")) self.git = False self.parent = False self.active_user = "******" self.current_user = "******" confirm_list = [u"Açık", u"Kapalı"] self.cmb_switch_confirm.addItems(confirm_list) with open(full_path + "current_user.dmr", "r") as current_user: self.active_user = current_user.readline() self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) QtCore.QObject.connect(self.btn_unlock, QtCore.SIGNAL(_fromUtf8("clicked()")), self.unlock_settings) QtCore.QObject.connect( self.cmb_switch_confirm, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(const QString&)")), self.change_confirmation) QtCore.QObject.connect(self.btn_config_save, QtCore.SIGNAL(_fromUtf8("clicked()")), self.save_config_path) QtCore.QObject.connect(self.btn_config_save_gitlab, QtCore.SIGNAL(_fromUtf8("clicked()")), self.save_config_gitlab) QtCore.QObject.connect(self.menu_definitions, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_def_window) QtCore.QObject.connect(self.menu_about, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_about_window) self.set_config_text() self.get_confirmation_status() self.get_file_list()
class Ui_FwSettingsWindow(QtGui.QWidget): def setupUi(self, FwSettingsWindow): FwSettingsWindow.setObjectName(_fromUtf8("FwSettingsWindow")) FwSettingsWindow.move(250, 150) FwSettingsWindow.resize(740, 530) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( FwSettingsWindow.sizePolicy().hasHeightForWidth()) FwSettingsWindow.setSizePolicy(sizePolicy) FwSettingsWindow.setMinimumSize(QtCore.QSize(740, 530)) FwSettingsWindow.setMaximumSize(QtCore.QSize(740, 530)) FwSettingsWindow.setStyleSheet( _fromUtf8("background-color: rgb(255, 236, 207);")) self.centralwidget = QtGui.QWidget(FwSettingsWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.tabWidget = QtGui.QTabWidget(self.centralwidget) self.tabWidget.setGeometry(QtCore.QRect(20, 90, 711, 401)) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.tab_path = QtGui.QWidget() self.tab_path.setEnabled(False) self.tab_path.setObjectName(_fromUtf8("tab_path")) self.btn_config_save = QtGui.QPushButton(self.tab_path) self.btn_config_save.setGeometry(QtCore.QRect(550, 280, 101, 41)) self.btn_config_save.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_config_save.setObjectName(_fromUtf8("btn_config_save")) self.layoutWidget = QtGui.QWidget(self.tab_path) self.layoutWidget.setGeometry(QtCore.QRect(20, 20, 631, 281)) self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.label_13 = QtGui.QLabel(self.layoutWidget) self.label_13.setObjectName(_fromUtf8("label_13")) self.verticalLayout_2.addWidget(self.label_13) self.label_2 = QtGui.QLabel(self.layoutWidget) self.label_2.setObjectName(_fromUtf8("label_2")) self.verticalLayout_2.addWidget(self.label_2) self.label_12 = QtGui.QLabel(self.layoutWidget) self.label_12.setObjectName(_fromUtf8("label_12")) self.verticalLayout_2.addWidget(self.label_12) self.label_3 = QtGui.QLabel(self.layoutWidget) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout_2.addWidget(self.label_3) self.label_4 = QtGui.QLabel(self.layoutWidget) self.label_4.setObjectName(_fromUtf8("label_4")) self.verticalLayout_2.addWidget(self.label_4) self.label_5 = QtGui.QLabel(self.layoutWidget) self.label_5.setObjectName(_fromUtf8("label_5")) self.verticalLayout_2.addWidget(self.label_5) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.cmb_fw_file_name = QtGui.QComboBox(self.layoutWidget) self.cmb_fw_file_name.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.cmb_fw_file_name.setObjectName(_fromUtf8("cmb_fw_file_name")) self.verticalLayout.addWidget(self.cmb_fw_file_name) self.ledit_fw_copy_path = QtGui.QLineEdit(self.layoutWidget) self.ledit_fw_copy_path.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_fw_copy_path.setObjectName(_fromUtf8("ledit_fw_copy_path")) self.verticalLayout.addWidget(self.ledit_fw_copy_path) self.ledit_std_out_err = QtGui.QLineEdit(self.layoutWidget) self.ledit_std_out_err.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_std_out_err.setObjectName(_fromUtf8("ledit_std_out_err")) self.verticalLayout.addWidget(self.ledit_std_out_err) self.ledit_poc_ip = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_ip.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_ip.setObjectName(_fromUtf8("ledit_poc_ip")) self.verticalLayout.addWidget(self.ledit_poc_ip) self.ledit_poc_user = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_user.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_user.setObjectName(_fromUtf8("ledit_poc_user")) self.verticalLayout.addWidget(self.ledit_poc_user) self.ledit_poc_copy_path = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_copy_path.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_copy_path.setObjectName( _fromUtf8("ledit_poc_copy_path")) self.verticalLayout.addWidget(self.ledit_poc_copy_path) self.ledit_poc_port_number = QtGui.QLineEdit(self.layoutWidget) self.ledit_poc_port_number.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_poc_port_number.setObjectName( _fromUtf8("ledit_poc_port_number")) self.verticalLayout.addWidget(self.ledit_poc_port_number) self.horizontalLayout.addLayout(self.verticalLayout) self.progressBar_path = QtGui.QProgressBar(self.tab_path) self.progressBar_path.setGeometry(QtCore.QRect(40, 320, 501, 31)) self.progressBar_path.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar_path.setFont(font) self.progressBar_path.setStyleSheet(_fromUtf8("")) self.progressBar_path.setProperty("value", 0) self.progressBar_path.setObjectName(_fromUtf8("progressBar_path")) self.tabWidget.addTab(self.tab_path, _fromUtf8("")) self.tab_gitlab = QtGui.QWidget() self.tab_gitlab.setEnabled(False) self.tab_gitlab.setObjectName(_fromUtf8("tab_gitlab")) self.layoutWidget_2 = QtGui.QWidget(self.tab_gitlab) self.layoutWidget_2.setGeometry(QtCore.QRect(30, 30, 641, 271)) self.layoutWidget_2.setObjectName(_fromUtf8("layoutWidget_2")) self.horizontalLayout_3 = QtGui.QHBoxLayout(self.layoutWidget_2) self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.verticalLayout_5 = QtGui.QVBoxLayout() self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5")) self.label_11 = QtGui.QLabel(self.layoutWidget_2) self.label_11.setObjectName(_fromUtf8("label_11")) self.verticalLayout_5.addWidget(self.label_11) self.label_15 = QtGui.QLabel(self.layoutWidget_2) self.label_15.setObjectName(_fromUtf8("label_15")) self.verticalLayout_5.addWidget(self.label_15) self.label_16 = QtGui.QLabel(self.layoutWidget_2) self.label_16.setObjectName(_fromUtf8("label_16")) self.verticalLayout_5.addWidget(self.label_16) self.label_17 = QtGui.QLabel(self.layoutWidget_2) self.label_17.setObjectName(_fromUtf8("label_17")) self.verticalLayout_5.addWidget(self.label_17) self.label_18 = QtGui.QLabel(self.layoutWidget_2) self.label_18.setObjectName(_fromUtf8("label_18")) self.verticalLayout_5.addWidget(self.label_18) self.label_19 = QtGui.QLabel(self.layoutWidget_2) self.label_19.setObjectName(_fromUtf8("label_19")) self.verticalLayout_5.addWidget(self.label_19) self.label_20 = QtGui.QLabel(self.layoutWidget_2) self.label_20.setObjectName(_fromUtf8("label_20")) self.verticalLayout_2.addWidget(self.label_20) self.horizontalLayout_4.addLayout(self.verticalLayout_5) self.verticalLayout_6 = QtGui.QVBoxLayout() self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6")) self.ledit_gitlab_url = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_url.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_url.setObjectName(_fromUtf8("ledit_gitlab_url")) self.verticalLayout_6.addWidget(self.ledit_gitlab_url) self.ledit_gitlab_user = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_user.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_user.setObjectName(_fromUtf8("ledit_gitlab_user")) self.verticalLayout_6.addWidget(self.ledit_gitlab_user) self.ledit_gitlab_pass = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_gitlab_pass.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_gitlab_pass.setObjectName(_fromUtf8("ledit_gitlab_pass")) self.ledit_gitlab_pass.setEchoMode(QtGui.QLineEdit.Password) self.verticalLayout_6.addWidget(self.ledit_gitlab_pass) self.ledit_confirm_branch = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_confirm_branch.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_confirm_branch.setObjectName( _fromUtf8("ledit_confirm_branch")) self.verticalLayout_6.addWidget(self.ledit_confirm_branch) self.ledit_master_branch = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_master_branch.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_master_branch.setObjectName( _fromUtf8("ledit_master_branch")) self.verticalLayout_6.addWidget(self.ledit_master_branch) self.ledit_project_name = QtGui.QLineEdit(self.layoutWidget_2) self.ledit_project_name.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.ledit_project_name.setObjectName(_fromUtf8("ledit_project_name")) self.verticalLayout_6.addWidget(self.ledit_project_name) self.horizontalLayout_4.addLayout(self.verticalLayout_6) self.horizontalLayout_3.addLayout(self.horizontalLayout_4) self.btn_config_save_gitlab = QtGui.QPushButton(self.tab_gitlab) self.btn_config_save_gitlab.setGeometry(QtCore.QRect( 550, 280, 101, 41)) self.btn_config_save_gitlab.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_config_save_gitlab.setObjectName( _fromUtf8("btn_config_save_gitlab")) self.progressBar_gitlab = QtGui.QProgressBar(self.tab_gitlab) self.progressBar_gitlab.setGeometry(QtCore.QRect(40, 320, 501, 31)) self.progressBar_gitlab.setVisible(False) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.progressBar_gitlab.setFont(font) self.progressBar_gitlab.setStyleSheet(_fromUtf8("")) self.progressBar_gitlab.setProperty("value", 0) self.progressBar_gitlab.setObjectName(_fromUtf8("progressBar_gitlab")) self.tabWidget.addTab(self.tab_gitlab, _fromUtf8("")) self.btn_unlock = QtGui.QPushButton(self.centralwidget) self.btn_unlock.setGeometry(QtCore.QRect(630, 40, 101, 41)) self.btn_unlock.setStyleSheet( _fromUtf8("background-color: rgb(159, 173, 176);")) self.btn_unlock.setObjectName(_fromUtf8("btn_unlock")) self.lbl_error_message = QtGui.QLabel(self.centralwidget) self.lbl_error_message.setGeometry(QtCore.QRect(10, 40, 611, 31)) font = QtGui.QFont() font.setFamily(_fromUtf8("Sans Serif")) font.setBold(False) font.setUnderline(True) font.setWeight(50) self.lbl_error_message.setFont(font) self.lbl_error_message.setStyleSheet( _fromUtf8("color: rgb(255, 0, 0);")) self.lbl_error_message.setText(_fromUtf8("")) self.lbl_error_message.setObjectName(_fromUtf8("lbl_error_message")) self.layoutWidget1 = QtGui.QWidget(self.centralwidget) self.layoutWidget1.setGeometry(QtCore.QRect(20, 10, 231, 34)) self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_6 = QtGui.QLabel(self.layoutWidget1) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_2.addWidget(self.label_6) self.cmb_switch_confirm = QtGui.QComboBox(self.layoutWidget) self.cmb_switch_confirm.setStyleSheet( _fromUtf8("background-color: rgb(255, 255, 255);")) self.cmb_switch_confirm.setObjectName(_fromUtf8("cmb_fw_file_name")) self.cmb_switch_confirm.setEnabled(False) self.horizontalLayout_2.addWidget(self.cmb_switch_confirm) FwSettingsWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(FwSettingsWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 740, 22)) self.menubar.setStyleSheet(_fromUtf8("")) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu_edit = QtGui.QMenu(self.menubar) self.menu_edit.setStyleSheet(_fromUtf8("")) self.menu_edit.setObjectName(_fromUtf8("menu_edit")) self.menu_help = QtGui.QMenu(self.menubar) self.menu_help.setObjectName(_fromUtf8("menu_help")) FwSettingsWindow.setMenuBar(self.menubar) self.action_exit = QtGui.QAction(FwSettingsWindow) self.action_exit.setObjectName(_fromUtf8("action_exit")) self.menu_definitions = QtGui.QAction(FwSettingsWindow) self.menu_definitions.setObjectName(_fromUtf8("menu_definitions")) self.menu_about = QtGui.QAction(FwSettingsWindow) self.menu_about.setObjectName(_fromUtf8("menu_about")) self.menu_edit.addAction(self.action_exit) self.menu_help.addAction(self.menu_definitions) self.menu_help.addAction(self.menu_about) self.menubar.addAction(self.menu_edit.menuAction()) self.menubar.addAction(self.menu_help.menuAction()) self.retranslateUi(FwSettingsWindow) self.tabWidget.setCurrentIndex(0) self.def_window = None self.about_window = None #QtCore.QObject.connect(FwSettingsWindow, QtCore.SIGNAL(_fromUtf8("destroyed()")), self.close_event) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL(_fromUtf8("triggered()")), FwSettingsWindow.close) #FwSettingsWindow.destroyed.connect(self.close_event) QtCore.QMetaObject.connectSlotsByName(FwSettingsWindow) abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" #stylesheets FwSettingsWindow.setStyleSheet( _fromUtf8("QMainWindow#FwSettingsWindow {border-image: url(" + full_path + "img/ahtapot_logo.png);}")) self.git = False self.parent = False self.active_user = "******" self.current_user = "******" confirm_list = [u"Açık", u"Kapalı"] self.cmb_switch_confirm.addItems(confirm_list) with open(full_path + "current_user.dmr", "r") as current_user: self.active_user = current_user.readline() self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) QtCore.QObject.connect(self.btn_unlock, QtCore.SIGNAL(_fromUtf8("clicked()")), self.unlock_settings) QtCore.QObject.connect( self.cmb_switch_confirm, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(const QString&)")), self.change_confirmation) QtCore.QObject.connect(self.btn_config_save, QtCore.SIGNAL(_fromUtf8("clicked()")), self.save_config_path) QtCore.QObject.connect(self.btn_config_save_gitlab, QtCore.SIGNAL(_fromUtf8("clicked()")), self.save_config_gitlab) QtCore.QObject.connect(self.menu_definitions, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_def_window) QtCore.QObject.connect(self.menu_about, QtCore.SIGNAL(_fromUtf8("triggered()")), self.show_about_window) self.set_config_text() self.get_confirmation_status() self.get_file_list() def retranslateUi(self, FwSettingsWindow): FwSettingsWindow.setWindowTitle( _translate("FwSettingsWindow", " Ahtapot - GDYS - Yapılandırma", None)) self.btn_config_save.setText( _translate("FwSettingsWindow", "Kaydet", None)) self.label_13.setText( _translate("FwSettingsWindow", "Yapılandırma Dosya Adı", None)) self.label_2.setText( _translate("FwSettingsWindow", "Test Betikleri Dizini", None)) self.label_12.setText( _translate("FwSettingsWindow", "Hata Bildirim Dizini", None)) self.label_3.setText( _translate("FwSettingsWindow", "Test Makinesi IP Adresi", None)) self.label_4.setText( _translate("FwSettingsWindow", "Test Makinesi Kullanıcı Adı", None)) self.label_5.setText( _translate("FwSettingsWindow", "Test Makinesi Betik Dizini", None)) self.ledit_fw_copy_path.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Test ortamında çalıştırılacak kural betiklerinin bulunduğu dizin adı</p></body></html>", None)) self.ledit_gitlab_pass.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Onay mekanizmasında kullanılacak GitLab’a bağlantıyı sağlayan kullanıcının parolası</p></body></html>", None)) self.ledit_project_name.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Projenin bulunduğu deponun adı</p></body></html>", None)) self.ledit_master_branch.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Onaylanmış kuralların bulunduğu dalın adı</p></body></html>", None)) self.ledit_confirm_branch.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Onaya gönderilen kuralların bulunduğu dalın adı</p></body></html>", None)) self.ledit_gitlab_user.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Onay mekanizmasında kullanılacak GitLab’a bağlantıyı sağlayan kullanıcının adı</p></body></html>", None)) self.ledit_gitlab_url.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Onay mekanizması için kullanılacak GitLab’ın bağlantı adresi</p></body></html>", None)) self.ledit_poc_user.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Ip tables kurallarının söz dizimi bakımından test edileceği makinanın kullanıcı adı</p></body></html>", None)) self.ledit_poc_ip.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Ip tables kurallarının söz dizimi bakımından test edileceği makinanın IP adresi</p></body></html>", None)) self.ledit_poc_port_number.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Ip tables kurallarının söz dizimi bakımından test edileceği makinanın Port Numarası</p></body></html>", None)) self.ledit_poc_copy_path.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>FirewallBuilder tarafından üretilen ve söz dizimi bakımından test edilecek betikerin kopyalandığı dizin adı</p></body></html>", None)) self.ledit_std_out_err.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>Test sırasında söz dizimi hatası bulunması durumunda hata çıktılarının yazıldığı dizin adı</p></body></html>", None)) self.cmb_fw_file_name.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>FirewallBuilder tarafından açılacak olan yapılandırma dosyasının adı</p></body></html>", None)) self.cmb_switch_confirm.setToolTip( _translate( "FwSettingsWindow", "<html><head/><body><p>FirewallBuilder’dan yazılacak kuralların onay mekanizmasına tabii olup olmayacağını belirten ayar</p></body></html>", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_path), _translate("FwSettingsWindow", "Dizin Yapılandırma", None)) self.label_11.setText( _translate("FwSettingsWindow", "GitLab Bağlantı Adresi", None)) self.label_15.setText( _translate("FwSettingsWindow", "GitLab Kullanıcı Adı", None)) self.label_16.setText( _translate("FwSettingsWindow", "GitLab Kullanıcı Parolası", None)) self.label_17.setText( _translate("FwSettingsWindow", "GitLab Onay Dalı", None)) self.label_18.setText( _translate("FwSettingsWindow", "GitLab Ana Dal", None)) self.label_19.setText( _translate("FwSettingsWindow", "GitLab Proje Adı", None)) self.label_20.setText( _translate("FwSettingsWindow", "Test Makinesi Port Numarası", None)) self.btn_config_save_gitlab.setText( _translate("FwSettingsWindow", "Kaydet", None)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.tab_gitlab), _translate("FwSettingsWindow", "Gitlab Yapılandırma", None)) self.btn_unlock.setText( _translate("FwSettingsWindow", "Kilidi Aç", None)) self.label_6.setText( _translate("FwSettingsWindow", "Onay Mekanizması :", None)) self.menu_edit.setTitle(_translate("FwSettingsWindow", "Düzenle", None)) self.menu_help.setTitle(_translate("FwSettingsWindow", "Yardım", None)) self.action_exit.setText(_translate("FwSettingsWindow", "Çıkış", None)) self.action_exit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) self.menu_definitions.setText( _translate("FwSettingsWindow", "Açıklamalar", None)) self.menu_definitions.setShortcut( _translate("MainWindow", "Ctrl+D", None)) self.menu_about.setText( _translate("FwSettingsWindow", "Hakkında", None)) self.menu_about.setShortcut(_translate("MainWindow", "Ctrl+A", None)) def set_windows(self, old, new): self.old_window = old self.new_window = new def change_windows(self): self.new_window.show() def show_def_window(self): self.def_window.show() def show_about_window(self): self.about_window.show() def close_event(self): self.old_window.show() self.new_window.hide() def set_error_message(self, message): self.lbl_error_message.setText(message) def set_config_text(self): self.ledit_fw_copy_path.setText(CP.get_configs()["fw_copy_path"]) self.ledit_poc_user.setText(CP.get_configs()["poc_user"]) self.ledit_poc_ip.setText(CP.get_configs()["poc_ip"]) self.ledit_poc_port_number.setText(CP.get_configs()["port_number"]) self.ledit_poc_copy_path.setText(CP.get_configs()["poc_copy_location"]) self.ledit_std_out_err.setText(CP.get_configs()["std_out_err"]) self.ledit_gitlab_url.setText(CP.get_configs()["gitlab_url"]) self.ledit_gitlab_user.setText(CP.get_configs()["gitlab_user"]) self.ledit_gitlab_pass.setText(CP.get_configs()["gitlab_pass"]) self.ledit_confirm_branch.setText( CP.get_configs()["gitlab_confirm_branch"]) self.ledit_master_branch.setText( CP.get_configs()["gitlab_master_branch"]) self.ledit_project_name.setText( CP.get_configs()["gitlab_project_name"]) def save_config_path(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) config_paths = {} config_paths["fwb_file_name"] = str( self.cmb_fw_file_name.currentText()) config_paths["fw_copy_path"] = self.ledit_fw_copy_path.text() config_paths["poc_user"] = self.ledit_poc_user.text() config_paths["poc_ip"] = self.ledit_poc_ip.text() config_paths["port_number"] = self.ledit_poc_port_number.text() config_paths["poc_copy_location"] = self.ledit_poc_copy_path.text() config_paths["std_out_err"] = self.ledit_std_out_err.text() self.progressBar_path.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar(self.progressBar_path) CP.set_path_config(config_paths) self.logger.send_log("warning", " path configs changed") self.filelogger.send_log("warning", " path configs changed") result = self.check_and_refresh() self.centralwidget.setEnabled(True) self.progressBar_path.setValue(0) self.progressBar_path.setVisible(False) if result == True: self.lbl_error_message.setText( u"<p>Ayarlarınız başarılı bir şekilde kaydedildi.</p>") def save_config_gitlab(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) config_gitlab = {} config_gitlab["url"] = self.ledit_gitlab_url.text() config_gitlab["user"] = self.ledit_gitlab_user.text() config_gitlab["pass"] = self.ledit_gitlab_pass.text() config_gitlab["confirm_branch"] = self.ledit_confirm_branch.text() config_gitlab["master_branch"] = self.ledit_master_branch.text() config_gitlab["project_name"] = self.ledit_project_name.text() self.progressBar_gitlab.setVisible(True) self.centralwidget.setEnabled(False) self.set_progressbar(self.progressBar_gitlab) CP.set_gitlab_config(config_gitlab) self.logger.send_log("warning", " gitlab configs changed") self.filelogger.send_log("warning", " gitlab configs changed") result = self.check_and_refresh() self.centralwidget.setEnabled(True) self.progressBar_gitlab.setValue(0) self.progressBar_gitlab.setVisible(False) if result == True: self.lbl_error_message.setText( u"<p>Ayarlarınız başarılı bir şekilde kaydedildi.</p>") def set_progressbar(self, progressbar): progressbar.setValue(30) sleep(1) progressbar.setValue(60) sleep(1) progressbar.setValue(100) def check_and_refresh(self): check_path = start_fw.check_config_paths(CP.get_path_configs()) check_gitlab_conn = GC.check_gitlab_connection(CP.get_gitlab_configs()) self.lbl_error_message.setText("") if check_gitlab_conn[0] == True: self.git = check_gitlab_conn[1] check_gitlab_sett = GC.check_gitlab_settings( self.git, CP.get_gitlab_configs()) if check_path == True and check_gitlab_conn[ 0] == True and check_gitlab_sett == True: self.lbl_error_message.setText("") self.parent.btn_merge_control.setEnabled(True) self.parent.btn_deny_control.setEnabled(True) self.parent.btn_start_fwbuilder.setEnabled(True) self.parent.btn_watch_merge.setEnabled(True) self.parent.check_and_refresh() return True else: self.parent.btn_merge_control.setEnabled(False) self.parent.btn_deny_control.setEnabled(False) self.parent.btn_start_fwbuilder.setEnabled(False) self.parent.btn_watch_merge.setEnabled(False) self.parent.lbl_merge_control.setText(u"") self.lbl_error_message.setText("") if check_path != True: self.set_error_message(check_path) elif check_gitlab_conn[0] != True: self.set_error_message(check_gitlab_conn[0]) else: self.set_error_message(check_gitlab_sett) return False def get_confirmation_status(self): status = str(CP.get_gitlab_configs()["gitlab_confirmation"]) if status == "on": self.cmb_switch_confirm.setCurrentIndex(0) else: self.cmb_switch_confirm.setCurrentIndex(1) def change_confirmation(self): status = self.cmb_switch_confirm.currentIndex() abs_path = os.path.abspath(__file__) path_list = abs_path.split("/") del path_list[-1] path_name = "/".join(path_list) full_path = path_name + "/" with_confirmation = full_path + "installers/" + "with_confirm.py" without_confirmation = full_path + "installers/" + "without_confirm.py" installer = full_path + "installer.py" cmd_cp_with = "cp " + with_confirmation + " " + installer cmd_cp_without = "cp " + without_confirmation + " " + installer if status == 0: config = {} config["confirmation"] = "on" CP.set_gitlab_config(config) subprocess.call([cmd_cp_with], shell=True) else: config = {} config["confirmation"] = "off" CP.set_gitlab_config(config) subprocess.call([cmd_cp_without], shell=True) def unlock_settings(self): if self.cmb_switch_confirm.isEnabled() == True: self.tab_gitlab.setEnabled(False) self.tab_path.setEnabled(False) self.cmb_switch_confirm.setEnabled(False) self.btn_unlock.setText(u"Kilidi Aç") else: text, ok = QtGui.QInputDialog.getText( self, u"Giriş Yapınız", u"Root parolasını giriniz : ", QtGui.QLineEdit.Password) if ok: root_pass = str(text) res = self.pam_login('root', root_pass) if res == True: self.tab_gitlab.setEnabled(True) self.tab_path.setEnabled(True) self.cmb_switch_confirm.setEnabled(True) self.btn_unlock.setText(u"Kilitle") else: QtGui.QMessageBox.warning(self, 'Hata', u'Hatalı Giriş Bilgileri', QtGui.QMessageBox.Ok) def get_file_list(self): self.logger = Syslogger("FWBUILDER-AHTAPOT", '%(name)s %(levelname)s %(message)s', "/dev/log", self.current_user) self.filelogger = Filelogger( "FWBUILDER-AHTAPOT", '%(asctime)s %(name)s %(levelname)s %(message)s', "/var/log/ahtapot/gdys-gui.log", "a", self.current_user) fw_path = CP.get_path_configs()["fw_path"] files = [] fwb_list = [] for (dirpath, dirnames, file_names) in os.walk(fw_path): files.extend(file_names) break for f in files: f_name, f_extension = os.path.splitext(f) if f_extension == ".fwb": fwb_list.append(str(f)) if len(fwb_list) != 0: self.cmb_fw_file_name.addItems(fwb_list) fwb_file_name = CP.get_path_configs()["fwb_file_name"] index = self.cmb_fw_file_name.findText(str(fwb_file_name)) if index != -1: self.cmb_fw_file_name.setCurrentIndex(index) def pam_login(self, username, password): try: child = pexpect.spawn('/bin/su - %s' % (username)) child.expect('Password:'******'su: Authentication failure', username]) child.close() except Exception as exc_err: child.close() print("Error authenticating. Reason: " % (err)) self.logger.send_log( "error", "error found while attempting to login to unlock\n" + str(exc_err)) self.filelogger.send_log( "error", "error found while attempting to login to unlock\n" + str(exc_err)) return False if result == 0: print("Authentication failed for user %s." % (username)) self.logger.send_log("error", "failed login to unlock") self.filelogger.send_log("error", "failed login to unlock") return False else: return True