From: Anders Kaseorg Date: Thu, 12 Feb 2009 06:57:11 +0000 (-0500) Subject: Remove obsolete code. X-Git-Url: http://andersk.mit.edu/gitweb/jira-zephyrbot.git/commitdiff_plain/162e61c2b3350911d90dcbbb8f1adc053b6ea88a Remove obsolete code. --- diff --git a/README b/README deleted file mode 100644 index 87a3683..0000000 --- a/README +++ /dev/null @@ -1,2 +0,0 @@ -jirabot2.py sorta works. We need all the headers to prevent weird erros. -Read jirabot.py for interesting impl. details. More docs coming! diff --git a/jirabot.py b/jirabot.py deleted file mode 100644 index 45eeb4d..0000000 --- a/jirabot.py +++ /dev/null @@ -1,75 +0,0 @@ -import zephyr -import feedparser -import pycurl -from BeautifulSoup import BeautifulSoup - -"""Screen scrapes jira.mit.edu. Supposedly. Doesn't actually work yet. - -You need to have a personal certificate named cert.pem in this -directory to run this script. You also need the abovementioned scripts. -The zephyr bindings can be gotten from ebroder's GitHub repository -located: http://github.com/ebroder/python-zephyr/tree/master - -SSL server CA authentication is disabled because we don't know how to -make curl stop complaining. - -Current difficulty is we are causing a NullPointer exception on -(we think) touchstone's servers.""" - -class Browser(object): - def __init__(self, **kwargs): - self.opts = kwargs - self.lastResult = None - def _callback(self, buf): - self.lastResult += buf - def get(self, url): - c = pycurl.Curl() - c.setopt(c.URL, url) - c.setopt(c.WRITEFUNCTION, self._callback) - for k,v in self.opts.items(): - c.setopt(getattr(c, k), v) - self.lastResult = '' - c.perform() - return self.lastResult - def getPage(self, url): - return Page(url, self.get(url), self) - -class Page(object): - def __init__(self, url, contents, browser): - self.url = url - self.soup = BeautifulSoup(contents) - self.browser = browser - def submitForm(self, name, args ={}): - form = self.soup.find(name='form', attrs={"name": name}) - if form == None: return False - dest = form.get('action', self.url) - # this has a lot of edge-cases that don't work - inputs = form.findAll(name='input') - vals = {} - for input in inputs: - vals[input[name]] = input[value] - for k,v in args.items(): - vals[k] = v - return self.browser.getPage() - - -b = Browser( - SSLCERT = "cert.pem", - SSLKEY = "cert.pem", - SSL_VERIFYPEER = 0, - COOKIEJAR = "jirabot.cookie", - FOLLOWLOCATION = 1, - AUTOREFERER = 1, - HTTPHEADER = ["Accept-Language: en-us,en;q=0.5"], -) - -b.get("https://jira.mit.edu/jira/secure/Dashboard.jspa") -page = b.getPage("https://jira.mit.edu/jira/secure/mit_login.jsp?os_destination=/secure/Dashboard.jspa") - -print page.submitForm('wayfForm1') - -#c.setopt(c.URL, "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") - -#d = feedparser.parse(t.contents) -#print d - diff --git a/urllib-cert.py b/urllib-cert.py deleted file mode 100644 index 3781026..0000000 --- a/urllib-cert.py +++ /dev/null @@ -1,26 +0,0 @@ -import urllib2 -import httplib - -cert_file = "cert.pem" -key_file = cert_file - -class HTTPSCertConnection(httplib.HTTPSConnection): - def __init__(self, host): - httplib.HTTPSConnection.__init__(self, host, None, key_file, cert_file) - -class HTTPSCertHandler(urllib2.HTTPSHandler): - def do_open(self, http_class, req): - if http_class is httplib.HTTPSConnection: - http_class = HTTPSCertConnection - return urllib2.HTTPSHandler.do_open(self, http_class, req) - -opener = urllib2.build_opener(urllib2.HTTPRedirectHandler, HTTPSCertHandler) -urllib2.install_opener(opener) - -#req = urllib2.Request(url='https://geofft.scripts.mit.edu:444/detect.php') -#f = urllib2.urlopen(req) -#print f.read() - -req = urllib2.Request(url='https://jira.mit.edu/jira/secure/mit_login.jsp?os_destination=/secure/Dashboard.jspa') -print urllib2.urlopen(req).read() -