当前位置: 首页>>代码示例>>Python>>正文


Python Platform.is_mac方法代码示例

本文整理汇总了Python中utils.platform.Platform.is_mac方法的典型用法代码示例。如果您正苦于以下问题:Python Platform.is_mac方法的具体用法?Python Platform.is_mac怎么用?Python Platform.is_mac使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.platform.Platform的用法示例。


在下文中一共展示了Platform.is_mac方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        self.options = {}
        system_tray_menu = [
            (self.START, lambda: agent_manager("start")),
            (self.STOP, lambda: agent_manager("stop")),
            (self.RESTART, lambda: agent_manager("restart")),
        ]
        # First the version
        self.addAction(self.ABOUT.format(get_version())).setEnabled(False)
        self.addSeparator()

        for name, action in system_tray_menu:
            self.add_option(name, action)

        # enable or disable mac login
        if Platform.is_mac():
            self.add_option(self.MAC_LOGIN.format(self.enable_or_disable_mac()),
                            lambda: self.enable_or_disable_login())
        elif Platform.is_windows():
            self.add_option(self.FLARE, lambda: thread.start_new_thread(windows_flare, ()))

        # And finally the exit
        self.add_option(self.EXIT, lambda: sys.exit(0))

        self.connect(self, SIGNAL("aboutToShow()"), lambda: self.update_options())
开发者ID:dadicool,项目名称:dd-agent,代码行数:28,代码来源:gui.py

示例2: get_config_path

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
def get_config_path(cfg_path=None, os_name=None):
    # Check if there's an override and if it exists
    if cfg_path is not None and os.path.exists(cfg_path):
        return cfg_path

    # Check if there's a config stored in the current agent directory
    try:
        path = os.path.realpath(__file__)
        path = os.path.dirname(path)
        return _config_path(path)
    except PathNotFound as e:
        pass

    # Check for an OS-specific path, continue on not-found exceptions
    bad_path = ''
    try:
        if Platform.is_windows():
            common_data = _windows_commondata_path()
            return _config_path(os.path.join(common_data, 'Datadog'))
        elif Platform.is_mac():
            return _config_path(MAC_CONFIG_PATH)
        else:
            return _config_path(UNIX_CONFIG_PATH)
    except PathNotFound as e:
        if len(e.args) > 0:
            bad_path = e.args[0]

    # If all searches fail, exit the agent with an error
    sys.stderr.write("Please supply a configuration file at %s or in the directory where "
                     "the Agent is currently deployed.\n" % bad_path)
    sys.exit(3)
开发者ID:ross,项目名称:dd-agent,代码行数:33,代码来源:config.py

示例3: _get_path_supervisor_conf

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
    def _get_path_supervisor_conf(self):
        if Platform.is_mac():
            supervisor_conf = '/opt/datadog-agent/etc/supervisor.conf'
        else:
            supervisor_conf = '/etc/dd-agent/supervisor.conf'

        if not os.path.isfile(supervisor_conf):
            supervisor_conf = os.path.join(
                os.path.dirname(os.path.realpath(__file__)),
                '../../agent/supervisor.conf'
            )
        return supervisor_conf
开发者ID:jimmystewpot,项目名称:dd-agent,代码行数:14,代码来源:flare.py

示例4: _get_path_agent_exec

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
    def _get_path_agent_exec(self):
        if Platform.is_mac():
            agent_exec = '/opt/datadog-agent/bin/datadog-agent'
        else:
            agent_exec = '/etc/init.d/datadog-agent'

        if not os.path.isfile(agent_exec):
            agent_exec = os.path.join(
                os.path.dirname(os.path.realpath(__file__)),
                '../../bin/agent'
            )
        return agent_exec
开发者ID:jimmystewpot,项目名称:dd-agent,代码行数:14,代码来源:flare.py

示例5: get_dir

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
    def get_dir(cls, run_dir=None):
        if run_dir is None:
            my_dir = os.path.dirname(os.path.abspath(__file__))
            if Platform.is_mac():
                # py2app compress this file (.pyc) in
                # /Applications/Datadog Agent.app/Contents/Resources\
                # /lib/python2.7/site-packages.zip/utils/
                # which is not a real directory, so we're using this trick
                run_dir = '/'.join(my_dir.split('/')[:-4])
            else:
                run_dir = os.path.join(my_dir, '..', '..')
            run_dir = os.path.join(run_dir, 'run')

        if os.path.exists(run_dir) and os.access(run_dir, os.W_OK):
            return os.path.realpath(run_dir)
        else:
            return tempfile.gettempdir()
开发者ID:Shopify,项目名称:dd-agent,代码行数:19,代码来源:pidfile.py

