From: Frank Brehm Date: Tue, 24 Sep 2019 14:23:38 +0000 (+0200) Subject: Adding some scripts and requirements.txt X-Git-Tag: 1.3.3~18 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=622e9e0836cca4afa320eb14f125b402dbd71c03;p=pixelpark%2Fcreate-terraform.git Adding some scripts and requirements.txt --- diff --git a/README.md b/README.md index 59b4aa1..ad2e3a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Automatisierte Provisionierung mittels Terraform **Autor:** Frank Brehm + **Copyright:** Pixelpark GmbH, Berlin, 2019 ## 1. Voraussetzungen und Installation diff --git a/bin/compile-xlate-msgs.sh b/bin/compile-xlate-msgs.sh new file mode 100755 index 0000000..e31a56b --- /dev/null +++ b/bin/compile-xlate-msgs.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e +set -u + +this_script=$( readlink -f "$0" ) +cur_dir=$( pwd ) + +base_dir=$( dirname $( dirname "${this_script}" ) ) +cd ${base_dir} + +locale_dir=locale +locale_domain="create_terraform" +pot_file="${locale_dir}/${locale_domain}.pot" +po_with=99 +my_address="${DEBEMAIL:-frank.brehm@pixelpark.com}" + +if [[ ! -d "${locale_dir}" ]] ; then + echo "Localisation directory '${cur_dir}/${locale_dir}' not found." >&2 + exit 3 +fi + +pybabel compile --domain "${locale_domain}" \ + --directory "${locale_dir}" \ + --statistics + diff --git a/bin/update-env.sh b/bin/update-env.sh new file mode 100755 index 0000000..71e6156 --- /dev/null +++ b/bin/update-env.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +base_dir=$( dirname $( dirname $0 ) ) +cd ${base_dir} +base_dir=$( readlink -f . ) + +declare -a VALID_PY_VERSIONS=("3.8" "3.7" "3.6" "3.5") + +echo "Preparing virtual environment ..." +echo +if [[ ! -f venv/bin/activate ]] ; then + found="n" + for py_version in "${VALID_PY_VERSIONS[@]}" ; do + PYTHON="python${py_version}" + if type -t ${PYTHON} >/dev/null ; then + found="y" + echo + echo "Found ${PYTHON}." + echo + virtualenv --python=${PYTHON} venv + break + fi + done + if [[ "${found}" == "n" ]] ; then + echo >&2 + echo "Did not found a usable Python version." >&2 + echo "Usable Python versions are: ${VALID_PY_VERSIONS[*]}" >&2 + echo >&2 + exit 5 + fi +fi + +. venv/bin/activate || exit 5 + +echo "---------------------------------------------------" +echo "Upgrading PIP ..." +echo +pip install --upgrade --upgrade-strategy eager pip +echo + +echo "---------------------------------------------------" +echo "Upgrading setuptools + wheel + six ..." +echo +pip install --upgrade --upgrade-strategy eager setuptools wheel six +echo + +echo "---------------------------------------------------" +echo "Installing and/or upgrading necessary modules ..." +echo +pip install --upgrade --upgrade-strategy eager --requirement requirements.txt +echo +echo "---------------------------------------------------" +echo "Installed modules:" +echo +pip list --format columns + +if [[ -x bin/compile-xlate-msgs.sh ]]; then + echo + echo "--------------" + echo "Updating i18n files in ${base_dir} ..." + echo + bin/compile-xlate-msgs.sh +fi + +echo +echo "-------" +echo "Fertig." +echo + +# vim: ts=4 diff --git a/bin/xtract-xlate-msgs.sh b/bin/xtract-xlate-msgs.sh new file mode 100755 index 0000000..712ffe1 --- /dev/null +++ b/bin/xtract-xlate-msgs.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -e +set -u + +this_script=$( readlink -f "$0" ) +cur_dir=$( pwd ) + +base_dir=$( dirname $( dirname "${this_script}" ) ) +cd ${base_dir} + +locale_dir=locale +locale_domain="create_terraform" +pot_file="${locale_dir}/${locale_domain}.pot" +po_with=99 +my_address="${DEBEMAIL:-frank.brehm@pixelpark.com}" + +if [[ ! -d "lib" ]] ; then + echo "Python module directory '${cur_dir}/lib' not found." >&2 + exit 3 +fi + +pkg_version=$( cat lib/cr_tf/__init__.py | \ + grep '^[ ]*__version__' | \ + sed -e 's/[ ]*//g' | \ + awk -F= '{print $2}' | \ + sed -e "s/^'//" -e "s/'\$//" ) + +mkdir -pv "${locale_dir}" + +pybabel extract lib/cr_tf \ + -o "${pot_file}" \ + -F babel.ini \ + --width=${po_with} \ + --sort-by-file \ + --msgid-bugs-address="${my_address}" \ + --copyright-holder="Frank Brehm, Pixelpark GmbH, Berlin" \ + --project="${locale_domain}" \ + --version="${pkg_version}" + +sed -i -e "s/FIRST AUTHOR/Frank Brehm/g" -e "s//<${my_address}>/g" "${pot_file}" + +for lang in de_DE en_US ; do + if [[ ! -f "${locale_dir}/${lang}/LC_MESSAGES/${locale_domain}.po" ]] ; then + pybabel init --domain "${locale_domain}" \ + --input-file "${pot_file}" \ + --output-dir "${locale_dir}" \ + --locale "${lang}" \ + --width ${po_with} + else + pybabel update --domain "${locale_domain}" \ + --input-file "${pot_file}" \ + --output-dir "${locale_dir}" \ + --locale "${lang}" \ + --width ${po_with} \ + --update-header-comment + fi + # --ignore-obsolete \ +done diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a9d1722 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +pip +ansible +babel +PyYAML +pyvmomi>=v6.5.0.2017.5-1 +requests +six +pytz +paramiko +dnspython +flake8 +docker-py +pathlib +setuptools +git+https://git.pixelpark.com/python/python_fb_tools.git@master