Beispiel #1
0
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"
    app.set_session_var("caller_id", caller)
Beispiel #2
0
def get_user_agent():
    data = [
        "PlatformIO/%s" % __version__,
        "CI/%d" % int(proc.is_ci()),
        "Container/%d" % int(proc.is_container()),
    ]
    if get_session_var("caller_id"):
        data.append("Caller/%s" % get_session_var("caller_id"))
    if os.getenv("PLATFORMIO_IDE"):
        data.append("IDE/%s" % os.getenv("PLATFORMIO_IDE"))
    data.append("Python/%s" % platform.python_version())
    data.append("Platform/%s" % platform.platform())
    return " ".join(data)
def set_caller(caller=None):
    caller = caller or getenv("PLATFORMIO_CALLER")
    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"
    return app.set_session_var("caller_id", caller)
Beispiel #4
0
    def _prefill_custom_data(self):
        def _filter_args(items):
            result = []
            stop = False
            for item in items:
                item = str(item).lower()
                result.append(item)
                if stop:
                    break
                if item == "account":
                    stop = True
            return result

        caller_id = str(app.get_session_var("caller_id"))
        self["cd1"] = util.get_systype()
        self["cd4"] = (1 if (not util.is_ci() and
                             (caller_id or not is_container())) else 0)
        if caller_id:
            self["cd5"] = caller_id.lower()
Beispiel #5
0
    def _prefill_custom_data(self):
        def _filter_args(items):
            result = []
            stop = False
            for item in items:
                item = str(item).lower()
                result.append(item)
                if stop:
                    break
                if item == "account":
                    stop = True
            return result

        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['cd3'] = " ".join(_filter_args(sys.argv[1:]))
        self['cd4'] = 1 if (not util.is_ci() and
                            (caller_id or not is_container())) else 0
        if caller_id:
            self['cd5'] = caller_id.lower()