Add a new script that queries for a Zanata version
To allow us to check if a version exists for a Zanata project without requiring us to create a zanata.xml first, add a small script that uses the Zanata REST API to query for its existance. Make use it instead of the zanata-cli in upstream_translation_update, since we can't create a zanata.xml if the version doesn't exist. Change-Id: I93a72845aa705ce6b72acec9b5d62b5565368ab0
This commit is contained in:
parent
0ca9b23dfb
commit
c7836c092e
49
jenkins/scripts/query-zanata-project-version.py
Executable file
49
jenkins/scripts/query-zanata-project-version.py
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from ZanataUtils import IniConfig, ZanataRestService
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser(description='Check if a version for the '
|
||||
'specificed project exists on the Zanata '
|
||||
'server')
|
||||
parser.add_argument('-p', '--project', required=True)
|
||||
parser.add_argument('-v', '--version', required=True)
|
||||
parser.add_argument('--no-verify', action='store_false', dest='verify',
|
||||
help='Do not perform HTTPS certificate verification')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
args = get_args()
|
||||
zc = IniConfig(os.path.expanduser('~/.config/zanata.ini'))
|
||||
rest_service = ZanataRestService(zc, verify=args.verify)
|
||||
try:
|
||||
r = rest_service.query(
|
||||
'/rest/projects/p/%s/iterations/i/%s'
|
||||
% (args.project, args.version))
|
||||
except ValueError:
|
||||
sys.exit(1)
|
||||
if r.status_code == 200:
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -20,15 +20,13 @@ ZANATA_VERSION=${ZUUL_REFNAME//\//-}
|
||||
|
||||
source /usr/local/jenkins/slave_scripts/common_translation_update.sh
|
||||
|
||||
function check_version_exists {
|
||||
local version=$1
|
||||
if ! zanata-cli -B list-remote --project-version $version > /dev/null 2>&1 ; then
|
||||
# Exit successfully so that lack of a version doesn't cause
|
||||
# the jenkins jobs to fail. This is necessary because not all
|
||||
# branches of a project will be translated.
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
if ! /usr/local/jenkins/slave_scripts/query-zanata-project-version.py \
|
||||
-p $PROJECT -v $ZANATA_VERSION; then
|
||||
# Exit successfully so that lack of a version doesn't cause the jenkins
|
||||
# jobs to fail. This is necessary because not all branches of a project
|
||||
# will be translated.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
setup_git
|
||||
|
||||
@ -38,21 +36,17 @@ case "$PROJECT" in
|
||||
init_manuals "$PROJECT"
|
||||
# POT file extraction is done in setup_manuals.
|
||||
setup_manuals "$PROJECT" "$ZANATA_VERSION"
|
||||
check_version_exists "$ZANATA_VERSION"
|
||||
;;
|
||||
django_openstack_auth)
|
||||
setup_django_openstack_auth "$ZANATA_VERSION"
|
||||
check_version_exists "$ZANATA_VERSION"
|
||||
extract_messages
|
||||
;;
|
||||
horizon)
|
||||
setup_horizon "$ZANATA_VERSION"
|
||||
check_version_exists "$ZANATA_VERSION"
|
||||
./run_tests.sh --makemessages -V
|
||||
;;
|
||||
*)
|
||||
setup_project "$PROJECT" "$ZANATA_VERSION"
|
||||
check_version_exists "$ZANATA_VERSION"
|
||||
setup_loglevel_vars
|
||||
extract_messages
|
||||
extract_messages_log "$PROJECT"
|
||||
|
Loading…
Reference in New Issue
Block a user