Check if version is read-only when querying Zanata

Extend query-zanata-project-version.py to parse the response it gets
back from the Zanata server, and to also exit 1 if the version is marked
as read-only, saves the proposal slave performing the work if the server
will reject the upload anyway.

Change-Id: I9f66bd34c6d34703b47836f91737282193beb0af
This commit is contained in:
Steve Kowalik 2015-09-25 15:48:41 +10:00
parent 1aac2cffbb
commit 04ffd50543

View File

@ -16,6 +16,7 @@
import argparse
import os
import json
import sys
from ZanataUtils import IniConfig, ZanataRestService
@ -34,7 +35,8 @@ def get_args():
def main():
args = get_args()
zc = IniConfig(os.path.expanduser('~/.config/zanata.ini'))
rest_service = ZanataRestService(zc, verify=args.verify)
rest_service = ZanataRestService(zc, content_type='application/json',
verify=args.verify)
try:
r = rest_service.query(
'/rest/projects/p/%s/iterations/i/%s'
@ -42,6 +44,9 @@ def main():
except ValueError:
sys.exit(1)
if r.status_code == 200:
details = json.loads(r.content)
if details['status'] == 'READONLY':
sys.exit(1)
sys.exit(0)