示例#1
0
    def __init__(self, project_id):
        self.env = rpc_init(log)

        if settings.get("TESTING"):
            test_project = settings.get("TEST_PROJECT")
            log.debug("Overriding JIRA project from %s to %s" % (project_id, test_project))
            project_id = test_project

        projects = get_project_choices(self.env)
        if project_id not in projects:
            raise JiraException("%s isn't a valid project ID." % project_id)

        self.project_id = project_id

        client = self.env["client"]
        auth = self.env["auth"]
        server_info = client.service.getServerInfo(auth)
        log.debug("Server info: %s" % server_info)

        if "auth" not in self.env or not self.env["auth"]:
            log.critical("Error acquiring auth token")
            raise RPCException(self.env)

        if "client" not in self.env or not self.env["client"]:
            log.critical("Error acquiring client")
            raise RPCException(self.env)
示例#2
0
def rpc_init(logger):
    env = dict(
        jirauser=settings.get('USERNAME'),
    )

    authorized = False
    while not authorized:
        try:
            logger.debug('Starting authorization')

            client = get_client(logger)
            auth = client.service.login(
                env['jirauser'], settings.get('PASSWORD'),
            )

            logger.debug('Using auth to get types')
            env['types'] = client.service.getIssueTypes(auth)

            logger.debug('Using auth to get subtask types')
            env['subtypes'] = client.service.getSubTaskIssueTypes(auth)

            logger.debug('Using auth to get statuses')
            env['statuses'] = client.service.getStatuses(auth)

            logger.debug('Using auth to get priorities')
            env['priorities'] = client.service.getPriorities(auth)

            logger.debug('Using auth to get resolutions')
            env['resolutions'] = client.service.getResolutions(auth)

            logger.debug('Using auth to get projects')
            env['projects'] = client.service.getProjectsNoSchemes(auth)

            authorized = True

            env['client'] = client
            env['auth'] = auth
        except Exception, e:
            logger.error('Error authenticating with JIRA')
            logger.exception(e)
            raise
示例#3
0
def get_client(logger):
    WSDL_URL = settings.get('WSDL_URL')

    try:
        logger.debug('Attempting to connect to the server: ' + WSDL_URL)

        client = Client(WSDL_URL)
        logger.debug('Connected to the server')
        logger.debug(client)
        return client
    except Exception, e:
        logger.error('Failed to connect to JIRA (%s): %s' % (WSDL_URL, e))
        raise