def get_script_list(self, rules, callback): """Start an Nmap subprocess in the background with "--script-help=<rules> -oX -", and set it up to call the given callback when finished.""" ops = NmapOptions() ops.executable = paths_config.nmap_command_path ops["--script-help"] = rules ops["-oX"] = "-" command_string = ops.render_string() # Separate stderr to avoid breaking XML parsing with "Warning: File # ./nse_main.lua exists, but Nmap is using...". stderr = tempfile.TemporaryFile(mode="rb", prefix=APP_NAME + "-script-help-stderr-") log.debug("Script interface: running %s" % repr(command_string)) nmap_process = NmapCommand(command_string) try: nmap_process.run_scan(stderr=stderr) except Exception as e: callback(False, None) stderr.close() return stderr.close() self.script_list_widget.set_sensitive(False) gobject.timeout_add(self.NMAP_DELAY, self.script_list_timer_callback, nmap_process, callback)