From 3c65e9942752c329b60a631a687f423ff899c29b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 20 Apr 2022 22:49:45 +1000 Subject: [PATCH] Prevent infinite loop when serving development version of docs --- main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 9f913bd..656b6c9 100644 --- a/main.py +++ b/main.py @@ -9,15 +9,17 @@ def define_env(env): # Ensure that the config template is always up to date CFG_URL = "https://raw.githubusercontent.com/inventree/InvenTree/master/InvenTree/config_template.yaml" - response = request.urlopen(CFG_URL) - print(f"Reading config template from GitHub: Response {response.status}") - - if response.status == 200: - data = response.read() + # Only perform this step if we are building on RTD server + if os.environ.get('READTHEDOCS', False): + response = request.urlopen(CFG_URL) + print(f"Reading config template from GitHub: Response {response.status}") + + if response.status == 200: + data = response.read() - if len(data) > 0: - with open("_includes/config.yaml", "w") as f: - f.write(str(data.decode())) + if len(data) > 0: + with open("_includes/config.yaml", "w") as f: + f.write(str(data.decode())) @env.macro def listimages(subdir):