From 2d9480a6a71fc0cf04b67ee4bc719831c7b988b6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 1 Nov 2020 21:05:03 +0200 Subject: [PATCH] Support for GitPod environment --- platformio/app.py | 2 ++ platformio/maintenance.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index 0196fac4..9b22b638 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -255,6 +255,8 @@ def get_cid(): uid = None if os.getenv("C9_UID"): uid = os.getenv("C9_UID") + elif os.getenv("GITPOD_GIT_USER_NAME"): + uid = os.getenv("GITPOD_GIT_USER_NAME") elif os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")): try: uid = json.loads( diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 5fa66bd1..06ca827a 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -73,16 +73,19 @@ def on_platformio_exception(e): def set_caller(caller=None): caller = caller or getenv("PLATFORMIO_CALLER") - if not caller: - if getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): - caller = "vscode" - elif is_container(): - if getenv("C9_UID"): - caller = "C9" - elif getenv("USER") == "cabox": - caller = "CA" - elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): - caller = "Che" + if caller: + return app.set_session_var("caller_id", caller) + if getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): + caller = "vscode" + elif getenv("GITPOD_INSTANCE_ID") or getenv("GITPOD_WORKSPACE_URL"): + caller = "gitpod" + elif is_container(): + if getenv("C9_UID"): + caller = "C9" + elif getenv("USER") == "cabox": + caller = "CA" + elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): + caller = "Che" app.set_session_var("caller_id", caller)