def __loadButtons__(self, mainFrame): """ Loads the button controls onto the given parent frame """ btnframe = Frame(mainFrame) self.btnFixAvgCost = Button(btnframe, text="Fix Avg Cost", command=self.startThread) self.btnFixAvgCost.pack(side=RIGHT, padx=5) self.btnReset = Button(btnframe, text="Reset", command=self.reset) self.btnReset.pack() btnframe.grid(row=4, column=1, padx=5, pady=10) ''' radioFrame = Frame(mainFrame) radioFrame.grid(row=4, column=1) self.entityType = StringVar() custRadio = Radiobutton(radioFrame, text="Customers", value='Customers', variable=self.entityType, command=self.__switchEntityType) custRadio.invoke() custRadio.pack(side=LEFT) prodRadio = Radiobutton(radioFrame, text="Products", value='Products', variable=self.entityType, command=self.__switchEntityType) #prodRadio.configure(state=DISABLED) prodRadio.pack() self.entityToRadio = { 'Customers' : custRadio, 'Products' : prodRadio }''' ControlUtil.addControl(self.BUTTONS, self.btnFixAvgCost, self.btnReset)
def reset(self): """ Function to reset the state of the GUI. """ self.setStatus("") self.setReadyState() ControlUtil.clearTextBoxes(self.TEXT_BOXES)
def reset(self): """ Function to reset the state of the GUI. """ self.setStatus("") self.setReadyState() ControlUtil.clearTextBoxes(self.TEXT_BOXES) self.paConfirmation.set(0) self.tokenExpiry.set(0) del self.csvList[:] self.csvListbox.delete(0, END) self.csvFileDict = {} self.setResult("")
def __loadCheckListControl__(self, mainFrame): """ Loads the check list controls onto the given parent frame """ checklistFrame = Frame(mainFrame, width=200, height=200, bd=1) #Label(mainFrame, text="Checklist", font="Helvetica 14 bold").grid(row=0, column=3) checklistFrame.grid(row=3, column=1) self.paConfirmation = BooleanVar() self.tokenExpiry = BooleanVar() self.chkPaConfirm = Checkbutton(checklistFrame, text="PA Confirmation", variable=self.paConfirmation) self.chkPaConfirm.grid(row=1, sticky=W) self.chkTokenExpiry = Checkbutton(checklistFrame, text="Token Expiry Set", variable=self.tokenExpiry) self.chkTokenExpiry.grid(row=2, sticky=W) ControlUtil.addControl(self.BUTTONS, self.chkPaConfirm, self.chkTokenExpiry)
def entriesHaveValues(self): """ Returns true/false whether the required input values have been provided """ return ControlUtil.entriesHaveValues( self.TEXT_BOXES) and (len(self.csvList) > 0)
def __loadButtons__(self, mainFrame): """ Loads the button controls onto the given parent frame """ btnframe = Frame(mainFrame) self.btnGetChannels = Button(btnframe, text="Get Channel Events", command=self.startThread) self.btnGetChannels.pack(side=RIGHT, padx=5) self.btnReset = Button(btnframe, text="Reset", command=self.reset) self.btnReset.pack() btnframe.grid(row=3, column=3, padx=0, pady=10, sticky=W) self.btnExportCsv = Button(mainFrame, text="Export CSV") self.btnExportCsv.grid(row=3, column=4, pady=10, sticky=E) self.btnSubmitFeedback = Button(mainFrame, text="Submit Feedback", font="Helvetica 12") self.btnSubmitFeedback.grid(row=1, column=4, sticky=E) ControlUtil.addControl(self.BUTTONS, self.btnGetChannels, self.btnReset)
def __loadUserInputs__(self, mainFrame): """ Loads the user input controls onto the given parent frame """ lblStorePrefix = Label(mainFrame, text="Store Prefix:", font="Helvetica 14 bold") lblStorePrefix.grid(row=1, column=0, sticky=E) lblToken = Label(mainFrame, text="Token:", font="Helvetica 14 bold") lblToken.grid(row=2, column=0, sticky=E) #textboxes self.txtPrefix = Entry(mainFrame) self.txtToken = Entry(mainFrame) self.txtPrefix.grid(row=1,column=1, sticky=W) self.txtToken.grid(row=2,column=1, sticky=W) lblTicketNum = Label(mainFrame, text="Ticket #:", font="Helvetica 14 bold") lblTicketNum.grid(row=3, column=0, sticky=E) self.txtTicketNum = Entry(mainFrame) self.txtTicketNum.grid(row=3, column=1, sticky=W) lblLevel = Label(mainFrame, text="Level:", font="Helvetica 14 bold") lblLevel.grid(row=1, column=1, sticky=E) self.strLevel = StringVar() self.cboLevel = ttk.Combobox(mainFrame, values = ("all", "info", "warning"), state='readonly', textvariable=self.strLevel, width=15) self.cboLevel.set("all") self.cboLevel.grid(row=1, column=2, sticky=W) lblEntityType = Label(mainFrame, text="Entity Type:", font="Helvetica 14 bold") lblEntityType.grid(row=2, column=1, sticky=E) self.strEntityType = StringVar() self.cboEntityType = ttk.Combobox(mainFrame, values = ("all", "product","product_inventory", "product_ingress", "sale"), state='readonly', textvariable=self.strEntityType, width=15) self.cboEntityType.set("product") self.cboEntityType.grid(row=2, column=2, sticky=W) lblEntityid = Label(mainFrame, text="Entity ID:", font="Helvetica 14 bold") lblEntityid.grid(row=3, column=1, sticky=E) self.txtEntityId = Entry(mainFrame, width=25) self.txtEntityId.grid(row=3, column=2, sticky=W) ControlUtil.addControl(self.TEXT_BOXES, self.txtPrefix, self.txtToken, self.txtTicketNum)
def __loadUserInputs__(self, mainFrame): """ Loads the user input controls onto the given parent frame """ lblStorePrefix = Label(mainFrame, text="Store Prefix:", font="Helvetica 14 bold") lblStorePrefix.grid(row=1, column=0, sticky=E) lblToken = Label(mainFrame, text="Token:", font="Helvetica 14 bold") lblToken.grid(row=2, column=0, sticky=E) lblCsv = Label(mainFrame, text="CSV File:", font="Helvetica 14 bold") #lblCsv.grid(row=3, column=0, sticky=E) #textboxes self.txtPrefix = Entry(mainFrame) self.txtToken = Entry(mainFrame) self.txtPrefix.grid(row=1, column=1, sticky=W) self.txtToken.grid(row=2, column=1, sticky=W) ControlUtil.addControl(self.TEXT_BOXES, self.txtPrefix, self.txtToken)
def __loadCsvControl__(self, mainFrame): """ Loads the CSV file controls onto the given parent frame """ self.csvList = [] self.csvFileDict = {} self.csvListbox = Listbox(mainFrame, listvariable=self.csvList, width=25, bd=0.5, selectmode='single') #csvHeader.grid(row=0, column=2) self.csvListbox.grid(row=1, column=2, rowspan=3, padx=10, pady=5) csvFrame = Frame(mainFrame, padx=10) csvHeader = Label(csvFrame, text="CSV Files", font="Helvetica 14 bold") csvHeader.pack(side=LEFT) csvFrame.grid(row=4, column=2, sticky=E) self.btnOpenCsvDialog = Button(csvFrame, text="+", font="Helvetica 14 bold", command=self.openFile, width=3) self.btnOpenCsvDialog.pack(side=LEFT) self.btnDeleteFile = Button(csvFrame, text="-", font="Helvetica 14 bold", command=self.deleteFileFromList, width=3) self.btnDeleteFile.pack() ControlUtil.addControl(self.BUTTONS, self.btnOpenCsvDialog, self.btnDeleteFile)
def process(self, data, base_response): logger.debug("Nmap Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "nmap_scan": target = Utils.get_var("target=\"([\s0-9a-fA-F\.:/\-]+)\"" , data) scan_type = Utils.get_var("type=\"(ping|0|fast|1|normal|2|full|3|custom|4)\"" , data) scan_timming = Utils.get_var("timming=\"(T0|T1|T2|T3|T4|T5)\"" , data) autodect = Utils.get_var("autodetect=\"(enable|disable|enabled|disabled)\"" , data) scan_ports = Utils.get_var("scan_ports=\"([0-9\-\,]+)\"" , data) rdns = Utils.get_var("rdns=\"(enable|disable|enabled|disabled)\"" , data) report_prefix = Utils.get_var("report_prefix=\"([\s0-9a-fA-F\.:/\-]+)\"" , data) if autodect == "": autodect = "enable" if rdns == "": rdns = "disable" if scan_timming == "": scan_timming = "T3" # set the scan type as appropriate if scan_type == "": scan_type = "ping" if report_prefix == "": response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2007))) return response self.__nmap.set_report_prefix(report_prefix) self.__nmap.set_scan_type(scan_type) self.__nmap.set_scan_timming(scan_timming) self.__nmap.set_scan_autodetect(autodect) self.__nmap.set_scan_ports(scan_ports)#only if custom self.__nmap.set_scan_rdsn(rdns) if scan_type == "custom" and scan_ports=="": response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2006))) return response if len(target): if self.__nmap.status() > 0: logger.info("Scan already in progress: %i" % self.__nmap.status()) response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__nmap.set_scan_target(target) self.__nmap.scan_start() response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "nmap_status": if self.__nmap.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__nmap.get_error())) else: response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(0))) elif action == "nmap_reset": self.__nmap.reset_status() if self.__nmap.status() == -1: logger.debug("Previous scan aborted raising errors, please check your logfile.") response.append(base_response + ' %s ackend\n' % ControlError.get(1, str(self.__nmap.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "nmap_report_list": report_files = self.__get_report_file_list(self.__nmap_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "nmap_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) deletestr = Utils.get_var("delete=\"(yes|no|0|1|true\false)\"", data) deletestr = deletestr.lower() delete = False if deletestr in ['yes','1','true']: delete = True # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__nmap.get_working_report_path(): report_response = self.__generate_report(path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) if delete: self.__deleteReport(path) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "nmap_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) deletestr = Utils.get_var("delete=\"(yes|no|0|1|true\false)\"", data) deletestr = deletestr.lower() delete = False if deletestr in ['yes','1','true']: delete = True # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) if delete: self.__deleteReport(path) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "nmap_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list(self.__nmap_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response
def process(self, data, base_response): logger.debug("VAScanner Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "va_scan": target = Utils.get_vars("target=\"([\s0-9a-fA-F\.:/]+)\"", data) if len(target): if self.__vascanner.status() > 0: logger.info("Scan already in progress: %i" % self.__vascanner.status()) response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__vascanner.set_scan_target(target) self.__vascanner.scan_start() response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "va_status": if self.__vascanner.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__vascanner.get_error())) else: response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) elif action == "va_reset": self.__vascanner.reset_status() if self.__vascanner.status() == -1: logger.debug( "Previous scan aborted raising errors, please check your logfile." ) response.append( base_response + ' %s ackend\n' % ControlError.get(1, str(self.__vascanner.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "va_report_list": report_files = self.__get_report_file_list( self.__vascanner_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "va_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__vascanner.get_working_report_path(): report_response = self.__generate_report( path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list( self.__vascanner_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response
def process(self, data, base_response): logger.debug("VAScanner Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "va_scan": target = Utils.get_vars("target=\"([\s0-9a-fA-F\.:/]+)\"" , data) if len(target): if self.__vascanner.status() > 0: logger.info("Scan already in progress: %i" % self.__vascanner.status()) response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__vascanner.set_scan_target(target) self.__vascanner.scan_start() response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "va_status": if self.__vascanner.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__vascanner.get_error())) else: response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) elif action == "va_reset": self.__vascanner.reset_status() if self.__vascanner.status() == -1: logger.debug("Previous scan aborted raising errors, please check your logfile.") response.append(base_response + ' %s ackend\n' % ControlError.get(1, str(self.__vascanner.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "va_report_list": report_files = self.__get_report_file_list(self.__vascanner_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "va_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__vascanner.get_working_report_path(): report_response = self.__generate_report(path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list(self.__vascanner_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response
def setReadyState(self): """ Resets all controls back to normal state.""" ControlUtil.setControlState(self.TEXT_BOXES, NORMAL) ControlUtil.setControlState(self.BUTTONS, NORMAL) self.root.update()
def setDeletingState(self): """ Sets all the controls to disabled state to prevent any multi-clicks""" ControlUtil.setControlState(self.TEXT_BOXES, DISABLED) ControlUtil.setControlState(self.BUTTONS, DISABLED) self.root.update()
def disableCsvButtons(self): ControlUtil.setControlState([self.btnOpenCsvDialog, self.btnDeleteFile], DISABLED)