]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding bin/create-terraform
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 14:28:48 +0000 (16:28 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 14:28:48 +0000 (16:28 +0200)
bin/create-terraform [new file with mode: 0755]

diff --git a/bin/create-terraform b/bin/create-terraform
new file mode 100755 (executable)
index 0000000..5dc499e
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import sys
+
+if sys.version_info[0] != 3:
+    print("This script is intended to use with Python3.", file=sys.stderr)
+    print("You are using Python: {0}.{1}.{2}-{3}-{4}.\n".format(
+        *sys.version_info), file=sys.stderr)
+    sys.exit(1)
+
+if sys.version_info[1] < 4:
+    print("A minimal Python version of 3.4 is necessary to execute this script.", file=sys.stderr)
+    print("You are using Python: {0}.{1}.{2}-{3}-{4}.\n".format(
+        *sys.version_info), file=sys.stderr)
+    sys.exit(1)
+
+import os
+import logging
+import locale
+
+# own modules:
+cur_dir = os.getcwd()
+base_dir = cur_dir
+
+if sys.argv[0] != '' and sys.argv[0] != '-c':
+    bin_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
+else:
+    bin_dir = os.path.dirname(os.path.realpath(__file__))
+base_dir = os.path.abspath(os.path.join(bin_dir, '..'))
+lib_dir = os.path.join(base_dir, 'lib')
+module_dir = os.path.join(lib_dir, 'cr_tf')
+if os.path.exists(module_dir):
+    sys.path.insert(0, lib_dir)
+
+from cr_tf.app import CrTfApplication
+
+log = logging.getLogger(__name__)
+
+__author__ = 'Frank Brehm <frank.brehm@pixelpark.com>'
+__copyright__ = '(C) 2019 by Frank Brehm, Pixelpark GmbH, Berlin'
+
+appname = os.path.basename(sys.argv[0])
+
+locale.setlocale(locale.LC_ALL, '')
+
+app = CrTfApplication(appname=appname, base_dir=base_dir)
+app.initialized = True
+
+if app.verbose > 2:
+    print("{c}-Object:\n{a}".format(c=app.__class__.__name__, a=app))
+
+app()
+
+if app.handler:
+    app.handler = None
+
+sys.exit(0)
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4