1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| from bs4 import BeautifulSoup import sys reload(sys) sys.setdefaultencoding( "utf-8" ) import requests import bs4 import sys import io import datetime import commands as cmd
base_url = 'http://10.8.17.24:8080'
log = open('/home/piccism/sapchk/jira_zdsl_gdzc.log','a')
now_time = datetime.datetime.now()
print >>log,now_time
data = {'os_username':'yangwenwei', 'os_password':'1111', 'os_cookie':'true'}
login_url = base_url+'/rest/gadget/1.0/login'
session = requests.Session()
resp = session.post(login_url, data)
query_url = base_url+'/secure/IssueNavigator!executeAdvanced.jspa' query_str = "project = GDZC AND (assignee = aaa or assignee = bbb ) AND status=open" query_data = {'jqlQuery':query_str, 'runQuery':'true'} resp_query = session.post(query_url, query_data)
htmlpage = resp_query.content.decode('utf-8') soup = BeautifulSoup(htmlpage,'lxml')
trs = soup.find_all('tr',{"rel":True}) for tr in trs: rel = tr['rel'] tds = tr.find_all('td') issuekey = tds[1].find('a').string assignee = tds[3].find('a').string status = tds[5].contents[2].strip() logstr = 'new job ' +rel+' '+issuekey+' '+assignee+' '+status print >>log,logstr if assignee != 'zvb': get_url = base_url+'/secure/AssignIssue.jspa?id='+rel+'&assignee=yangwenwei' session.get(get_url) get_url = base_url+'/secure/WorkflowUIDispatcher.jspa?id='+rel+'&action=4' session.get(get_url) else: get_url = base_url+'/secure/WorkflowUIDispatcher.jspa?id='+rel+'&action=4' session.get(get_url)
log.close()
|