forked from platformio/platformio-core
Handle process in container
This commit is contained in:
@@ -51,8 +51,11 @@ def on_platformio_start(ctx, force, caller):
|
|||||||
if not caller:
|
if not caller:
|
||||||
if getenv("PLATFORMIO_CALLER"):
|
if getenv("PLATFORMIO_CALLER"):
|
||||||
caller = getenv("PLATFORMIO_CALLER")
|
caller = getenv("PLATFORMIO_CALLER")
|
||||||
elif getenv("C9_UID"):
|
elif util.is_container():
|
||||||
|
if getenv("C9_UID"):
|
||||||
caller = "C9"
|
caller = "C9"
|
||||||
|
elif getenv("USER") == "cabox":
|
||||||
|
caller = "CA"
|
||||||
|
|
||||||
app.set_session_var("command_ctx", ctx)
|
app.set_session_var("command_ctx", ctx)
|
||||||
app.set_session_var("force_option", force)
|
app.set_session_var("force_option", force)
|
||||||
|
@@ -92,12 +92,14 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
self['an'] = " ".join(dpdata)
|
self['an'] = " ".join(dpdata)
|
||||||
|
|
||||||
def _prefill_custom_data(self):
|
def _prefill_custom_data(self):
|
||||||
|
caller_id = str(app.get_session_var("caller_id"))
|
||||||
self['cd1'] = util.get_systype()
|
self['cd1'] = util.get_systype()
|
||||||
self['cd2'] = "Python/%s %s" % (platform.python_version(),
|
self['cd2'] = "Python/%s %s" % (platform.python_version(),
|
||||||
platform.platform())
|
platform.platform())
|
||||||
self['cd4'] = 1 if not util.is_ci() else 0
|
self['cd4'] = 1 if (not util.is_ci() and
|
||||||
if app.get_session_var("caller_id"):
|
(caller_id or not util.is_container())) else 0
|
||||||
self['cd5'] = str(app.get_session_var("caller_id")).lower()
|
if caller_id:
|
||||||
|
self['cd5'] = caller_id.lower()
|
||||||
|
|
||||||
def _prefill_screen_name(self):
|
def _prefill_screen_name(self):
|
||||||
self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]])
|
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"
|
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):
|
def exec_command(*args, **kwargs):
|
||||||
result = {"out": None, "err": None, "returncode": None}
|
result = {"out": None, "err": None, "returncode": None}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user