def _quit(self, event=None): if self.SHUTDOWN_IN_PROGRESS: try: #python 2.7 tkMessageBox.showerror('Error', 'Device Shutdown In Progress\nPlease wait...') except ImportError: #python 3.x messagebox.showerror('Error', 'Device Shutdown In Progress\nPlease wait...') return try: yes = tkMessageBox.askyesno('Exit', 'Do you really want to quit?') except: yes = messagebox.askyesno('Exit', 'Do you really want to quit?') if yes: if self.IS_WIRESHARK_RUNNING: self.logger.debug('Wireshark stopping...') self._send_cmd_to_thread('STOP_WIRESHARK') if self.IS_SITE_SURVEY_RUNNING: self.logger.debug('Site survey stopping...') self._send_cmd_to_thread('STOP_PLINK') self.status_check_thread.join() self.exec_cmd_thread.join() self.destroy()
def __close(self): """Function called when the windows is closed.""" if PY_VERSION == 2: if tkMessageBox.askyesno( "Exit", "Do you want to exit the application?"): self.__application.clear_unfinished_images(self.__user) self.destroy() else: if messagebox.askyesno( "Exit", "Do you want to exit the application?"): self.__application.clear_unfinished_images(self.__user) self.destroy()
def _send_cmd_to_thread(self, cmd=None, *args): self.logger.debug('received cmd: {}'.format(cmd)) if cmd == 'MONITOR_MODE': if self.IS_WIRESHARK_RUNNING or self.IS_SITE_SURVEY_RUNNING: self.logger.debug('Wireshark is running: {}, Site Survey is running: {}'.format(self.IS_WIRESHARK_RUNNING, self.IS_SITE_SURVEY_RUNNING)) try: #python 2.7 tkMessageBox.showerror("Error", "Other Task Running Please Wait...") except ImportError: #python 3.x messagebox.showerror("Error", "Other Task Running Please Wait...") return # Neither Wireshark nor Site Survey is running. #Now changing wifi interface to Monitor mode and set to target Frequency self.IS_FREQUENCY_SET = False channel = self.var_channel_option.get().split()[1] self.logger.debug('Chaning WiFi channel to {}'.format(channel)) mapping_cmd = self.CMD_MAPPING[cmd].substitute(channel=channel) elif cmd == 'WIFI_INFO': mapping_cmd = self.CMD_MAPPING[cmd] else: # for all other commands, wait until device is ready self.IS_DEVICE_READY = self.IS_DEVICE_CONNECTED and self.IS_WIFI_INFO_AVAILABLE and self.IS_FREQUENCY_SET self.logger.debug('device status - Conn: {}, WiFi: {}, Freq: {}'.format(self.IS_DEVICE_CONNECTED, self.IS_WIFI_INFO_AVAILABLE, self.IS_FREQUENCY_SET)) if not self.IS_DEVICE_READY: self.logger.debug('device not ready. just returning...') try: #python 2.7 tkMessageBox.showerror('Error', 'Device Not Ready Yet...') except ImportError: #python 3.x messagebox.showerror('Error', 'Device Not Ready Yet...') return if cmd == 'START_WIRESHARK': if self.IS_SITE_SURVEY_RUNNING: self.logger.debug('site survey is running. do not start wireshark') try: tkMessageBox.showerror('Error', 'Site Survey is running. Please Wait...') except ImportError: messagebox.showerror('Error', 'Site Survey is running. Please Wait...') return filter_expression = self.ent_set_filter.get() if filter_expression and not 'xx:xx:xx:xx:xx:xx' in filter_expression: # this means user entered capture filter option. if not re.search(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', filter_expression, re.I): try: tkMessageBox.showerror('Error', 'Invalid capture filter') except ImportError: messagebox.showerror('Error', 'Invalid capture filter') return else: filter_expression = '"wlan.addr==' + filter_expression + '"' filter_option='"-f"' else: # this means no capture filter set filter_expression = '' filter_option='' self.logger.debug('filter option: {}, filter expression: {}'.format(filter_option, filter_expression)) if not self.IS_WIRESHARK_RUNNING and self.IS_WIRESHARK_INSTALLED: self.IS_WIRESHARK_RUNNING = True mapping_cmd = self.CMD_MAPPING[cmd].substitute(filter_option=filter_option, filter_expression=filter_expression) else: #prevent double-click in short period of time which causes double wireshark launching return elif cmd == 'STOP_WIRESHARK': mapping_cmd = 'taskkill /IM wireshark.exe' from subprocess import call, Popen, PIPE, STDOUT p = Popen(mapping_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT) stdout, stderr = p.communicate() return elif cmd == 'STOP_PLINK': mapping_cmd = 'taskkill /IM plink.exe /F /T' from subprocess import call, Popen, PIPE, STDOUT p = Popen(mapping_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT) stdout, stderr = p.communicate() return elif cmd == 'SITE_SURVEY': if self.IS_WIRESHARK_RUNNING: self.logger.debug('wireshark is running. do not start site survey') try: tkMessageBox.showerror('Error', 'Wireshark is running. Please Wait...') except ImportError: messagebox.showerror.showerror('Error', 'Wireshark is running. Please Wait...') return if not self.IS_SITE_SURVEY_RUNNING: self.IS_SITE_SURVEY_RUNNING = True mapping_cmd = self.CMD_MAPPING[cmd].substitute(timeout=args[0]) else: return elif cmd == 'STOP_DEVICE': # double-confirm try: yes = tkMessageBox.askyesno('Exit', 'Do you really want to shutdown device?') except: yes = messagebox.askyesno('Exit', 'Do you really want to shutdown device??') if not yes: return mapping_cmd = self.CMD_MAPPING[cmd] else: mapping_cmd = self.CMD_MAPPING[cmd] # now send cmd to ExeCmdThread self.logger.debug('send cmd to ExeCmdThread: cmd:{}, mapping_cmd:{}'.format(cmd, mapping_cmd)) self.queue_cmd_request.put((cmd, mapping_cmd))
+ self.gravity = 0 + self.state = "showsplash" + self.splash_time = splash_time + + self.time = time.time() + + # Clear the terminal and print the game title + self.clear_terminal_screen() + print (self.title) + + # Show splash + self.show_splash(self.splash_time) + + # Pop ups + def ask_yes_no(self, title, message): + return messagebox.askyesno(title, message) + + def show_info(self, title, message): + return messagebox.showinfo(title, message) + + def show_warning(self, title, message): + return messagebox.showwarning(title, message) + + def print_error_logs(self): + print ("Error Logs:") + for error in SPGL.logs: + print (error) + + if len(SPGL.logs) == 0: + print ("No errors") + print ("")