本文整理汇总了Python中zenmapCore.UmitLogging.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wrap_file_in_preferred_encoding
def wrap_file_in_preferred_encoding(f):
"""Wrap an open file to automatically decode its contents when reading from
the encoding given by locale.getpreferredencoding, or just return the file
if that doesn't work.
The nmap executable will write its output in whatever the system encoding
is. Nmap's output is usually all ASCII, but time zone it prints can be in a
different encoding. If it is not decoded correctly it will be displayed as
garbage characters. This function assists in reading the Nmap output. We
don't know for sure what the encoding used is, but we take a best guess and
decode the output into a proper unicode object so that the screen display
and XML writer interpret it correctly."""
try:
preferredencoding = locale.getpreferredencoding()
except locale.Error:
# This can happen if the LANG environment variable is set to something
# weird.
preferredencoding = None
if preferredencoding is not None:
try:
reader = codecs.getreader(preferredencoding)
return reader(f, "replace")
except LookupError:
# The lookup failed. This can happen if the preferred encoding is
# unknown ("X-MAC-KOREAN" has been observed). Ignore it and return
# the unwrapped file.
log.debug("Unknown encoding \"%s\"." % preferredencoding)
return f
开发者ID:SiGhTfOrbACQ,项目名称:Kvasir,代码行数:31,代码来源:NmapCommand.py
示例2: __get_it
def __get_it(self, p_name, default):
try:
return config_parser.get(self.section_name, p_name)
except (NoOptionError, NoSectionError):
log.debug(
">>> Using default \"%s\" for \"%s\"." % (default, p_name))
return default
开发者ID:CCrashBandicot,项目名称:nmap,代码行数:7,代码来源:UmitConf.py
示例3: match_profile
def match_profile(self, profile):
log.debug("Match profile: %s" % profile)
log.debug("Comparing: %s == %s ??" % (
str(self.parsed_scan.profile_name).lower(),
"*%s*" % profile.lower()))
return (profile == "*" or profile == "" or
profile.lower() in str(self.parsed_scan.profile_name).lower())
开发者ID:CCrashBandicot,项目名称:nmap,代码行数:7,代码来源:SearchResult.py
示例4: match_option
def match_option(self, option):
log.debug("Match option: %s" % option)
if option == "*" or option == "":
return True
# NOTE: Option matching treats "_" and "-" the same, just like the
# optcmp function in utils.cc . Also, option matching is
# case-sensitive.
option = option.replace("_", "-")
ops = NmapOptions()
ops.parse_string(self.parsed_scan.get_nmap_command())
if "(" in option and ")" in option:
# The syntax allows matching option arguments as
# "opt:option_name(value)". Since we've received only the
# "option_name(value)" part, we need to parse it.
optname = option[:option.find("(")]
optval = option[option.find("(") + 1:option.find(")")]
val = ops["--" + optname]
if val is None:
val = ops["-" + optname]
if val is None:
return False
return str(val) == optval or str(val) == optval
else:
return (ops["--" + option] is not None or
ops["-" + option] is not None)
开发者ID:CCrashBandicot,项目名称:nmap,代码行数:30,代码来源:SearchResult.py
示例5: read
def read(self, filename):
log.debug(">>> Trying to parse: %s" % filename)
if ConfigParser.read(self, filename):
self.filenames = filename
return self.filenames
开发者ID:C40,项目名称:nmap,代码行数:7,代码来源:UmitConfigParser.py
示例6: run_scan
def run_scan(self, stderr = None):
"""Run the command represented by this class."""
# We don't need a file name for stdout output, just a handle. A
# TemporaryFile is deleted as soon as it is closed, and in Unix is
# unlinked immediately after creation so it's not even visible.
f = tempfile.TemporaryFile(mode = "rb", prefix = APP_NAME + "-stdout-")
self.stdout_file = wrap_file_in_preferred_encoding(f)
if stderr is None:
stderr = f
search_paths = self.get_path()
env = dict(os.environ)
env["PATH"] = search_paths
log.debug("PATH=%s" % env["PATH"])
command_list = self.ops.render()
log.debug("Running command: %s" % repr(command_list))
startupinfo = None
if sys.platform == "win32":
# This keeps a terminal window from opening.
startupinfo = subprocess.STARTUPINFO()
try:
startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
except AttributeError:
# This name is used before Python 2.6.5.
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
self.command_process = subprocess.Popen(command_list, bufsize=1,
stdin=subprocess.PIPE,
stdout=f,
stderr=stderr,
startupinfo = startupinfo,
env=env)
开发者ID:SiGhTfOrbACQ,项目名称:Kvasir,代码行数:35,代码来源:NmapCommand.py
示例7: refresh_diff
def refresh_diff(self, widget):
"""This method is called whenever the diff output might have changed,
such as when a different scan was selected in one of the choosers."""
log.debug("Refresh diff.")
if (self.ndiff_process is not None and
self.ndiff_process.poll() is None):
# Put this in the list of old processes we keep track of.
self.old_processes.append(self.ndiff_process)
self.ndiff_process = None
scan_a = self.scan_chooser_a.parsed_scan
scan_b = self.scan_chooser_b.parsed_scan
if scan_a is None or scan_b is None:
self.diff_view.clear()
else:
try:
self.ndiff_process = zenmapCore.Diff.ndiff(scan_a, scan_b)
except OSError, e:
alert = HIGAlertDialog(
message_format=_("Error running ndiff"),
secondary_text=_(
"There was an error running the ndiff program.\n\n"
) + str(e).decode(sys.getdefaultencoding(), "replace"))
alert.run()
alert.destroy()
else:
开发者ID:0x00evil,项目名称:nmap,代码行数:28,代码来源:DiffCompare.py
示例8: verify_execution
def verify_execution(self):
"""This is a callback that is called periodically to refresh the output
check whether any running scans have finished. The timer that schedules
the callback is started in execute_command. When there are no more
running scans, this function returns True so that it won't be scheduled
again."""
self.scan_result.refresh_nmap_output()
finished_jobs = []
for scan in self.jobs:
try:
alive = scan.scan_state()
if alive:
continue
except:
log.debug("Scan terminated unexpectedly: %s" % scan.command)
self.scans_store.fail_running_scan(scan)
else:
log.debug("Scan finished: %s" % scan.command)
self.load_from_command(scan)
scan.close()
self.update_cancel_button()
finished_jobs.append(scan)
# Remove finished jobs from the job list
for finished in finished_jobs:
self.jobs.remove(finished)
del(finished_jobs)
return len(self.jobs) != 0
开发者ID:mogigoma,项目名称:nmap,代码行数:30,代码来源:ScanInterface.py
示例9: refresh_output
def refresh_output(self, widget = None):
"""Update the output from the latest output of the command associated
with this view, as set by set_command_execution. It has no effect if no
command has been set."""
log.debug("Refresh nmap output")
if self.command_execution is None:
return
# Seek to the end of the most recent read.
self.command_execution.stdout_file.seek(self.output_file_pointer)
pos = self.command_execution.stdout_file.tell()
new_output = self.command_execution.stdout_file.read()
self.output_file_pointer = self.command_execution.stdout_file.tell()
# print "read %d -> %d %d" % (pos, self.output_file_pointer, len(new_output))
v_adj = self.scrolled.get_vadjustment()
if new_output and v_adj is not None:
# Find out if the view is already scrolled to the bottom.
at_end = (v_adj.value >= v_adj.upper - v_adj.page_size)
buf = self.text_view.get_buffer()
prev_end_mark = buf.create_mark(None, buf.get_end_iter(), left_gravity = True)
buf.insert(buf.get_end_iter(), new_output)
# Highlight the new text.
self.apply_highlighting(buf.get_iter_at_mark(prev_end_mark), buf.get_end_iter())
if at_end:
# If we were already scrolled to the bottom, scroll back to the
# bottom again. Also do it in an idle handler in case the added
# text causes a scroll bar to appear and reflow the text, making
# the text a bit taller.
self.text_view.scroll_mark_onscreen(self.end_mark)
gobject.idle_add(lambda: self.text_view.scroll_mark_onscreen(self.end_mark))
开发者ID:bluelineXY,项目名称:android_external_nmap,代码行数:34,代码来源:NmapOutputViewer.py
示例10: kill
def kill(self):
"""Kill the nmap subprocess."""
from time import sleep
log.debug(">>> Killing scan process %s" % self.command_process.pid)
if sys.platform != "win32":
try:
from signal import SIGTERM, SIGKILL
os.kill(self.command_process.pid, SIGTERM)
for i in range(10):
sleep(0.5)
if self.command_process.poll() is not None: # Process has been TERMinated
break
else:
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.")
os.kill(self.command_process.pid, SIGKILL)
self.command_process.wait()
except:
pass
else:
try:
import ctypes
ctypes.windll.kernel32.TerminateProcess(
int(self.command_process._handle), -1)
except:
pass
开发者ID:0x00evil,项目名称:nmap,代码行数:27,代码来源:NmapCommand.py
示例11: close
def close(self):
"""Clean up temporary files."""
self.stdout_file.close()
for filename in self.temporary_filenames:
log.debug("Remove temporary diff file %s." % filename)
os.remove(filename)
self.temporary_filenames = []
开发者ID:ParrotSec,项目名称:nmap,代码行数:7,代码来源:Diff.py
示例12: _destroy_callback
def _destroy_callback(window):
open_windows.remove(window)
if len(open_windows) == 0:
gtk.main_quit()
try:
from zenmapCore.UmitDB import UmitDB
except ImportError, e:
log.debug(">>> Not cleaning up database: %s." % str(e))
开发者ID:mogigoma,项目名称:nmap,代码行数:8,代码来源:App.py
示例13: safe_shutdown
def safe_shutdown(signum, stack):
"""Kills any active scans/tabs and shuts down the application."""
log.debug("\n\n%s\nSAFE SHUTDOWN!\n%s\n" % ("#" * 30, "#" * 30))
log.debug("SIGNUM: %s" % signum)
for window in open_windows:
window.scan_interface.kill_all_scans()
sys.exit(signum)
开发者ID:mogigoma,项目名称:nmap,代码行数:9,代码来源:App.py
示例14: match_target
def match_target(self, target):
log.debug("Match target: %s" % target)
for spec in self.parsed_scan.get_targets():
if target in spec:
return True
else:
# We search the (rDNS) hostnames list
for host in self.parsed_scan.get_hosts():
if HostSearch.match_target(host, target):
return True
return False
开发者ID:CCrashBandicot,项目名称:nmap,代码行数:12,代码来源:SearchResult.py
示例15: add_to_host_list
def add_to_host_list(self, host, p):
entry = [
"",
findout_service_icon(p),
host,
host.get_hostname(),
int(p.get("portid", "0")),
p.get("protocol", ""),
p.get("port_state", ""),
get_version_string(p),
]
log.debug(">>> Add Host: %s" % entry)
self.host_list.append(entry)
开发者ID:CoolisTheName007,项目名称:nmap,代码行数:13,代码来源:ScanOpenPortsPage.py
示例16: add_to_port_list
def add_to_port_list(self, p):
entry = [
None,
"",
findout_service_icon(p),
int(p.get("portid", "0")),
p.get("protocol", ""),
p.get("port_state", ""),
p.get("service_name", ""),
get_version_string(p),
]
log.debug(">>> Add Port: %s" % entry)
self.port_list.append(entry)
开发者ID:CoolisTheName007,项目名称:nmap,代码行数:13,代码来源:ScanOpenPortsPage.py
示例17: save_changes
def save_changes(self):
if self.filenames:
log.debug("saving to %s" % self.filenames)
try:
fp = open(self.filenames, 'w')
except Exception as e:
self.failed = e
log.error(">>> Can't save to %s: %s" % (self.filenames, e))
return
self.write(fp)
self.failed = False
else:
log.debug(">>> UmitConfigParser can't save changes: no filename")
开发者ID:EricGershman,项目名称:nmap,代码行数:13,代码来源:UmitConfigParser.py
示例18: __init__
def __init__(self, search_directory, file_extensions=["usr"]):
SearchResult.__init__(self)
log.debug(">>> SearchDir initialized")
self.search_directory = search_directory
if isinstance(file_extensions, StringTypes):
self.file_extensions = file_extensions.split(";")
elif isinstance(file_extensions, list):
self.file_extensions = file_extensions
else:
raise Exception(
"Wrong file extension format! '%s'" % file_extensions)
log.debug(">>> Getting directory's scan results")
self.scan_results = []
files = []
for ext in self.file_extensions:
files += glob(os.path.join(self.search_directory, "*.%s" % ext))
log.debug(">>> Scan results at selected directory: %s" % files)
for scan_file in files:
log.debug(">>> Retrieving scan result %s" % scan_file)
if os.access(scan_file, os.R_OK) and os.path.isfile(scan_file):
try:
parsed = NmapParser()
parsed.parse_file(scan_file)
except:
pass
else:
self.scan_results.append(parsed)
开发者ID:CCrashBandicot,项目名称:nmap,代码行数:31,代码来源:SearchResult.py
示例19: match_port
def match_port(self, ports, port_state):
log.debug("Match port:%s" % ports)
# Transform a comma-delimited string containing ports into a list
ports = filter(lambda not_empty: not_empty, ports.split(","))
for host in self.parsed_scan.get_hosts():
for port in ports:
if not HostSearch.match_port(host.get_ports(), port, port_state):
break
else:
return True
else:
return False
开发者ID:6e6f36,项目名称:nmap,代码行数:14,代码来源:SearchResult.py
示例20: __create_tab
def __create_tab(self, tab_name, section_name, tab):
log.debug(">>> Tab name: %s" % tab_name)
log.debug(">>>Creating profile editor section: %s" % section_name)
vbox = HIGVBox()
if tab.notscripttab: # if notscripttab is set
table = HIGTable()
table.set_row_spacings(2)
section = HIGSectionLabel(section_name)
vbox._pack_noexpand_nofill(section)
vbox._pack_noexpand_nofill(HIGSpacer(table))
vbox.set_border_width(5)
tab.fill_table(table, True)
else:
hbox = tab.get_hmain_box()
vbox.pack_start(hbox, True, True, 0)
self.notebook.append_page(vbox, gtk.Label(tab_name))
开发者ID:mogigoma,项目名称:nmap,代码行数:16,代码来源:ProfileEditor.py
注:本文中的zenmapCore.UmitLogging.log.debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论