This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new c950358  Add and use a function to detect running in a local 
environment
c950358 is described below

commit c95035802849a340985e99bfcf01bb5f5a109802
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Jun 27 14:15:14 2025 +0100

    Add and use a function to detect running in a local environment
---
 atr/routes/resolve.py | 3 +--
 atr/routes/vote.py    | 5 ++---
 atr/util.py           | 5 +++++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/atr/routes/resolve.py b/atr/routes/resolve.py
index e003389..617d73e 100644
--- a/atr/routes/resolve.py
+++ b/atr/routes/resolve.py
@@ -16,7 +16,6 @@
 # under the License.
 
 import json
-import os
 
 import quart
 import sqlmodel
@@ -138,7 +137,7 @@ async def selected_post(
 
 
 def task_mid_get(latest_vote_task: models.Task) -> str | None:
-    if "LOCAL_DEBUG" in os.environ:
+    if util.is_dev_environment():
         return "[email protected]"
     # TODO: Improve this
     task_mid = None
diff --git a/atr/routes/vote.py b/atr/routes/vote.py
index f019319..676fe03 100644
--- a/atr/routes/vote.py
+++ b/atr/routes/vote.py
@@ -17,7 +17,6 @@
 
 import json
 import logging
-import os
 
 import aiohttp
 import quart
@@ -61,7 +60,7 @@ async def selected(session: routes.CommitterSession, 
project_name: str, version_
         task_mid = resolve.task_mid_get(latest_vote_task)
         archive_url = await _task_archive_url_cached(task_mid)
 
-    if ("LOCAL_DEBUG" in os.environ) and (latest_vote_task is not None):
+    if util.is_dev_environment() and (latest_vote_task is not None):
         logging.warning("LOCAL_DEBUG: Setting vote task to completed")
         latest_vote_task.status = models.TaskStatus.COMPLETED
         latest_vote_task.result = [json.dumps({"mid": 
"[email protected]"})]
@@ -179,7 +178,7 @@ async def _task_archive_url(task_mid: str) -> str | None:
 
 
 async def _task_archive_url_cached(task_mid: str | None) -> str | None:
-    if "LOCAL_DEBUG" in os.environ:
+    if util.is_dev_environment():
         return 
"https://lists.apache.org/thread/619hn4x796mh3hkk3kxg1xnl48dy2s64";
     if task_mid is None:
         return None
diff --git a/atr/util.py b/atr/util.py
index 06d4331..f40fd79 100644
--- a/atr/util.py
+++ b/atr/util.py
@@ -291,6 +291,11 @@ def create_path_matcher(lines: Iterable[str], full_path: 
pathlib.Path, base_dir:
     return lambda file_path: gitignore_parser.handle_negation(file_path, rules)
 
 
+def is_dev_environment() -> bool:
+    conf = config.get()
+    return (conf.APP_HOST == "127.0.0.1") or 
conf.APP_HOST.startswith("127.0.0.1:")
+
+
 def email_from_uid(uid: str) -> str | None:
     if m := re.search(r"<([^>]+)>", uid):
         return m.group(1).lower()


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to