forked from platformio/platformio-core
Minor improvements
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
|
||||
import json
|
||||
import uuid
|
||||
import hashlib
|
||||
from copy import deepcopy
|
||||
from os import environ, getenv
|
||||
from os.path import getmtime, isfile, join
|
||||
@ -165,11 +166,6 @@ def reset_settings():
|
||||
|
||||
|
||||
def get_session_var(name, default=None):
|
||||
if name == "caller_id" and not SESSION_VARS[name]:
|
||||
if getenv("PLATFORMIO_CALLER"):
|
||||
return getenv("PLATFORMIO_CALLER")
|
||||
elif getenv("C9_UID"):
|
||||
return "C9"
|
||||
return SESSION_VARS.get(name, default)
|
||||
|
||||
|
||||
@ -187,7 +183,8 @@ def get_cid():
|
||||
cid = get_state_item("cid")
|
||||
if not cid:
|
||||
cid = str(
|
||||
uuid.uuid5(uuid.NAMESPACE_OID, str(
|
||||
getenv("C9_UID") if getenv("C9_UID") else uuid.getnode())))
|
||||
uuid.UUID(bytes=hashlib.md5(
|
||||
str(getenv("C9_UID")
|
||||
if getenv("C9_UID") else uuid.getnode())).digest()))
|
||||
set_state_item("cid", cid)
|
||||
return cid
|
||||
|
@ -27,6 +27,8 @@ from platformio.commands.platform import \
|
||||
from platformio.managers.lib import LibraryManager
|
||||
from platformio.managers.platform import PlatformFactory
|
||||
|
||||
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
|
||||
|
||||
|
||||
@click.command("run", short_help="Process project environments")
|
||||
@click.option("-e", "--environment", multiple=True)
|
||||
@ -46,13 +48,7 @@ from platformio.managers.platform import PlatformFactory
|
||||
@click.option("-v", "--verbose", is_flag=True)
|
||||
@click.option("--disable-auto-clean", is_flag=True)
|
||||
@click.pass_context
|
||||
def cli(ctx, # pylint: disable=R0913,R0914
|
||||
environment,
|
||||
target,
|
||||
upload_port,
|
||||
project_dir,
|
||||
silent,
|
||||
verbose,
|
||||
def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
|
||||
disable_auto_clean):
|
||||
# find project directory on upper level
|
||||
if isfile(project_dir):
|
||||
|
@ -38,6 +38,12 @@ def in_silence(ctx):
|
||||
|
||||
|
||||
def on_platformio_start(ctx, force, caller):
|
||||
if not caller:
|
||||
if getenv("PLATFORMIO_CALLER"):
|
||||
caller = getenv("PLATFORMIO_CALLER")
|
||||
elif getenv("C9_UID"):
|
||||
caller = "C9"
|
||||
|
||||
app.set_session_var("command_ctx", ctx)
|
||||
app.set_session_var("force_option", force)
|
||||
app.set_session_var("caller_id", caller)
|
||||
|
Reference in New Issue
Block a user