]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding some scripts and requirements.txt
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 14:23:38 +0000 (16:23 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 14:23:38 +0000 (16:23 +0200)
README.md
bin/compile-xlate-msgs.sh [new file with mode: 0755]
bin/update-env.sh [new file with mode: 0755]
bin/xtract-xlate-msgs.sh [new file with mode: 0755]
requirements.txt [new file with mode: 0644]

index 59b4aa1f2f7a84d9b795a5056cdaaf94cfe727ee..ad2e3a6aede37bcc1d59fc7f4107e02fd33214d4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
 # Automatisierte Provisionierung mittels Terraform
 
 **Autor:** Frank Brehm <frank.brehm@pixelpark.com>
+
 **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 (executable)
index 0000000..e31a56b
--- /dev/null
@@ -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 (executable)
index 0000000..71e6156
--- /dev/null
@@ -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 (executable)
index 0000000..712ffe1
--- /dev/null
@@ -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/<EMAIL@ADDRESS>/<${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 (file)
index 0000000..a9d1722
--- /dev/null
@@ -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