def callback_nmon(host, scan_info, queue,output):#Function called by sub thread of PortScannerAsync when an event arrived if re.match(".*-sP.*",scan_info['nmap']['command_line']) : SCAN_TYPE="PING_SCAN" elif re.match(".*-sS.*",scan_info['nmap']['command_line']): SCAN_TYPE="TCP_SCAN" else: SCAN_TYPE="OTHER_SCAN" queue.put(["RES_SCAN",SCAN_TYPE, host, scan_info,xml_to_dict(parsestring(output))])
def resolve(self, makefile, variables, fd, setting): if makefile.parsingfinished: # GNU make allows variables to be set by recursive expansion during # command execution. This seems really dumb to me, so I don't! raise data.DataError("$(eval) not allowed via recursive expansion after parsing is finished", self.loc) stmts = parser.parsestring(self._arguments[0].resolvestr(makefile, variables, setting), 'evaluation from %s' % self.loc) stmts.execute(makefile)
def test_makefiles(self): for mk_file in self.mk_files: print "Parse %s" % os.path.basename(mk_file) f = open(mk_file, 'rt') expected_block = False should_list = [] # read expected block for line in f: if expected_block and expected_end_re.match(line): break if expected_block: should_match = should_re.match(line) if should_match: should_list.append(should_match.groups()) if expected_re.match(line): expected_block = True continue f.seek(0) source = readmk(f) for comments, name, type in parsestring(source): identity = _id(name, type) print makeid_(identity) desc = _desc(name, type) self.assertIn(identity, (_id(x[0], x[1]) for x in should_list), err_("%s not in expected list" % desc)) entry = filter(lambda x: _id(x[0], x[1]) == identity, should_list)[0] should_langs = entry[2].split(',') for lang in comments: self.assertIn(lang, should_langs, err_("lang %s for %s should exists" % (lang, desc))) print lang_(lang) print comment_('\n'.join(comments[lang])) should_langs.remove(lang) for lang in should_langs: self.fail(err_("Lang %s not preset in %s" % (lang, desc))) print should_list = filter(lambda x: _id(x[0], x[1]) != identity, should_list) for x in should_list: self.fail(err_("%s not parsed in makefile" % _desc(x[0], x[1])))