How to use the jira.JIRAError function in jira

To help you get started, we’ve selected a few jira examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pycontribs / jira / tests / tests.py View on Github external
def test_remove_user_from_group(self):
        if self._should_skip_for_pycontribs_instance():
            self._skip_pycontribs_instance()
        try:
            self.jira.add_user(
                self.test_username, self.test_email, password=self.test_password
            )
        except JIRAError:
            pass

        try:
            self.jira.add_group(self.test_groupname)
        except JIRAError:
            pass

        try:
            self.jira.add_user_to_group(self.test_username, self.test_groupname)
        except JIRAError:
            pass

        result = self.jira.remove_user_from_group(
            self.test_username, self.test_groupname
        )
        assert result, True

        sleep(2)
        x = self.jira.group_members(self.test_groupname)
        self.assertNotIn(
            self.test_username,
github pycontribs / jira / tests / tests.py View on Github external
def test_session_invalid_login(self):
        try:
            JIRA(
                "https://jira.atlassian.com",
                basic_auth=("xxx", "xxx"),
                validate=True,
                logging=False,
            )
        except Exception as e:
            self.assertIsInstance(e, JIRAError)
            # 20161010: jira cloud returns 500
            assert e.status_code in (401, 500, 403)
            str(JIRAError)  # to see that this does not raise an exception
            return
        assert False
github pycontribs / jira / tests / tests.py View on Github external
def test_assign_to_bad_issue_raises(self):
        self.assertRaises(JIRAError, self.jira.assign_issue, 'NOPE-1',
                          'notauser')
github kraiz / hamster-bridge / hamster_bridge / listeners / jira.py View on Github external
return

            transition_found = False
            transitions = self.jira.transitions(issue_name)
            for transition in transitions:
                if transition['name'] == transition_name:
                    transition_found = True
                    self.jira.transition_issue(issue_name, transition['id'])
                    logger.info('Marked issue "%s" as "%s"', issue_name, transition_name)
            if not transition_found:
                logger.warn(
                    "Could not find transition '%s' in '%s'",
                    transition_name,
                    [t['name'] for t in transitions]
                )
        except JIRAError:
            logger.exception('Error communicating with Jira')
github GaretJax / lancet / lancet / issue_tracker.py View on Github external
def checker(url, username, password):
        try:
            JIRA(options={"server": url}, basic_auth=(username, password))
        except JIRAError:
            return False
        else:
            return True
github DataDog / gello / app / api_clients / jira_api_client.py View on Github external
def initialize(self):
        server = environ.get('JIRA_SERVER_ADDRESS')
        username = environ.get('JIRA_USERNAME')
        key = environ.get('JIRA_API_KEY')

        self._client = None

        if bool(server) and bool(username) and bool(key):
            try:
                self._client = self._return_client(server, username, key)
                return None
            except FunctionTimedOut:
                return "Could not connect to JIRA server"
            except JIRAError as err:
                to_return = "Error occurred when connecting to JIRA server: " + err.text
                if err.text == "Basic auth with password is not allowed on this instance\n":
                    to_return += "\nPerhaps the provided authentication is invalid?"
                return to_return
github echorebel / generate-changelog / generate-changelog.py View on Github external
def set_fixVersions(issue, version):
    fixVersions = []
    for existing_version in issue.fields.fixVersions:
        fixVersions.append({'name': existing_version.name})
    fixVersions.append({'name': version.name})
    try:
        issue.update(fields={'fixVersions': fixVersions})
    except JIRAError as e:
        print(e.status_code, e.text, issue.key)
github opennode / waldur-mastermind / src / nodeconductor_assembly_waldur / support / backend / atlassian.py View on Github external
def wrapped(self, *args, **kwargs):
            try:
                return func(self, *args, **kwargs)
            except JIRAError as e:
                six.reraise(JiraBackendError, e)
        return wrapped
github opennode / waldur-mastermind / src / waldur_jira / jira_fix.py View on Github external
count = (
        len('.'.join(filename_extension).encode('utf-8')) + 1
        if filename_extension
        else 0
    )
    char_limit = 0

    for char in filename:
        count += len(char.encode('utf-8'))
        if count > limit:
            break
        else:
            char_limit += 1

    if not char_limit:
        raise JIRAError('Attachment filename is very long.')

    tmp = [filename[:char_limit]]
    tmp.extend(filename_extension)
    filename = '.'.join(tmp)
    return filename
github opennode / waldur-mastermind / src / waldur_jira / jira_fix.py View on Github external
headers = {'X-ExperimentalApi': 'opt-in'}
    r = self._session.post(
        url,
        headers=headers,
        data=json.dumps(
            {
                'email': email,
                'fullName': displayName,  # different property for the server one
            }
        ),
    )

    raw_customer_json = json_loads(r)

    if r.status_code != 201:
        raise JIRAError(r.status_code, request=r)
    return Customer(self._options, self._session, raw=raw_customer_json)