Skip to content

Commit

Permalink
Merge pull request #19 from sshedmake/fixes_for_zanata-python-client
Browse files Browse the repository at this point in the history
FIXES rhbz 1207303, return code now is 1 if push fails
https://bugzilla.redhat.com/show_bug.cgi?id=1207303
  • Loading branch information
definite committed Apr 29, 2015
2 parents dd57f15 + 5ff8006 commit 2610df8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion zanataclient/zanatalib/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ProjectExistException", "UnAvaliableResourceException",
"UnAvaliablePOTException", "BadRequestBodyException",
"SameNameDocumentException","InternalServerError",
"NotAllowedException", "UnavailableServiceError",
"NotAllowedException", "UnavailableServiceError", "ForbiddenException",
"UnexpectedStatusException"
)
class ZanataException(Exception):
Expand Down Expand Up @@ -80,5 +80,8 @@ class SameNameDocumentException(ZanataException):
class NotAllowedException(ZanataException):
pass

class ForbiddenException(ZanataException):
pass

class UnexpectedStatusException(ZanataException):
pass
9 changes: 9 additions & 0 deletions zanataclient/zanatalib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from error import ProjectExistException
from error import NotAllowedException
from error import SameNameDocumentException
from error import ForbiddenException
from rest.client import RestClient

import json
import sys

__all__ = (
"Service",
Expand Down Expand Up @@ -59,6 +61,13 @@ def messages(self,res,content,extra_msg=None):
elif res['status'] == '503':
raise UnavailableServiceError('Error 503',
'Service Temporarily Unavailable, stop processing!')
elif res['status'] == '403':
try:
raise ForbiddenException('Error 403', 'You are authenticated but do not have the permission for the requested resource.')
except ForbiddenException as e:
print '', e
finally:
sys.exit(1)
else:
raise UnexpectedStatusException('Error',
'Unexpected Status (%s), failed to push: %s' % (res['status'], extra_msg or ""))

0 comments on commit 2610df8

Please sign in to comment.