Exemplo n.º 1
0
class Bugzilla(object):
    def __init__(self, url):
        self.url = url
        self.scraper = WebScraper()

    def login(self, login, passwd):
        url = self.url + "/index.cgi"
        post_data = {
            'Bugzilla_login': login,
            'Bugzilla_password': passwd,
            'Bugzilla_restrictlogin': "******",
            'GoAheadAndLogIn': '******'
        }
        content = self.scraper.get_content(url, post_data)
        if content.find("Invalid Username Or Password") == -1:
            return True
        else:
            raise "Invalid Login or Password"

    def get_bugs(self, search):
        url = "%s/buglist.cgi?cmdtype=runnamed&namedcmd=%s&ctype=csv" % (self.url, search.replace(" ", "%20"))

        csv = self.scraper.get_content(url)
        if csv.find("The search named <em>%s</em>" % (search)) != -1:
            raise "Invalid Search Name"

        bugs = []
        tmp_bugs = csv.split("\n")
        columns = tmp_bugs[0].split(",")
        for b in tmp_bugs[1:]:
            b2 = b.split(",")
            bug = {}
            for i, column in enumerate(columns):
                bug[column.replace("\"", "")] = b2[i].replace("\"", "")
            bugs.append(bug)

        return bugs
Exemplo n.º 2
0
 def __init__(self, url):
     self.url = url
     self.scraper = WebScraper()