From d82857d4cb4588f8eab55e0c9eb3b07a9cdbde37 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Mon, 18 Nov 2019 17:36:46 -0500 Subject: [PATCH] Remove f-strings to remove requirement on py36 This is a small change that removes the hard requirement for python>=3.6. We can reconsider it in the future but for now this makes it easier for certain users to deploy for their environment. This also fixes wrong indentation on the settings file comment. Change-Id: Iab84818e5e50aa1e3a0951be154718be04fb53f5 --- README.rst | 2 +- ara/clients/utils.py | 2 +- ara/server/__main__.py | 2 +- ara/server/settings.py | 23 ++++++++++++++--------- doc/source/installation.rst | 2 +- roles/ara_api/tasks/pre-requirements.yaml | 8 ++++---- setup.cfg | 2 ++ 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index c0b86bea..604b9141 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ A stateless javascript client interface is provided by a different project, Quickstart ========== -Here's how you can get started from scratch with sane defaults with python>=3.6: +Here's how you can get started from scratch with sane defaults with python>=3.5: .. code-block:: bash diff --git a/ara/clients/utils.py b/ara/clients/utils.py index aa4f1d89..da95cc11 100644 --- a/ara/clients/utils.py +++ b/ara/clients/utils.py @@ -42,7 +42,7 @@ def get_client( return AraHttpClient(endpoint=endpoint, timeout=timeout, auth=auth) else: - raise ValueError(f"Unsupported API client: {client} (use 'http' or 'offline')") + raise ValueError("Unsupported API client: %s (use 'http' or 'offline')" % client) def active_client(): diff --git a/ara/server/__main__.py b/ara/server/__main__.py index fa8ec999..2fd6ac12 100644 --- a/ara/server/__main__.py +++ b/ara/server/__main__.py @@ -33,7 +33,7 @@ def main(): raise MissingDjangoException from e execute_from_command_line(sys.argv) - print(f"[ara] Using settings file: {settings.ARA_SETTINGS}") + print("[ara] Using settings file: %s" % settings.ARA_SETTINGS) if __name__ == "__main__": diff --git a/ara/server/settings.py b/ara/server/settings.py index b5e92577..e24f45f6 100644 --- a/ara/server/settings.py +++ b/ara/server/settings.py @@ -238,7 +238,7 @@ ARA_SETTINGS = os.getenv("ARA_SETTINGS", DEFAULT_SETTINGS) # Ensure default base configuration/data directory exists if not os.path.isdir(BASE_DIR): - print(f"[ara] Creating data & configuration directory: {BASE_DIR}") + print("[ara] Creating data & configuration directory: %s" % BASE_DIR) os.makedirs(BASE_DIR, mode=0o700) if not os.path.exists(DEFAULT_SETTINGS) and "ARA_SETTINGS" not in os.environ: @@ -268,13 +268,18 @@ if not os.path.exists(DEFAULT_SETTINGS) and "ARA_SETTINGS" not in os.environ: TIME_ZONE=TIME_ZONE, ) with open(DEFAULT_SETTINGS, "w+") as settings_file: - comment = f"""--- - # This is a default settings template generated by ARA. - # To use a settings file such as this one, you need to export the - # ARA_SETTINGS environment variable like so: - # $ export ARA_SETTINGS="{DEFAULT_SETTINGS}" + comment = textwrap.dedent( + """ + --- + # This is a default settings template generated by ARA. + # To use a settings file such as this one, you need to export the + # ARA_SETTINGS environment variable like so: + # $ export ARA_SETTINGS="{}" - """ - print(f"[ara] Writing default settings to {DEFAULT_SETTINGS}") - settings_file.write(textwrap.dedent(comment)) + """.format( + DEFAULT_SETTINGS + ) + ) + print("[ara] Writing default settings to %s" % DEFAULT_SETTINGS) + settings_file.write(comment.lstrip()) yaml.dump({"default": SETTINGS}, settings_file, default_flow_style=False) diff --git a/doc/source/installation.rst b/doc/source/installation.rst index a1144177..881b8fcb 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -18,7 +18,7 @@ the project's `README `_. Requirements and dependencies ----------------------------- -ARA should work on any Linux distribution as long as python3.6 and greater is +ARA should work on any Linux distribution as long as python3.5 and greater is available. In order to record data, ARA provides Ansible plugins that must be installed diff --git a/roles/ara_api/tasks/pre-requirements.yaml b/roles/ara_api/tasks/pre-requirements.yaml index 632fe8c7..5460b1ea 100644 --- a/roles/ara_api/tasks/pre-requirements.yaml +++ b/roles/ara_api/tasks/pre-requirements.yaml @@ -18,16 +18,16 @@ # The ansible_python_version fact might end up retrieving the version of # python2 so we need to explicitely get the version of python 3 available. -- name: Validate availability of Python 3.6 +- name: Validate availability of Python 3.5 command: /usr/bin/python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))' changed_when: false failed_when: false register: python_version -- name: Fail pre-emptively if running Python <3.6 +- name: Fail pre-emptively if running Python <3.5 fail: - msg: "Python >=3.6 is required to run ARA" - when: python_version.stdout is version('3.6', '<') or python_version.rc != 0 + msg: "Python >=3.5 is required to run ARA" + when: python_version.stdout is version('3.5', '<') or python_version.rc != 0 - name: Get list of installed packages package_facts: diff --git a/setup.cfg b/setup.cfg index 74f46850..0220b4dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,9 @@ classifier = Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 3 + Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 Development Status :: 4 - Beta [global]