mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Handle process in container
This commit is contained in:
@ -51,8 +51,11 @@ def on_platformio_start(ctx, force, caller):
|
||||
if not caller:
|
||||
if getenv("PLATFORMIO_CALLER"):
|
||||
caller = getenv("PLATFORMIO_CALLER")
|
||||
elif getenv("C9_UID"):
|
||||
caller = "C9"
|
||||
elif util.is_container():
|
||||
if getenv("C9_UID"):
|
||||
caller = "C9"
|
||||
elif getenv("USER") == "cabox":
|
||||
caller = "CA"
|
||||
|
||||
app.set_session_var("command_ctx", ctx)
|
||||
app.set_session_var("force_option", force)
|
||||
|
@ -92,12 +92,14 @@ class MeasurementProtocol(TelemetryBase):
|
||||
self['an'] = " ".join(dpdata)
|
||||
|
||||
def _prefill_custom_data(self):
|
||||
caller_id = str(app.get_session_var("caller_id"))
|
||||
self['cd1'] = util.get_systype()
|
||||
self['cd2'] = "Python/%s %s" % (platform.python_version(),
|
||||
platform.platform())
|
||||
self['cd4'] = 1 if not util.is_ci() else 0
|
||||
if app.get_session_var("caller_id"):
|
||||
self['cd5'] = str(app.get_session_var("caller_id")).lower()
|
||||
self['cd4'] = 1 if (not util.is_ci() and
|
||||
(caller_id or not util.is_container())) else 0
|
||||
if caller_id:
|
||||
self['cd5'] = caller_id.lower()
|
||||
|
||||
def _prefill_screen_name(self):
|
||||
self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]])
|
||||
|
@ -298,6 +298,17 @@ def is_ci():
|
||||
return os.getenv("CI", "").lower() == "true"
|
||||
|
||||
|
||||
def is_container():
|
||||
if not isfile("/proc/1/cgroup"):
|
||||
return False
|
||||
with open("/proc/1/cgroup") as fp:
|
||||
for line in fp:
|
||||
line = line.strip()
|
||||
if ":" in line and not line.endswith(":/"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def exec_command(*args, **kwargs):
|
||||
result = {"out": None, "err": None, "returncode": None}
|
||||
|
||||
|
Reference in New Issue
Block a user