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:
parent
1aac2cffbb
commit
04ffd50543
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
import sys
|
import sys
|
||||||
from ZanataUtils import IniConfig, ZanataRestService
|
from ZanataUtils import IniConfig, ZanataRestService
|
||||||
|
|
||||||
@ -34,7 +35,8 @@ def get_args():
|
|||||||
def main():
|
def main():
|
||||||
args = get_args()
|
args = get_args()
|
||||||
zc = IniConfig(os.path.expanduser('~/.config/zanata.ini'))
|
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:
|
try:
|
||||||
r = rest_service.query(
|
r = rest_service.query(
|
||||||
'/rest/projects/p/%s/iterations/i/%s'
|
'/rest/projects/p/%s/iterations/i/%s'
|
||||||
@ -42,6 +44,9 @@ def main():
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
|
details = json.loads(r.content)
|
||||||
|
if details['status'] == 'READONLY':
|
||||||
|
sys.exit(1)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user