def __parse(self): try: parse = xml_parse.parse(self.description_xslt_processed.name, True) parse.description_dir = os.path.dirname(self.description) return parse except Exception as e: raise KiwiDataStructureError('%s: %s' % (type(e).__name__, format(e)))
def __parse(self): try: parse = xml_parse.parse( self.description_xslt_processed.name, True ) parse.description_dir = os.path.dirname(self.description) return parse except Exception as e: raise KiwiDataStructureError( '%s: %s' % (type(e).__name__, format(e)) )
def pythonpost(authorname,projectname): # 解析config文件 os.chdir('D:\\comput\\ftp_file\\'+authorname+'\\'+projectname) user, proj, type, path, main, mail = xml_parse.parse('config.xml') # 参数列表 data_list = {'username': user, 'project': proj, 'type': type, 'path': path, 'main': main, 'mail': mail} r = requests.post('http://127.0.0.1:9010',data=data_list)#'http://192.168.7.106:8077/login'
def gettind_urls(pr=False, get_vk=False): remove_tmp() # k = ('access_token=942fa486fca9443462686cbe93176a8634a4b6aa3197b415264567cc760cd85f3c37c062a643388688128' # '&expires_in=86400' # '&user_id=14921565') print 'getting data' #req = urllib2.Request( # u'https://api.vk.com/method/audio.get', # data=urllib.urlencode({ # u'access_token': u'73d01e0d4800e40f691129598f24de58b87d16e52fa23aa24c2b80cc85c31bdf8ef6f25430bb329b7ec71', # u'owner_id': u'14921565', # u'need_user': 0}) #) #resp = urllib2.urlopen(req) #data = resp.read() #resp_d = json.loads(data) # def dd(data): # path = os.path.join('tmp', data['artist'], data['title'] + '.mp3') # if len(re_apply(path)) != len(path): # print type(path), path, '\n ', re_apply(path), '\n' if get_vk: html = process() with open('vk_com.html', 'wb') as vk: vk.write(html.encode('utf-8')) else: with open('vk_com.html') as vk: html = vk.read().decode('utf-8') if pr: for i in parse(html): for j, k in i.items(): print j, k print print 'creating treads' qe = TaskToThreadPool(10, download) print 'run download' qe.run(parse(html))
def get_report_id(self): data = [('token', self.token), ('cmd', 'get_tasks'), ('usage_type', 'scan'), ('filter', "~" + self.task_name + " apply_overrides=0 min_qod=70 sort=name first=1 rows=10")] res = requests.get(self.gmpurl, cookies=self.cookie_jar, params=data, headers=self.headers, verify=False) #res = requests.get(self.gmpurl, cookies=self.cookie_jar, proxies=self.proxies, params=data,headers=self.headers, verify=False) if res.status_code == 200: parse = xml_parse.parse(res.content.decode('utf-8')) report_id_dict = parse.get_item_attr(".//report") self.report_id = report_id_dict['id'] print("get_report_id_success,id={}".format(self.report_id)) else: print(res.text) raise Exception('[FAIL] Could not parse tasksname')
def login(self): data = [ ('cmd', 'login'), ('login', self.username), ('password', self.password), ] #res = requests.post(self.base, data=data, proxies=self.proxies, cookies=self.cookie_jar, headers=self.headers,verify=False) res = requests.post(self.base, data=data, cookies=self.cookie_jar, headers=self.headers, verify=False) if res.status_code == 200: self.cookie_jar = res.cookies parse = xml_parse.parse(res.content.decode('utf-8')) self.token = parse.get_item_text("token") print("login success,token={}".format(self.token)) else: raise Exception('[FAIL] Could not login to OpenVAS')
if __name__=='__main__': os.chdir(r"D:\Goku.Framework.CoreUI-master\src\main\webapp\upload") while 1: time.sleep(5) for dirpath, dirnames, filenames in os.walk(r"D:\Goku.Framework.CoreUI-master\src\main\webapp\upload"): for filename in filenames: forword, extension = os.path.splitext("D:\\Goku.Framework.CoreUI-master\\src\\main\\webapp\\upload\\"+filename) if extension == '.xml': try: user, proj, type, path, main, mail = xml_parse.parse(filename) data_list = {'username': user, 'project': proj, 'type': type, 'path': path, 'main': main, 'mail': mail} try: requests.post('http://127.0.0.1:9010', data=data_list) os.system("del D:\\Goku.Framework.CoreUI-master\\src\\main\\webapp\\upload\\" + filename) shutil.rmtree("D:\\comput\\ftp_file\\" + user) os.system("del D:\\Goku.Framework.CoreUI-master\\src\\main\\webapp\\upload\\" + proj + ".rar") except: pass except: os.system("del D:\\Goku.Framework.CoreUI-master\\src\\main\\webapp\\upload\\"+filename)