Esempio n. 1
0
class FogBugzClient:
    def __init__(self, base_url, unused):
        self.base_url = base_url
        self.backend = FogBugz(base_url)

    @staticmethod
    def validate_backend(backend_name):
        """
        Returns True always, as this client doesn't support backends.
        """
        return True

    @staticmethod
    def get_url_from_id(remote_tracker_id, base_url):
        """
        Returns an absolute URL to a bug given its remote_tracker_id and the
        tracker's base_url.
        """
        return '%s/default.asp?%s' % (base_url, remote_tracker_id)

    @staticmethod
    def get_id_from_url(url, base_url):
        """
        Returns the id of a bug given a correctly-formatted URL,
            e.g.: https://foo.fogbugz.com/default.asp?23714
                  https://foo.fogbugz.com/default.asp?23714#430608
        otherwise, returns None.
        """
        path, query = urllib.splitquery(url)
        if not path.startswith(base_url):
            return None

        try:
            vals = query.split('#', 1)
            return vals[0]
        except:
            return None

    @staticmethod
    def urlize_bug_numbers(string, base_url):
        return re.sub(
            '([ -\'">])#([0-9]{1,7})([ .\'"<])',
            r'\1#<a href="%s/default.asp?\2" target="_blank">\2</a>\3' %
            base_url, string)

    def login(self, user, password):
        """
        Authenticates the user against the remote FogBugz instance.  Returns
        True if successful, False otherwise.
        """
        try:
            self.backend.logon(user, password)
        except AssertionError, e:
            logging.error('Exception while logging in:\n%s' % e)
            return False
        else:
Esempio n. 2
0
class FogBugzClient:
    def __init__(self, base_url, unused):
        self.base_url = base_url
        self.backend = FogBugz(base_url)

    @staticmethod
    def validate_backend(backend_name):
        """
        Returns True always, as this client doesn't support backends.
        """
        return True

    @staticmethod
    def get_url_from_id(remote_tracker_id, base_url):
        """
        Returns an absolute URL to a bug given its remote_tracker_id and the
        tracker's base_url.
        """
        return '%s/default.asp?%s' % (base_url, remote_tracker_id)

    @staticmethod
    def get_id_from_url(url, base_url):
        """
        Returns the id of a bug given a correctly-formatted URL,
            e.g.: https://foo.fogbugz.com/default.asp?23714
                  https://foo.fogbugz.com/default.asp?23714#430608
        otherwise, returns None.
        """
        path, query = urllib.splitquery(url)
        if not path.startswith(base_url):
            return None

        try:
            vals = query.split('#', 1)
            return vals[0]
        except:
            return None

    @staticmethod
    def urlize_bug_numbers(string, base_url):
        return re.sub('([ -\'">])#([0-9]{1,7})([ .\'"<])', r'\1#<a href="%s/default.asp?\2" target="_blank">\2</a>\3' % base_url, string)

    def login(self, user, password):
        """
        Authenticates the user against the remote FogBugz instance.  Returns
        True if successful, False otherwise.
        """
        try:
            self.backend.logon(user, password)
        except AssertionError, e:
            logging.error('Exception while logging in:\n%s' % e)
            return False
        else:
Esempio n. 3
0
 def __init__(self, base_url, unused):
     self.base_url = base_url
     self.backend = FogBugz(base_url)
Esempio n. 4
0
 def __init__(self, base_url, unused):
     self.base_url = base_url
     self.backend = FogBugz(base_url)