diff --git a/.ci/build.bash b/.ci/build.bash index 1d4915ea60d392eb471eed7f144b173ac89cddea..7d412740c689d598589c23232c508f9126aadbc7 100644 --- a/.ci/build.bash +++ b/.ci/build.bash @@ -46,7 +46,7 @@ REPOSITORY=experiments || CO_BRANCH="${TOPIC_BRANCH}" bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" bibi_configuration.xsd "${CO_BRANCH}" bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" ExDConfFile.xsd "${CO_BRANCH}" -python .ci/ci_download_directory.py https://bitbucket.org/hbpneurorobotics/experiments/src/${CO_BRANCH}/hbp-scxml/ + REPOSITORY=models [ -z "$(git ls-remote --heads https://bitbucket.org/hbpneurorobotics/${REPOSITORY}.git ${TOPIC_BRANCH})" ] \ && CO_BRANCH="${DEFAULT_BRANCH}" \ @@ -63,7 +63,7 @@ export pyxb_version=`grep "pyxb" ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/requir && pyxbgen -u ExDConfFile.xsd -m exp_conf_api_gen \ && pyxbgen -u robot_model_configuration.xsd -m robot_conf_api_gen \ && pyxbgen -u environment_model_configuration.xsd -m environment_conf_api_gen -mv bibi_api_gen.py exp_conf_api_gen.py _sc.py robot_conf_api_gen.py environment_conf_api_gen.py ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/hbp_nrp_commons/generated +mv bibi_api_gen.py exp_conf_api_gen.py robot_conf_api_gen.py environment_conf_api_gen.py ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/hbp_nrp_commons/generated touch ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/hbp_nrp_commons/generated/__init__.py deactivate diff --git a/.ci/ci_download_directory.py b/.ci/ci_download_directory.py deleted file mode 100644 index 4568c8cdf78cb99c5e33695bae02bedf6da13dd7..0000000000000000000000000000000000000000 --- a/.ci/ci_download_directory.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -""" -CI script for checkout of a single directory from a specified repo ref HEAD -This script uses BitBucket API, so the repo is supposed to be in BitBucket cloud -""" - -import os -import sys -from urllib.parse import urlparse -import urllib.request - -try: - import json -except ImportError: - import simplejson as json - - -def open_directory(api_path_, user_name_, repository_, slug_, path_): - """ - open_directory opens directory and recursevely downloads its content throug BitBucket API - :param api_path_: path to BitBucket API core (https://api.bitbucket.org/2.0/repositories) - :param user_name_: BitBucket username (hbpneurorobotics) - :param repository_: the desired repo to download (i.e. CLE) - :param slug_: the desired ref (branch/tag/hash) - :param path_: the path to the directory inside repository - """ - directory_url = "%s/%s/%s/src/%s/%s" % (api_path_, user_name_, repository_, slug_, path_) - print(directory_url) - json_data_url_handle = urllib.request.urlopen(directory_url) - - if json_data_url_handle.code != 200: - print("url %s not found" % directory_url) - sys.exit() - - json_directory = json.loads(json_data_url_handle.read()) - page_exists = True - - while page_exists: - for item in json_directory["values"]: - print(json.dumps(item, indent=4)) - if item["type"] == "commit_directory": - open_directory(api_path_, user_name_, repository_, slug_, item["path"]) - - for file_ in json_directory["values"]: - if file_["type"] == "commit_file" and file_["mimetype"] == "text/xml": - try: - os.makedirs(os.path.dirname(file_["path"])) - except OSError: - pass - print("downloading %s" % file_["path"]) - print(file_['links']['self']['href']) - urllib.request.urlretrieve(file_['links']['self']['href'], file_['path']) - if "next" in json_directory: - json_data_url_handle = urllib.request.urlopen(json_directory['next']) - if json_data_url_handle.code != 200: - print("url %s not found" % directory_url) - sys.exit() - json_directory = json.loads(json_data_url_handle.read()) - else: - page_exists = False - - -if ( - len(sys.argv) != 2 or - sys.argv[1].find("https://bitbucket.org/") != 0 or - sys.argv[1].find("/src/") == -1 -): - print("usage: python download_directory.py.py https://bitbucket.org/ws/repo/src/branch/demo/") - sys.exit() - -API_PATH = "https://api.bitbucket.org/2.0/repositories" -_, username, repo, _, slug, path_section = urlparse(sys.argv[1]).path.split("/", 5) - -print(username, repo, slug, path_section) - -open_directory(API_PATH, username, repo, slug, path_section) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 7ba3149ea949bfb67125f22251fc491a47decf0f..c71a5b175fbe220d16874702be0a04ecef7f594c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -45,7 +45,7 @@ pipelines: - make devinstall # Otherwise it can't find pyxbgen - export pyxb_version=`grep "pyxb" $HBP/ExDBackend/hbp_nrp_commons/requirements.txt` - . $VIRTUAL_ENV_PATH/bin/activate && pip install ${pyxb_version} && pyxbgen -u $HBP/Experiments/bibi_configuration.xsd -m bibi_api_gen && pyxbgen -u $HBP/Experiments/ExDConfFile.xsd -m exp_conf_api_gen && pyxbgen -u $HBP/Models/robot_model_configuration.xsd -m robot_conf_api_gen && pyxbgen -u $HBP/Models/environment_model_configuration.xsd -m environment_conf_api_gen - - mv bibi_api_gen.py exp_conf_api_gen.py _sc.py robot_conf_api_gen.py environment_conf_api_gen.py $HBP/ExDBackend/hbp_nrp_commons/hbp_nrp_commons/generated + - mv bibi_api_gen.py exp_conf_api_gen.py robot_conf_api_gen.py environment_conf_api_gen.py $HBP/ExDBackend/hbp_nrp_commons/hbp_nrp_commons/generated - touch $HBP/ExDBackend/hbp_nrp_commons/hbp_nrp_commons/generated/__init__.py - deactivate