mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Minor updates
This commit is contained in:
@ -253,29 +253,14 @@ def is_disabled_progressbar():
|
|||||||
|
|
||||||
|
|
||||||
def get_cid():
|
def get_cid():
|
||||||
# pylint: disable=import-outside-toplevel
|
|
||||||
from platformio.clients.http import fetch_remote_content
|
|
||||||
|
|
||||||
cid = get_state_item("cid")
|
cid = get_state_item("cid")
|
||||||
if cid:
|
if cid:
|
||||||
return cid
|
return cid
|
||||||
uid = None
|
uid = None
|
||||||
if os.getenv("C9_UID"):
|
if os.getenv("GITHUB_USER"):
|
||||||
uid = os.getenv("C9_UID")
|
uid = os.getenv("GITHUB_USER")
|
||||||
elif os.getenv("GITPOD_GIT_USER_NAME"):
|
elif os.getenv("GITPOD_GIT_USER_NAME"):
|
||||||
uid = 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(
|
|
||||||
fetch_remote_content(
|
|
||||||
"{api}/user?token={token}".format(
|
|
||||||
api=os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")),
|
|
||||||
token=os.getenv("USER_TOKEN"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).get("id")
|
|
||||||
except: # pylint: disable=bare-except
|
|
||||||
pass
|
|
||||||
if not uid:
|
if not uid:
|
||||||
uid = uuid.getnode()
|
uid = uuid.getnode()
|
||||||
cid = uuid.UUID(bytes=hashlib.md5(hashlib_encode_data(uid)).digest())
|
cid = uuid.UUID(bytes=hashlib.md5(hashlib_encode_data(uid)).digest())
|
||||||
|
@ -35,7 +35,6 @@ from platformio.package.manager.tool import ToolPackageManager
|
|||||||
from platformio.package.meta import PackageSpec
|
from platformio.package.meta import PackageSpec
|
||||||
from platformio.package.version import pepver_to_semver
|
from platformio.package.version import pepver_to_semver
|
||||||
from platformio.platform.factory import PlatformFactory
|
from platformio.platform.factory import PlatformFactory
|
||||||
from platformio.proc import is_container
|
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_start(ctx, force, caller):
|
def on_platformio_start(ctx, force, caller):
|
||||||
@ -78,17 +77,12 @@ def set_caller(caller=None):
|
|||||||
caller = caller or os.getenv("PLATFORMIO_CALLER")
|
caller = caller or os.getenv("PLATFORMIO_CALLER")
|
||||||
if caller:
|
if caller:
|
||||||
return app.set_session_var("caller_id", caller)
|
return app.set_session_var("caller_id", caller)
|
||||||
if os.getenv("VSCODE_PID") or os.getenv("VSCODE_NLS_CONFIG"):
|
if os.getenv("CODESPACES"):
|
||||||
|
caller = "codespaces"
|
||||||
|
elif os.getenv("VSCODE_PID") or os.getenv("VSCODE_NLS_CONFIG"):
|
||||||
caller = "vscode"
|
caller = "vscode"
|
||||||
elif os.getenv("GITPOD_INSTANCE_ID") or os.getenv("GITPOD_WORKSPACE_URL"):
|
elif os.getenv("GITPOD_WORKSPACE_ID") or os.getenv("GITPOD_WORKSPACE_URL"):
|
||||||
caller = "gitpod"
|
caller = "gitpod"
|
||||||
elif is_container():
|
|
||||||
if os.getenv("C9_UID"):
|
|
||||||
caller = "C9"
|
|
||||||
elif os.getenv("USER") == "cabox":
|
|
||||||
caller = "CA"
|
|
||||||
elif os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")):
|
|
||||||
caller = "Che"
|
|
||||||
return app.set_session_var("caller_id", caller)
|
return app.set_session_var("caller_id", caller)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user