]> andersk Git - jira-zephyrbot.git/commitdiff
Make initialization and login into functions.
authorAnders Kaseorg <andersk@mit.edu>
Fri, 13 Feb 2009 08:47:15 +0000 (03:47 -0500)
committerAnders Kaseorg <andersk@mit.edu>
Fri, 13 Feb 2009 08:47:15 +0000 (03:47 -0500)
jirabot.py

index 15ca6314c6e3908dfe4e90eb696e83318fcecbfb..9d36e910f01bacb6cc2e11d96fc2203e1e20dbda 100755 (executable)
@@ -17,23 +17,23 @@ zephyr_sender = 'jira'
 zephyr_class = 'andersk-test'
 time_file = 'jirabot.time'
 
-b = mechanize.Browser()
-b.set_handle_robots(False)
-b.add_client_certificate("https://idp.mit.edu:9443", "cert.pem", "cert.pem")
-b.addheaders = [("Accept-Language", "en-us,en;q=0.5"),]
-b.open("https://jira.mit.edu/jira/secure/Dashboard.jspa")
-b.follow_link(text="MIT Touchstone")
-b.select_form("wayfForm1")
-b.submit()
-b.select_form(predicate=lambda f: any(c.name == 'login_certificate'
-                                      for c in f.controls))
-b.submit()
-b.select_form(nr=0)
-b.submit()
-b.open("https://jira.mit.edu/jira/sr/jira.issueviews:searchrequest-rss/temp/SearchRequest.xml?&pid=10185&updated%3Aprevious=-1w&sorter/field=updated&sorter/order=DESC&tempMax=1000")
-issues_rss = b.response().read()
-b.open("https://jira.mit.edu/jira/sr/jira.issueviews:searchrequest-comments-rss/temp/SearchRequest.xml?&pid=10185&updated%3Aprevious=-1w&sorter/field=updated&sorter/order=DESC&tempMax=1000")
-comments_rss = b.response().read()
+def jira_init():
+    b = mechanize.Browser()
+    b.set_handle_robots(False)
+    b.add_client_certificate("https://idp.mit.edu:9443", "cert.pem", "cert.pem")
+    b.addheaders = [("Accept-Language", "en-us,en;q=0.5"),]
+    return b
+
+def jira_login(b):
+    b.open("https://jira.mit.edu/jira/secure/Dashboard.jspa")
+    b.follow_link(text="MIT Touchstone")
+    b.select_form("wayfForm1")
+    b.submit()
+    b.select_form(predicate=lambda f: any(c.name == 'login_certificate'
+                                          for c in f.controls))
+    b.submit()
+    b.select_form(nr=0)
+    b.submit()
 
 def parse_issue(e):
     issue = urlparse.urlparse(e.id)[2].rsplit('/', 1)[1]
@@ -78,6 +78,14 @@ def zerror(msg):
         fields=['Jira bot error', msg]
     )
 
+b = jira_init()
+
+jira_login(b)
+b.open("https://jira.mit.edu/jira/sr/jira.issueviews:searchrequest-rss/temp/SearchRequest.xml?&pid=10185&updated%3Aprevious=-1w&sorter/field=updated&sorter/order=DESC&tempMax=1000")
+issues_rss = b.response().read()
+b.open("https://jira.mit.edu/jira/sr/jira.issueviews:searchrequest-comments-rss/temp/SearchRequest.xml?&pid=10185&updated%3Aprevious=-1w&sorter/field=updated&sorter/order=DESC&tempMax=1000")
+comments_rss = b.response().read()
+
 time_file_new = time_file + '.' + ''.join(random.sample(string.letters, 8))
 
 try:
This page took 0.272501 seconds and 5 git commands to generate.