def reset(self):
     HTMLGetData.reset(self)
     self.found_root_path = False
     self.result_type = ''
     self.add_path_node('html')
     self.add_path_node('body')
     self.add_path_conditioned_node("div",[('id','content')])
Example #2
0
    def handle_starttag(self, tag, attrs):
        # Injects the needed tags to find the right result when it identifies
        # The type of result being handled
        if self.found_root_path and tag == 'div':
            for attr in attrs:
                if attr[0] == 'class':
                    if attr[1] == 'thanks':
                        self.add_path_conditioned_node("table",
                                                       [('id', 'bugheader')])
                        self.add_path_conditioned_node("tr", [('id', 'title')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'success'
                    elif attr[1] == 'error':
                        self.add_path_conditioned_node("div",
                                                       [('class', 'error')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'error'
                    elif attr[1] == 'warning':
                        self.add_path_conditioned_node("div",
                                                       [('class', 'warning')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'warning'

        HTMLGetData.handle_starttag(self, tag, attrs)
Example #3
0
 def reset(self):
     HTMLGetData.reset(self)
     self.found_root_path = False
     self.result_type = ''
     self.add_path_node('html')
     self.add_path_node('body')
     self.add_path_conditioned_node("div", [('id', 'content')])
    def handle_starttag(self, tag, attrs):
        # Injects the needed tags to find the right result when it identifies
        # The type of result being handled
        if self.found_root_path and tag == 'div':
            for attr in attrs:
                if attr[0] == 'class':
                    if attr[1] == 'thanks':
                        self.add_path_conditioned_node("table",[('id','bugheader')])
                        self.add_path_conditioned_node("tr",[('id','title')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'success'
                    elif attr[1] == 'error':
                        self.add_path_conditioned_node("div",[('class','error')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'error'
                    elif attr[1] == 'warning':
                        self.add_path_conditioned_node("div",[('class','warning')])
                        self.found_root_path = False
                        self.quit_on_done = True
                        self.result_type = 'warning'

        HTMLGetData.handle_starttag(self, tag, attrs)
 def handle_endtag(self, tag):
     HTMLGetData.handle_endtag(self, tag)
def test_connection():

    #Initializes the return value as no error
    ret_val = 'error|Unable to connecto through the Bug System, please proceed through http://bugs.mysql.com/report.php'

    try:
        # Creates the object to open and manage the cookies
        cookieJar = cookielib.CookieJar()
        urlOpener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(cookieJar))

        # Attempts to login
        response = urlOpener.open('http://bugs.mysql.com/index.php')

        # Reads the server response
        data = response.read()

        # Creates the parser to confirm successful login
        parser = HTMLGetData()
        parser.quit_on_done = True
        parser.add_path_node("html")
        parser.add_path_node("body")
        parser.add_path_conditioned_node("div", [('id', 'nav')])
        parser.add_path_node("ul")
        parser.add_path_conditioned_node("li", [('id', 'current')])

        parser.feed(data)

        if len(parser.result) == 1:
            if parser.result[0] == 'Bugs Home':
                ret_val = 'success|'

    except BaseException, e:
        log_error(
            "WB Bug Report",
            'An error occurred while testing conectivity, %s: %s\n' %
            (e.__class__.__name__, str(e)))
def login(opener, user, password):

    ret_val = 'error|Unknown error accessing the bug system'

    try:
        # Encodes the needed information for the login
        params = urllib.urlencode({
            'email': user,
            'password': password,
            'dest': ''
        })

        # Performs the actual login
        response = opener.open('https://dev.mysql.com/login/', params)

        # Reads the server response
        data = response.read()

        # Creates the parser to confirm successful login
        parser = HTMLGetData()
        parser.quit_on_done = True
        parser.add_path_node("html")
        parser.add_path_node("body")
        parser.add_path_conditioned_node("div", [('id', 'container')])
        parser.add_path_conditioned_node("div", [('class', 'page_container')])
        parser.add_path_conditioned_node("div", [('id', 'page')])
        parser.add_path_conditioned_node("h1", [('class', 'page_header'),
                                                ('id', 'mainContent')])

        # Performs the parsing
        parser.feed(data)

        # Initializing error, to be cleaned in case of success
        # A simple error is returned on any login attemp failure, just as the web page does
        ret_val = 'error|Error accessing the bug system, please verify your email and password'
        # Sets the return value
        if len(parser.result) == 1:
            if parser.result[0] == 'Login Successful':
                ret_val = ''

    except urllib2.URLError, e:
        ret_val = 'error|Error accessing the bug system, check your network settings'
        log_error('WB Bug Report',
                  'Error accessing the bug system: %s\n' % str(e))
Example #8
0
 def handle_endtag(self, tag):
     HTMLGetData.handle_endtag(self, tag)
def test_connection():

    #Initializes the return value as no error
    ret_val = 'error|Unable to connecto through the Bug System, please proceed through http://bugs.mysql.com/report.php'

    try:
        # Creates the object to open and manage the cookies
        cookieJar = cookielib.CookieJar()
        urlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))

        # Attempts to login
        response = urlOpener.open('http://bugs.mysql.com/index.php')

        # Reads the server response
        data = response.read()

        # Creates the parser to confirm successful login
        parser = HTMLGetData()
        parser.quit_on_done = True
        parser.add_path_node("html")
        parser.add_path_node("body")
        parser.add_path_conditioned_node("div",[('id','nav')])
        parser.add_path_node("ul")
        parser.add_path_conditioned_node("li",[('id','current')])
        
        parser.feed(data)

        if len(parser.result)==1:
            if parser.result[0] == 'Bugs Home':
                ret_val = 'success|'

    except BaseException, e:
        log_error("WB Bug Report", 'An error occurred while testing conectivity, %s: %s\n' % (e.__class__.__name__, str(e)))
Example #10
0
def login(opener, user, password):

    ret_val = 'error|Unknown error accessing the bug system'

    try:
        # Encodes the needed information for the login
        params = urllib.urlencode({'email': user,
                                   'password': password,
                                   'dest': ''})

        # Performs the actual login
        response = opener.open('https://dev.mysql.com/login/', params)

        # Reads the server response
        data = response.read()

        # Creates the parser to confirm successful login
        parser = HTMLGetData()
        parser.quit_on_done = True
        parser.add_path_node("html")
        parser.add_path_node("body")
        parser.add_path_conditioned_node("div",[('id','container')])
        parser.add_path_conditioned_node("div",[('class','page_container')])
        parser.add_path_conditioned_node("div",[('id','page')])
        parser.add_path_conditioned_node("h1",[('class','page_header'),('id','mainContent')])

        # Performs the parsing
        parser.feed(data)

        # Initializing error, to be cleaned in case of success
        # A simple error is returned on any login attemp failure, just as the web page does
        ret_val = 'error|Error accessing the bug system, please verify your email and password'
        # Sets the return value
        if len(parser.result) == 1:
            if parser.result[0] == 'Login Successful':
                ret_val = ''

    except urllib2.URLError, e:
        ret_val = 'error|Error accessing the bug system, check your network settings'
        log_error('WB Bug Report', 'Error accessing the bug system: %s\n' % str(e))