Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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
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)