def CreateWindow(self): self.path_change_win = GUILibraries.QDialog()
def LaunchGUI(self, arg): app = GUILibraries.QApplication(arg) app.MainFixityWindow = App.ProjectGUI.ProjectGUI() app.MainFixityWindow.show() app.exec_()
def Save(self): try: self.Fixity = SharedApp.SharedApp.App except: pass msgBox = GUILibraries.QLabel('Loading') selected_project = self.projects.currentText() algo_value_selected = self.methods.currentText() if selected_project is None or selected_project == '': self.notification.showError( self, "Warning", GUILibraries.messages['no_project_selected']) return project_core = self.Fixity.ProjectRepo.getSingleProject( str(selected_project)) if project_core.getAlgorithm() == algo_value_selected: self.notification.showWarning( self, "Failure", GUILibraries.messages['already_using_algorithm']) return last_dif_paths_info = self.Fixity.Database.select( self.Fixity.Database._tableProject, '*', "`id` = '" + str(id) + "' OR `title` like '" + project_core.getTitle() + "'") try: project_core.setLast_dif_paths( str(last_dif_paths_info[0]['lastDifPaths'])) project_core.setFilters(str(last_dif_paths_info[0]['filters'])) project_core.setAlgorithm( str(last_dif_paths_info[0]['selectedAlgo'])) #project_core.setProject_ran_before(str(last_dif_paths_info[0]['projectRanBefore'])) except: pass msgBox.setWindowTitle("Processing ....") msgBox.setText("Reading Files, please wait ...") msgBox.show() GUILibraries.QCoreApplication.processEvents() project_core.SaveSchedule() result_of_all_file_confirmed = {} if not (project_core.getProject_ran_before() == 0 or project_core.getProject_ran_before() == '0' or project_core.getProject_ran_before() == '' or project_core.getProject_ran_before() == 'None' or project_core.getProject_ran_before() is None): if project_core.getProject_ran_before( ) == 1 or project_core.getProject_ran_before() == '1': result_of_all_file_confirmed = project_core.Run(True) else: result_of_all_file_confirmed['file_changed_found'] = False else: result_of_all_file_confirmed['file_changed_found'] = False msgBox.close() if bool(result_of_all_file_confirmed['file_changed_found']): self.notification.showWarning( self, 'Failure', GUILibraries.messages['alog_not_changed_mail']) email_config = self.Fixity.Configuration.getEmailConfiguration() try: if email_config['smtp'] != '' and email_config[ 'smtp'] is not None: email_notification = EmailNotification.EmailNotification() if project_core.getEmail_address( ) != '' and project_core.getEmail_address() is not None: try: project_name = project_core.getTitle() except: project_name = '' email_notification.ErrorEmail( project_core.getEmail_address(), result_of_all_file_confirmed['report_path'], GUILibraries.messages['alog_not_changed_mail'], email_config, project_name) except: self.Fixity.logger.LogException(Exception.message) pass return update_project_algo = {} update_project_algo['selectedAlgo'] = algo_value_selected self.Fixity.Database.update(self.Fixity.Database._tableProject, update_project_algo, "id='" + str(project_core.getID()) + "'") project_core.setAlgorithm(algo_value_selected) msgBox.setWindowTitle("Processing ....") msgBox.setText("Changing Algorithm, please wait ...") msgBox.show() GUILibraries.QCoreApplication.processEvents() project_core.SaveSchedule() if project_core.getProject_ran_before() == 1: project_core.Run(False, False, True) msgBox.close() SharedApp.SharedApp.App = self.Fixity self.notification.showInformation( self, "Success", selected_project + "'s " + GUILibraries.messages['algorithm_success']) self.Cancel()
def SetDesgin(self): self.GetLayout().addStrut(200) self.Fixity.Configuration.fetchEmailConfiguration() self.email_addr_bar = GUILibraries.QLineEdit() self.out_going_mail_server = GUILibraries.QLineEdit() self.port = GUILibraries.QLineEdit() self.password = GUILibraries.QLineEdit() self.SSL_protocol = GUILibraries.QRadioButton("SSL Protocols") self.TLS_protocol = GUILibraries.QRadioButton("TLS Protocols") self.none_protocol = GUILibraries.QRadioButton("None") self.password.setEchoMode(GUILibraries.QLineEdit.Password) self.set_information = GUILibraries.QPushButton("Save && Close") self.reset = GUILibraries.QPushButton("Reset") self.check_email = GUILibraries.QPushButton("Check Credentials") self.cancel = GUILibraries.QPushButton("Close Without Saving") self.loader = GUILibraries.QLabel("Sending Email...") self.email_addr_bar.setPlaceholderText("email: [email protected]") self.password.setPlaceholderText("Password") self.out_going_mail_server.setPlaceholderText("smtp.gmail.com") self.port.setPlaceholderText("Port") self.email_addr_bar.setMaximumSize(200, 100) self.password.setMaximumSize(200, 100) self.reset.setMaximumSize(200, 100) self.cancel.setMaximumSize(200, 100) self.set_information.setMaximumSize(200, 100) self.out_going_mail_server.setMaximumSize(200, 100) self.port.setMaximumSize(200, 100) self.check_email.setMaximumSize(200, 100) self.SMTP_server_lable = GUILibraries.QLabel('SMTP Server') self.email_address_lable = GUILibraries.QLabel('Email Address') self.password_lable = GUILibraries.QLabel('Password') self.port_lable = GUILibraries.QLabel('Port') self.encryption_lable = GUILibraries.QLabel('Encryption Method') self.GetLayout().addWidget(self.loader) self.GetLayout().addWidget(self.SMTP_server_lable) self.GetLayout().addWidget(self.out_going_mail_server) self.GetLayout().addWidget(self.email_address_lable) self.GetLayout().addWidget(self.email_addr_bar) self.GetLayout().addWidget(self.password_lable) self.GetLayout().addWidget(self.password) self.GetLayout().addWidget(self.port_lable) self.GetLayout().addWidget(self.port) self.GetLayout().addWidget(self.encryption_lable) self.GetLayout().addWidget(self.SSL_protocol) self.GetLayout().addWidget(self.TLS_protocol) self.GetLayout().addWidget(self.none_protocol) self.GetLayout().addWidget(self.set_information) self.GetLayout().addWidget(self.check_email) self.GetLayout().addWidget(self.reset) self.GetLayout().addWidget(self.cancel) self.loader.hide() self.reset.clicked.connect(self.ResetForm) self.set_information.clicked.connect(self.Save) self.cancel.clicked.connect(self.CloseClick) self.check_email.clicked.connect(self.checkIsEmailValid) self.SSL_protocol.clicked.connect(self.SSL_protocolConif) self.TLS_protocol.clicked.connect(self.TLS_protocolConif) self.none_protocol.clicked.connect(self.none_protocolConif) self.SetWindowLayout() information = self.Fixity.Configuration.getEmailConfiguration() self.out_going_mail_server.setText('smtp.gmail.com') self.setInformation(information) self.TLS_protocol.setChecked(True) self.TLS_protocol.click() try: if information is not None and len( information) > 0 and information['smtp'] != None: self.setInformation(information) except: pass
def createDirectories(self): self.mail_layout = GUILibraries.QVBoxLayout() self.mail_layout.setSpacing(0) self.mail_text_fields = [] self.dirs_layout = GUILibraries.QVBoxLayout() self.dirs_layout.setSpacing(0) self.dirs_text_fields, self.browse_dirs, self.bin_of_dirs = [], [], [] for n in xrange( 0, self.Fixity.Configuration.getNumberOfPathDirectories()): hbox = GUILibraries.QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) hbox.setSpacing(0) self.dirs_text_fields.append(GUILibraries.QLineEdit()) self.browse_dirs.append(GUILibraries.QPushButton('...')) self.bin_of_dirs.append(GUILibraries.QPushButton('X')) self.browse_dirs[n].setFixedSize(30, 21) self.dirs_text_fields[n].setContentsMargins(0, 2, 7, 0) self.dirs_text_fields[n].setFixedSize(150, 22) self.bin_of_dirs[n].setFixedSize(25, 22) self.bin_of_dirs[n].setStyleSheet( 'QPushButton {color: red; font: bold} ') self.browse_dirs[n].clicked.connect(self.pickDir) self.dirs_text_fields[n].textChanged.connect(self.changed) self.bin_of_dirs[n].clicked.connect(self.removeDirs) hbox.addWidget(self.dirs_text_fields[n]) hbox.addWidget(self.browse_dirs[n]) hbox.addWidget(self.bin_of_dirs[n]) self.dirs_layout.addLayout(hbox) self.mail_text_fields.append(GUILibraries.QLineEdit()) self.mail_layout.addWidget(self.mail_text_fields[n]) self.dirs_text_fields[n].setReadOnly(True) self.dirs = GUILibraries.QGroupBox("Directories") self.dirs.setFixedSize(273, 289) self.mail = GUILibraries.QGroupBox("Recipient Email Addresses") self.dirs.setLayout(self.dirs_layout) self.mail.setLayout(self.mail_layout) self.main = GUILibraries.QHBoxLayout() self.main.addWidget(self.pgroup) self.main.addWidget(self.scheduling_groupBox) self.main.addWidget(self.dirs) self.main.addWidget(self.mail) self.widget.setLayout(self.main) self.setCentralWidget(self.widget) self.run_only_on_ac_power.setDisabled(False) self.start_when_available.setDisabled(False) self.email_only_when_something_changed.setDisabled(False) self.toggleEmailFields() if len(self.Fixity.ProjectsList) <= 0: self.togglerMenu(True)
def update(self, new='', project_name_force=None): if self.should_update is False: return if self.unsaved: response = self.notification.showQuestion( self, 'Unsaved Project', GUILibraries.messages['new_project_unsaved']) if response: self.should_update = False self.unsaved = False if self.old: try: self.projects.setCurrentRow( self.projects.indexFromItem(self.old).row()) except: self.projects.setCurrentRow(0) pass else: self.projects.setCurrentRow(0) self.should_update = True self.unsaved = True self.old = self.projects.currentItem() return else: selected = int(self.projects.currentIndex().row()) self.unsaved = False self.refreshProjectSettings() self.unsaved = False self.projects.setCurrentRow(selected) try: project_name = self.projects.currentItem().text() except: project_name = '' try: project_core = self.Fixity.ProjectRepo.getSingleProject( project_name) except: self.Fixity.logger.LogException(Exception.message) pass try: if project_core is False: return except: return for n in range(0, self.Fixity.Configuration.getNumberOfPathDirectories()): self.dirs_text_fields[(n)].setText("") self.mail_text_fields[(n)].setText("") self.run_only_on_ac_power.setChecked(False) self.start_when_available.setChecked(False) self.email_only_when_something_changed.setChecked(False) emails = str(project_core.getEmail_address()) emails = emails.split(',') last_run_label = project_core.getLast_ran() countEmail = 0 for email in emails: try: self.mail_text_fields[(countEmail)].setText(str(email).strip()) except: pass countEmail += 1 directories = project_core.getDirectories() for n in directories: try: try: self.dirs_text_fields[(n)].setText( directories[(n)].getPath()) except: self.dirs_text_fields[(n)].setText( str(directories[(n)].getPath()).strip()) pass except: try: self.dirs_text_fields[(n)].setText("") except: pass pass if int(project_core.scheduler.getEmail_only_upon_warning()) == 1: self.email_only_when_something_changed.setChecked(True) elif int(project_core.scheduler.getEmail_only_upon_warning()) == 0: self.email_only_when_something_changed.setChecked(False) if int(project_core.scheduler.getRun_when_on_battery()) == 1: self.run_only_on_ac_power.setChecked(True) elif int(project_core.scheduler.getRun_when_on_battery()) == 0: self.run_only_on_ac_power.setChecked(False) if int(project_core.scheduler.getIf_missed_run_upon_restart()) == 1: self.start_when_available.setChecked(True) elif int(project_core.scheduler.getIf_missed_run_upon_restart()) == 0: self.start_when_available.setChecked(False) if str(project_core.scheduler.getDurationType()) == '1': self.monthly.setChecked(True) self.monthClick() try: self.day_of_month.setValue( int(project_core.scheduler.getRun_day_or_month())) except: self.Fixity.logger.LogException(Exception.message) return elif str(project_core.scheduler.getDurationType()) == '2': self.weekly.setChecked(True) self.weekClick() self.day_of_week.setCurrentIndex( int(project_core.scheduler.getRun_day_or_month())) elif str(project_core.scheduler.getDurationType()) == '3': self.daily.setChecked(True) self.dayClick() try: t = str(project_core.scheduler.getRunTime()).split(':') except: t = ['00', '00'] self.timer.setTime(GUILibraries.QTime(int(t[0]), int(t[1]))) self.timer.timeChanged.connect(self.changed) if last_run_label and last_run_label is not None and last_run_label != 'None': self.lastrun.setText("Last checked:\n" + last_run_label) else: self.lastrun.setText("Last checked:\n --") if new: self.old = new else: self.old = self.projects.currentItem() self.unsaved = False
def creatSchedulingOptions(self): self.scheduling_groupBox = GUILibraries.QGroupBox("Scheduling") self.monthly = GUILibraries.QRadioButton("Monthly") self.weekly = GUILibraries.QRadioButton("Weekly") self.daily = GUILibraries.QRadioButton("Daily") self.run_only_on_ac_power = GUILibraries.QCheckBox( "Run when on battery power") self.start_when_available = GUILibraries.QCheckBox( "If missed, run upon restart") self.email_only_when_something_changed = GUILibraries.QCheckBox( "Email only upon warning or failure") self.run_only_on_ac_power.clicked.connect(self.changed) self.start_when_available.clicked.connect(self.changed) self.email_only_when_something_changed.clicked.connect(self.changed) self.run_only_on_ac_power.setChecked(True) self.start_when_available.setChecked(True) self.email_only_when_something_changed.setChecked(True) self.monthly.clicked.connect(self.monthClick) self.weekly.clicked.connect(self.weekClick) self.daily.clicked.connect(self.dayClick) self.switchDebugger(True) self.scheduling_layout = GUILibraries.QVBoxLayout() self.scheduling_layout.addWidget(self.monthly) self.scheduling_layout.addWidget(self.weekly) self.scheduling_layout.addWidget(self.daily) self.scheduler_run_time = GUILibraries.QLabel("Scheduler Run Time: ") self.scheduling_layout.addWidget(self.scheduler_run_time) self.timer = GUILibraries.QTimeEdit(GUILibraries.QTime()) self.timer.setDisplayFormat(self.Fixity.Configuration.getTimeFormat()) self.scheduling_layout.addWidget(self.timer) self.scheduler_run_on = GUILibraries.QLabel("Scheduler Run On: ") self.scheduling_layout.addWidget(self.scheduler_run_on) self.day_of_week = GUILibraries.QComboBox() self.day_of_week.addItems(self.Fixity.Configuration.getWeekDays()) self.day_of_week.activated.connect(self.changed) self.scheduling_layout.addWidget(self.day_of_week) self.day_of_week.hide() self.day_of_month = GUILibraries.QSpinBox() self.day_of_month.setMaximum(31) self.day_of_month.setMinimum(1) self.day_of_month.valueChanged.connect(self.changed) self.scheduling_layout.addWidget(self.day_of_month) self.day_of_month.hide() self.spacer = GUILibraries.QSpacerItem(125, 30) self.scheduling_layout.addItem(self.spacer) system_information = self.Fixity.Configuration.getWindowsInformation() if self.Fixity.Configuration.getOsType() == 'Windows' and ( str(system_information['WindowsType']) == '7' or str(system_information['WindowsType']) == '10' or str(system_information['WindowsType']) == '8'): self.scheduling_layout.addWidget(self.run_only_on_ac_power) self.scheduling_layout.addWidget(self.start_when_available) self.scheduling_layout.addWidget( self.email_only_when_something_changed) self.lastrun = GUILibraries.QLabel("Last checked: ") self.scheduling_layout.addWidget(self.lastrun) self.scheduling_groupBox.setLayout(self.scheduling_layout) self.scheduling_groupBox.setFixedSize(260, 289)
def __init__(self): super(ProjectGUI, self).__init__() self.should_update = True self.is_path_changed = False self.Fixity = SharedApp.SharedApp.App self.unsaved = False self.about_fixity_gui = AboutFixityGUI.AboutFixityGUI(self) self.apply_filters_gui = ApplyFiltersGUI.ApplyFiltersGUI(self) self.change_algorithm_gui = ChangeAlgorithmGUI.ChangeAlgorithmGUI(self) self.change_name_gui = ChangeNameGUI.ChangeNameGUI(self) self.email_notification_gui = EmailNotificationGUI.EmailNotificationGUI( self) self.import_project_gui = ImportProjGUI.ImportProjectGUI(self) self.path_change_gui = PathChangeGUI.PathChangeGUI(self) self.notification = GUILibraries.NotificationGUI.NotificationGUI() self.setWindowIcon( GUILibraries.QIcon(self.Fixity.Configuration.getLogoSignSmall())) self.setWindowTitle(self.Fixity.Configuration.getApplicationName() + ' ' + self.Fixity.Configuration.getApplicationVersion()) # create Menu self.createMenu() # Set Short Cuts self.setShortCuts() #Set All Menu self.setAllMenus() #Set Trigger self.setTriggersForMenu() #create Project Listing Options self.createProjectListingOption() #create Project scheduling Option self.creatSchedulingOptions() #create Directories and email Listing view self.createDirectories() if len(self.Fixity.ProjectsList) > 0: for project in self.Fixity.ProjectsList: GUILibraries.QListWidgetItem( str(self.Fixity.ProjectsList[project].getTitle()), self.projects) self.projects.setCurrentRow(0) try: self.old = self.projects.itemAt(0, 0) self.update(self.old) self.old.setSelected(True) except: pass self.unsaved = False self.toggler((self.projects.count() == 0)) self.show() self.unsaved = False if self.Fixity.Configuration.getOsType() == 'Windows': # set Fixed Size(Width, Height) self.setFixedSize(900, 318) else: # set Fixed Size(Width, Height) self.setFixedSize(1000, 300)
def createMenu(self): #Creat All Menu self.menubar = self.menuBar() self.file_manu_fixity = self.menubar.addMenu('&File') self.preferences = self.menubar.addMenu('&Preferences') self.new_menu = GUILibraries.QAction('&New Project', self) self.save_menu = GUILibraries.QAction('&Run Now', self) self.update_menu = GUILibraries.QAction('&Save Settings', self) self.delete_menu = GUILibraries.QAction('&Delete Project', self) self.config_email_menu = GUILibraries.QAction('&Email Settings', self) self.about_fixity_menu = GUILibraries.QAction('&About Fixity', self) self.quit_menu = GUILibraries.QAction('&Quit Fixity', self) self.quit_menu.setShortcut(GUILibraries.QKeySequence.Quit) self.filter_files_menu = GUILibraries.QAction('&Filter Files', self) self.change_name_menu = GUILibraries.QAction('&Change Project Name', self) self.decryption_manager_menu = GUILibraries.QAction( '&Select Checksum Algorithm', self) self.debuging_menu = GUILibraries.QAction('&Turn Debuging Off', self) self.import_menu = GUILibraries.QAction('&Import Project', self)