示例6: _run_gohai

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
    def _run_gohai(self, options):
        # Gohai is disabled on Mac for now
        if Platform.is_mac():
            return None
        output = None
        try:
            output, err, _ = get_subprocess_output(["gohai"] + options, log)
            if err:
                log.debug("GOHAI LOG | %s", err)
        except OSError as e:
            if e.errno == 2:  # file not found, expected when install from source
                log.info("gohai file not found")
            else:
                log.warning("Unexpected OSError when running gohai %s", e)
        except Exception as e:
            log.warning("gohai command failed with error %s", e)

        return output
开发者ID:motusllc,项目名称:dd-agent,代码行数:20,代码来源:collector.py

示例7: get_confd_path

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
def get_confd_path(osname=None):
    try:
        cur_path = os.path.dirname(os.path.realpath(__file__))
        return _confd_path(cur_path)
    except PathNotFound as e:
        pass

    bad_path = ''
    try:
        if Platform.is_windows():
            common_data = _windows_commondata_path()
            return _confd_path(os.path.join(common_data, 'Datadog'))
        elif Platform.is_mac():
            return _confd_path(MAC_CONFIG_PATH)
        else:
            return _confd_path(UNIX_CONFIG_PATH)
    except PathNotFound as e:
        if len(e.args) > 0:
            bad_path = e.args[0]

    raise PathNotFound(bad_path)
开发者ID:ross,项目名称:dd-agent,代码行数:23,代码来源:config.py

示例8: get_config

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
def get_config(parse_args=True, cfg_path=None, options=None):
    if parse_args:
        options, _ = get_parsed_args()

    # General config
    agentConfig = {
        'check_freq': DEFAULT_CHECK_FREQUENCY,
        'dogstatsd_port': 8125,
        'dogstatsd_target': 'http://localhost:17123',
        'graphite_listen_port': None,
        'hostname': None,
        'listen_port': None,
        'tags': None,
        'use_ec2_instance_id': False,  # DEPRECATED
        'version': get_version(),
        'watchdog': True,
        'additional_checksd': '/etc/dd-agent/checks.d/',
        'bind_host': get_default_bind_host(),
        'statsd_metric_namespace': None,
        'utf8_decoding': False
    }

    if Platform.is_mac():
        agentConfig['additional_checksd'] = '/opt/datadog-agent/etc/checks.d'

    # Config handling
    try:
        # Find the right config file
        path = os.path.realpath(__file__)
        path = os.path.dirname(path)

        config_path = get_config_path(cfg_path, os_name=get_os())
        config = ConfigParser.ConfigParser()
        config.readfp(skip_leading_wsp(open(config_path)))

        # bulk import
        for option in config.options('Main'):
            agentConfig[option] = config.get('Main', option)

        # Store developer mode setting in the agentConfig
        if config.has_option('Main', 'developer_mode'):
            agentConfig['developer_mode'] = _is_affirmative(config.get('Main', 'developer_mode'))

        # Allow an override with the --profile option
        if options is not None and options.profile:
            agentConfig['developer_mode'] = True

        #
        # Core config
        #ap
        if not config.has_option('Main', 'api_key'):
            log.warning(u"No API key was found. Aborting.")
            sys.exit(2)

        if not config.has_option('Main', 'dd_url'):
            log.warning(u"No dd_url was found. Aborting.")
            sys.exit(2)

        # Endpoints
        dd_urls = map(clean_dd_url, config.get('Main', 'dd_url').split(','))
        api_keys = map(lambda el: el.strip(), config.get('Main', 'api_key').split(','))

        # For collector and dogstatsd
        agentConfig['dd_url'] = dd_urls[0]
        agentConfig['api_key'] = api_keys[0]

        # Forwarder endpoints logic
        # endpoints is:
        # {
        #    'https://app.datadoghq.com': ['api_key_abc', 'api_key_def'],
        #    'https://app.example.com': ['api_key_xyz']
        # }
        endpoints = {}
        dd_urls = remove_empty(dd_urls)
        api_keys = remove_empty(api_keys)
        if len(dd_urls) == 1:
            if len(api_keys) > 0:
                endpoints[dd_urls[0]] = api_keys
        else:
            assert len(dd_urls) == len(api_keys), 'Please provide one api_key for each url'
            for i, dd_url in enumerate(dd_urls):
                endpoints[dd_url] = endpoints.get(dd_url, []) + [api_keys[i]]

        agentConfig['endpoints'] = endpoints

        # Forwarder or not forwarder
        agentConfig['use_forwarder'] = options is not None and options.use_forwarder
        if agentConfig['use_forwarder']:
            listen_port = 17123
            if config.has_option('Main', 'listen_port'):
                listen_port = int(config.get('Main', 'listen_port'))
            agentConfig['dd_url'] = "http://{}:{}".format(agentConfig['bind_host'], listen_port)
        # FIXME: Legacy dd_url command line switch
        elif options is not None and options.dd_url is not None:
            agentConfig['dd_url'] = options.dd_url

        # Forwarder timeout
        agentConfig['forwarder_timeout'] = 20
        if config.has_option('Main', 'forwarder_timeout'):
            agentConfig['forwarder_timeout'] = int(config.get('Main', 'forwarder_timeout'))
