How to use the stashy.errors.NotFoundException function in stashy

To help you get started, we’ve selected a few stashy 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 StackStorm-Exchange / stackstorm-bitbucket / sensors / repository_sensor.py View on Github external
last_commit = commits.next()

            if last_commit:
                return datetime.fromtimestamp(last_commit['authorTimestamp'] / 1000)
            else:
                return datetime.strptime('1900-01-01 00:00:00', self.DATE_FORMAT)

        for target in self.targets:
            (proj, repo) = target['repository'].split('/')

            for branch in target['branches']:
                try:
                    self._set_last_commit_time(target['repository'],
                                               branch,
                                               _last_ctime(proj, repo, branch))
                except stashy.errors.NotFoundException as e:
                    self._logger.warning("branch(%s) doesn't exist in the repository(%s) [%s]" %
                                         (branch, target['repository'], e))
github cosmin / stashy / stashy / errors.py View on Github external
def maybe_throw(response):
    if not response.ok:
        if response.status_code == 404:
            raise NotFoundException(response)
        else:
            e = GenericException(response)
            try:
                e.data = response.json()
            except ValueError:
                e.content = response.content
            raise e
github cosmin / stashy / stashy / errors.py View on Github external
def __init__(self, response):
        try:
            self.data = response.json()
            if 'errors' in self.data:
                msg = self.data['errors'][0]['message']
            else:
                msg = str(self.data)
        except ValueError:
            msg = "Not found: " + response.url

        super(NotFoundException, self).__init__(msg)