@staticmethod
    def __get_user_agent(agent_version):
        """Determine the user agent to report in the request headers.

        We construct an agent that gives Scalyr some information about the platform the customer is running on,
        the Python version, and a few other tidbits.  This is used to make decisions about support issues.

        @param agent_version: The agent version number.
        @type agent_version: str

        @return: The user agent string.
        @rtype: str
        """
        # We will construct our agent string to look something like:
        # Linux-redhat-7.0;python-2.7.2;agent-2.0.1;ssllib

        python_version = sys.version_info
        if len(python_version) >= 5:
            python_version_str = 'python-%s.%s.%s' % (python_version[0], python_version[1], python_version[2])
        else:
            python_version_str = 'python-unknown'

        # Try for a linux distribution first.  This doesn't seem to work for Amazon AMIs, but for most
        # distributions it hopefully will provide something readable.
        platform_value = None
        # noinspection PyBroadException
        try:
            distribution = platform.dist()
            if len(distribution[0]) > 0:
                platform_value = 'Linux-%s-%s' % (distribution[0], distribution[1])
        except Exception:
            platform_value = None

        # Try Mac
        if platform_value is None:
            # noinspection PyBroadException
            try:
                mac_ver = platform.mac_ver()[0]
                if len(mac_ver) > 0:
                    platform_value = 'MacOS-%s' % mac_ver
            except Exception:
                platform_value = None

        # Fall back for all others.  This should print out something reasonable for
        # Windows.
        if platform_value is None:
            platform_value = platform.platform(terse=1)

        # Include a string to indicate if python has a true ssl library available to record
        # whether or not the client is doing server certificate verification.
        if __has_ssl__:
            ssl_str = 'ssllib'
        else:
            ssl_str = 'nossllib'

        return '%s;%s;agent-%s;%s;' % (platform_value, python_version_str, agent_version, ssl_str)
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/scalyr_client.py/ScalyrClientSession.__get_user_agent/original