#.........这里部分代码省略.........
开发者ID:ewdurbin,项目名称:dd-agent,代码行数:103,代码来源:config.py

示例9: get_config

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
def get_config(parse_args=True, cfg_path=None, options=None):
    if parse_args:
        options, _ = get_parsed_args()

    # General config
    agentConfig = {
        'check_freq': DEFAULT_CHECK_FREQUENCY,
        'dogstatsd_port': 8125,
        'dogstatsd_target': 'http://localhost:17123',
        'graphite_listen_port': None,
        'hostname': None,
        'listen_port': None,
        'tags': None,
        'use_ec2_instance_id': False,  # DEPRECATED
        'version': get_version(),
        'watchdog': True,
        'additional_checksd': '/etc/dd-agent/checks.d/',
        'bind_host': get_default_bind_host(),
        'statsd_metric_namespace': None,
        'utf8_decoding': False
    }

    if Platform.is_mac():
        agentConfig['additional_checksd'] = '/opt/datadog-agent/etc/checks.d'

    # Config handling
    try:
        # Find the right config file
        path = os.path.realpath(__file__)
        path = os.path.dirname(path)

        config_path = get_config_path(cfg_path, os_name=get_os())
        config = ConfigParser.ConfigParser()
        config.readfp(skip_leading_wsp(open(config_path)))

        # bulk import
        for option in config.options('Main'):
            agentConfig[option] = config.get('Main', option)

        # Store developer mode setting in the agentConfig
        in_developer_mode = None
        if config.has_option('Main', 'developer_mode'):
            agentConfig['developer_mode'] = _is_affirmative(config.get('Main', 'developer_mode'))

        # Allow an override with the --profile option
        if options is not None and options.profile:
            agentConfig['developer_mode'] = True

        #
        # Core config
        #

        # FIXME unnecessarily complex

        if config.has_option('Main', 'use_dd'):
            agentConfig['use_dd'] = config.get('Main', 'use_dd').lower() in ("yes", "true")
        else:
            agentConfig['use_dd'] = True

        agentConfig['use_forwarder'] = False
        if options is not None and options.use_forwarder:
            listen_port = 17123
            if config.has_option('Main', 'listen_port'):
                listen_port = int(config.get('Main', 'listen_port'))
            agentConfig['dd_url'] = "http://" + agentConfig['bind_host'] + ":" + str(listen_port)
            agentConfig['use_forwarder'] = True
        elif options is not None and not options.disable_dd and options.dd_url:
            agentConfig['dd_url'] = options.dd_url
        else:
            agentConfig['dd_url'] = config.get('Main', 'dd_url')
        if agentConfig['dd_url'].endswith('/'):
            agentConfig['dd_url'] = agentConfig['dd_url'][:-1]

        # Extra checks.d path
        # the linux directory is set by default
        if config.has_option('Main', 'additional_checksd'):
            agentConfig['additional_checksd'] = config.get('Main', 'additional_checksd')
        elif get_os() == 'windows':
            # default windows location
            common_path = _windows_commondata_path()
            agentConfig['additional_checksd'] = os.path.join(common_path, 'Datadog', 'checks.d')

        if config.has_option('Main', 'use_dogstatsd'):
            agentConfig['use_dogstatsd'] = config.get('Main', 'use_dogstatsd').lower() in ("yes", "true")
        else:
            agentConfig['use_dogstatsd'] = True

        # Concerns only Windows
        if config.has_option('Main', 'use_web_info_page'):
            agentConfig['use_web_info_page'] = config.get('Main', 'use_web_info_page').lower() in ("yes", "true")
        else:
            agentConfig['use_web_info_page'] = True

        if not agentConfig['use_dd']:
            sys.stderr.write("Please specify at least one endpoint to send metrics to. This can be done in datadog.conf.")
            exit(2)

        # Which API key to use
        agentConfig['api_key'] = config.get('Main', 'api_key')

#.........这里部分代码省略.........
开发者ID:darron,项目名称:dd-agent,代码行数:103,代码来源:config.py

示例10: kill_old_process

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
        fp.write(str(pid))
        fp.close()
    except Exception, e:
        msg = "Unable to write pidfile: %s" % pidfile
        log.exception(msg)
        sys.stderr.write(msg + "\n")
        sys.exit(1)


if __name__ == '__main__':
    if Platform.is_windows():
        # Let's kill any other running instance of our GUI/SystemTray before starting a new one.
        kill_old_process()

    app = QApplication([])
    if Platform.is_mac():
        add_image_path(osp.join(os.getcwd(), 'images'))
        # add datadog-agent in PATH
        os.environ['PATH'] = "{0}:{1}".format(
            '/opt/datadog-agent/bin/',
            os.environ['PATH']
        )
        win = SystemTray() if len(sys.argv) < 2 else MainWindow()
    else:
        win = MainWindow()
    # Let's start the agent if he's not already started
    if agent_status() not in [AGENT_RUNNING, AGENT_START_PENDING]:
        agent_manager('start')
    win.show()
    app.exec_()
开发者ID:dadicool,项目名称:dd-agent,代码行数:32,代码来源:gui.py

示例11: get_config

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_mac [as 别名]
def get_config(parse_args=True, cfg_path=None, options=None):
    if parse_args:
        options, _ = get_parsed_args()

    # General config
    agentConfig = {
        "check_freq": DEFAULT_CHECK_FREQUENCY,
        "dogstatsd_port": 8125,
        "dogstatsd_target": "http://localhost:17123",
        "graphite_listen_port": None,
        "hostname": None,
        "listen_port": None,
        "tags": None,
        "use_ec2_instance_id": False,  # DEPRECATED
        "version": get_version(),
        "watchdog": True,
        "additional_checksd": "/etc/dd-agent/checks.d/",
        "bind_host": get_default_bind_host(),
        "statsd_metric_namespace": None,
        "utf8_decoding": False,
    }

    if Platform.is_mac():
        agentConfig["additional_checksd"] = "/opt/datadog-agent/etc/checks.d"

    # Config handling
    try:
        # Find the right config file
        path = os.path.realpath(__file__)
        path = os.path.dirname(path)

        config_path = get_config_path(cfg_path, os_name=get_os())
        config = ConfigParser.ConfigParser()
        config.readfp(skip_leading_wsp(open(config_path)))

        # bulk import
        for option in config.options("Main"):
            agentConfig[option] = config.get("Main", option)

        # Store developer mode setting in the agentConfig
        in_developer_mode = None
        if config.has_option("Main", "developer_mode"):
            agentConfig["developer_mode"] = _is_affirmative(config.get("Main", "developer_mode"))

        # Allow an override with the --profile option
        if options is not None and options.profile:
            agentConfig["developer_mode"] = True

        #
        # Core config
        #

        # FIXME unnecessarily complex
        agentConfig["use_forwarder"] = False
        if options is not None and options.use_forwarder:
            listen_port = 17123
            if config.has_option("Main", "listen_port"):
                listen_port = int(config.get("Main", "listen_port"))
            agentConfig["dd_url"] = "http://" + agentConfig["bind_host"] + ":" + str(listen_port)
            agentConfig["use_forwarder"] = True
        elif options is not None and not options.disable_dd and options.dd_url:
            agentConfig["dd_url"] = options.dd_url
        else:
            agentConfig["dd_url"] = config.get("Main", "dd_url")
        if agentConfig["dd_url"].endswith("/"):
            agentConfig["dd_url"] = agentConfig["dd_url"][:-1]

        # Extra checks.d path
        # the linux directory is set by default
        if config.has_option("Main", "additional_checksd"):
            agentConfig["additional_checksd"] = config.get("Main", "additional_checksd")
        elif get_os() == "windows":
            # default windows location
            common_path = _windows_commondata_path()
            agentConfig["additional_checksd"] = os.path.join(common_path, "Datadog", "checks.d")

        if config.has_option("Main", "use_dogstatsd"):
            agentConfig["use_dogstatsd"] = config.get("Main", "use_dogstatsd").lower() in ("yes", "true")
        else:
            agentConfig["use_dogstatsd"] = True

        # Concerns only Windows
        if config.has_option("Main", "use_web_info_page"):
            agentConfig["use_web_info_page"] = config.get("Main", "use_web_info_page").lower() in ("yes", "true")
        else:
            agentConfig["use_web_info_page"] = True

        # Which API key to use
        agentConfig["api_key"] = config.get("Main", "api_key")

        # local traffic only? Default to no
        agentConfig["non_local_traffic"] = False
        if config.has_option("Main", "non_local_traffic"):
            agentConfig["non_local_traffic"] = config.get("Main", "non_local_traffic").lower() in ("yes", "true")

        # DEPRECATED
        if config.has_option("Main", "use_ec2_instance_id"):
            use_ec2_instance_id = config.get("Main", "use_ec2_instance_id")
            # translate yes into True, the rest into False
            agentConfig["use_ec2_instance_id"] = use_ec2_instance_id.lower() == "yes"
#.........这里部分代码省略.........
开发者ID:relateiq,项目名称:dd-agent,代码行数:103,代码来源:config.py


注:本文中的utils.platform.Platform.is_mac方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。