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]
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: