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


Python Flare.upload方法代码示例

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


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

示例1: test_endpoint

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
 def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
     f = Flare()
     f._ask_for_email = lambda: None
     try:
         f.upload(confirmation=False)
         raise Exception('Should fail before')
     except Exception, e:
         self.assertEqual(str(e), "Your request is incorrect: Invalid inputs: 'API key unknown'")
开发者ID:AquaBindi,项目名称:dd-agent,代码行数:10,代码来源:test_flare.py

示例2: test_endpoint

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
开发者ID:SupersonicAds,项目名称:dd-agent,代码行数:12,代码来源:test_flare.py

示例3: test_endpoint

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
        if os.environ['FLARE_BROKEN']:
            raise unittest.case.SkipTest('Flare broken, acknowledged')
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
开发者ID:jalaziz,项目名称:dd-agent,代码行数:14,代码来源:test_flare.py

示例4: windows_flare

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
def windows_flare():
    case_id, ok = QInputDialog.getInteger(
        None, "Flare",
        "Your logs and configuration files are going to be collected and "
        "sent to Datadog Support. Please enter your ticket number if you have one:",
        value=0, min=0
    )
    if not ok:
        info_popup("Flare cancelled")
        return
    case_id = int(case_id) if case_id != 0 else None
    f = Flare(case_id=case_id)
    f.collect()
    email, ok = QInputDialog.getText(
        None, "Your email",
        "Logs and configuration files have been collected."
        " Please enter your email address:"
    )
    if not ok:
        info_popup("Flare cancelled. You can still use {0}".format(f.tar_path))
        return
    try:
        case_id = f.upload(email=str(email))
        info_popup("Your logs were successfully uploaded. For future reference,"
                   " your internal case id is {0}".format(case_id))
    except Exception, e:
        warning_popup('The upload failed. Please send the following file by email'
                      ' to support: {0}\n\n{1}'.format(f.tar_path, str(e)))
开发者ID:dadicool,项目名称:dd-agent,代码行数:30,代码来源:gui.py

示例5: test_upload_with_case

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
    def test_upload_with_case(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
        f = Flare(case_id=1337)

        assert not mock_requests.called
        f.upload(confirmation=False)
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args,
            ('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
        )
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
        )
        self.assertEqual(kwargs['data']['case_id'], 1337)
        self.assertEqual(kwargs['data']['email'], '')
        assert kwargs['data']['hostname']
开发者ID:AquaBindi,项目名称:dd-agent,代码行数:20,代码来源:test_flare.py

示例6: test_upload_no_case

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
    def test_upload_no_case(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
        f = Flare()
        f._ask_for_email = lambda: '[email protected]'

        assert not mock_requests.called
        f.upload()
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args,
            ('https://6-6-6-flare.agent.datadoghq.com/support/flare?api_key=APIKEY',)
        )
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
        )
        self.assertEqual(kwargs['data']['case_id'], None)
        self.assertEqual(kwargs['data']['email'], '[email protected]')
        assert kwargs['data']['hostname']
开发者ID:KnownSubset,项目名称:dd-agent,代码行数:21,代码来源:test_flare.py

示例7: test_upload_with_case_proxy

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]
    def test_upload_with_case_proxy(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
        f = Flare(case_id=1337)
        f._ask_for_email = lambda: '[email protected]'

        assert not mock_requests.called
        f.upload()
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args,
            ('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
        )
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
        )
        self.assertEqual(kwargs['data']['case_id'], 1337)
        self.assertEqual(kwargs['data']['email'], '[email protected]')
        assert kwargs['data']['hostname']
        assert kwargs['proxies']['https'] == 'http://proxy_user:[email protected]:3128'
        assert not kwargs['verify']
开发者ID:7040210,项目名称:dd-agent,代码行数:23,代码来源:test_flare.py

示例8: main

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]

#.........这里部分代码省略.........

    command = args[0]
    if command not in COMMANDS:
        sys.stderr.write("Unknown command: %s\n" % command)
        return 3

    # TODO: actually kill the start/stop/restart/status command for 5.11
    if command in ['start', 'stop', 'restart', 'status'] and not in_developer_mode:
        logging.error('Please use supervisor to manage the agent')
        return 1

    if command in COMMANDS_AGENT:
        agent = Agent(PidFile(PID_NAME, PID_DIR).get_path(), autorestart, in_developer_mode=in_developer_mode)

    if 'start' == command:
        log.info('Start daemon')
        agent.start()

    elif 'stop' == command:
        log.info('Stop daemon')
        agent.stop()

    elif 'restart' == command:
        log.info('Restart daemon')
        agent.restart()

    elif 'status' == command:
        agent.status()

    elif 'info' == command:
        return Agent.info(verbose=options.verbose)

    elif 'foreground' == command:
        log.info('Agent version %s' % get_version())
        if autorestart:
            # Set-up the supervisor callbacks and fork it.
            logging.info('Running Agent with auto-restart ON')

            def child_func():
                agent.start(foreground=True)

            def parent_func():
                agent.start_event = False

            AgentSupervisor.start(parent_func, child_func)
        else:
            # Run in the standard foreground.
            agent.start(foreground=True)

    elif 'check' == command:
        if len(args) < 2:
            sys.stderr.write(
                "Usage: %s check <check_name> [check_rate]\n"
                "Add check_rate as last argument to compute rates\n"
                % sys.argv[0]
            )
            return 1

        check_name = args[1]
        try:
            import checks.collector
            # Try the old-style check first
            print getattr(checks.collector, check_name)(log).check(agentConfig)
        except Exception:
            # If not an old-style check, try checks.d
            checks = load_check_directory(agentConfig, hostname)
            for check in checks['initialized_checks']:
                if check.name == check_name:
                    if in_developer_mode:
                        check.run = AgentProfiler.wrap_profiling(check.run)

                    cs = Collector.run_single_check(check, verbose=True)
                    print CollectorStatus.render_check_status(cs)

                    if len(args) == 3 and args[2] == 'check_rate':
                        print "Running 2nd iteration to capture rate metrics"
                        time.sleep(1)
                        cs = Collector.run_single_check(check, verbose=True)
                        print CollectorStatus.render_check_status(cs)

                    check.stop()

    elif 'configcheck' == command or 'configtest' == command:
        configcheck()
        sd_configcheck(agentConfig)

    elif 'jmx' == command:
        jmx_command(args[1:], agentConfig)

    elif 'flare' == command:
        Flare.check_user_rights()
        case_id = int(args[1]) if len(args) > 1 else None
        f = Flare(True, case_id)
        f.collect()
        try:
            f.upload()
        except Exception as e:
            print 'The upload failed:\n{0}'.format(str(e))

    return 0
开发者ID:alanbover,项目名称:dd-agent,代码行数:104,代码来源:agent.py

示例9: main

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]

#.........这里部分代码省略.........

    if command in START_COMMANDS:
        log.info("Agent version %s" % get_version())

    if "start" == command:
        log.info("Start daemon")
        agent.start()

    elif "stop" == command:
        log.info("Stop daemon")
        agent.stop()

    elif "restart" == command:
        log.info("Restart daemon")
        agent.restart()

    elif "status" == command:
        agent.status()

    elif "info" == command:
        return Agent.info(verbose=options.verbose)

    elif "foreground" == command:
        logging.info("Running in foreground")
        if autorestart:
            # Set-up the supervisor callbacks and fork it.
            logging.info("Running Agent with auto-restart ON")

            def child_func():
                agent.start(foreground=True)

            def parent_func():
                agent.start_event = False

            AgentSupervisor.start(parent_func, child_func)
        else:
            # Run in the standard foreground.
            agent.start(foreground=True)

    elif "check" == command:
        if len(args) < 2:
            sys.stderr.write(
                "Usage: %s check <check_name> [check_rate]\n"
                "Add check_rate as last argument to compute rates\n" % sys.argv[0]
            )
            return 1

        check_name = args[1]
        try:
            import checks.collector

            # Try the old-style check first
            print getattr(checks.collector, check_name)(log).check(agentConfig)
        except Exception:
            # If not an old-style check, try checks.d
            checks = load_check_directory(agentConfig, hostname)
            for check in checks["initialized_checks"]:
                if check.name == check_name:
                    if in_developer_mode:
                        check.run = AgentProfiler.wrap_profiling(check.run)

                    cs = Collector.run_single_check(check, verbose=True)
                    print CollectorStatus.render_check_status(cs)

                    if len(args) == 3 and args[2] == "check_rate":
                        print "Running 2nd iteration to capture rate metrics"
                        time.sleep(1)
                        cs = Collector.run_single_check(check, verbose=True)
                        print CollectorStatus.render_check_status(cs)

                    check.stop()

    elif "configcheck" == command or "configtest" == command:
        configcheck()

        if agentConfig.get("service_discovery", False):
            # set the TRACE_CONFIG flag to True to make load_check_directory return
            # the source of config objects.
            # Then call load_check_directory here and pass the result to sd_configcheck
            # to avoid circular imports
            agentConfig[TRACE_CONFIG] = True
            configs = {
                # check_name: (config_source, config)
            }
            print ("\nLoading check configurations...\n\n")
            configs = load_check_directory(agentConfig, hostname)
            sd_configcheck(agentConfig, configs)

    elif "jmx" == command:
        jmx_command(args[1:], agentConfig)

    elif "flare" == command:
        Flare.check_user_rights()
        case_id = int(args[1]) if len(args) > 1 else None
        f = Flare(True, case_id)
        f.collect()
        try:
            f.upload()
        except Exception, e:
            print "The upload failed:\n{0}".format(str(e))
开发者ID:WPMedia,项目名称:dd-agent,代码行数:104,代码来源:agent.py

示例10: main

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]

#.........这里部分代码省略.........
        log.info('Restart daemon')
        agent.restart()

    elif 'status' == command:
        agent.status()

    elif 'info' == command:
        return Agent.info(verbose=options.verbose)

    elif 'foreground' == command:
        logging.info('Running in foreground')
        if autorestart:
            # Set-up the supervisor callbacks and fork it.
            logging.info('Running Agent with auto-restart ON')

            def child_func():
                agent.start(foreground=True)

            def parent_func():
                agent.start_event = False

            AgentSupervisor.start(parent_func, child_func)
        else:
            # Run in the standard foreground.
            agent.start(foreground=True)

    elif 'check' == command:
        if len(args) < 2:
            sys.stderr.write(
                "Usage: %s check <check_name> [check_rate]\n"
                "Add check_rate as last argument to compute rates\n"
                % sys.argv[0]
            )
            return 1

        check_name = args[1]
        try:
            import checks.collector
            # Try the old-style check first
            print getattr(checks.collector, check_name)(log).check(agentConfig)
        except Exception:
            # If not an old-style check, try checks.d
            checks = load_check_directory(agentConfig, hostname)
            for check in checks['initialized_checks']:
                if check.name == check_name:
                    if in_developer_mode:
                        check.run = AgentProfiler.wrap_profiling(check.run)

                    cs = Collector.run_single_check(check, verbose=True)
                    print CollectorStatus.render_check_status(cs)

                    if len(args) == 3 and args[2] == 'check_rate':
                        print "Running 2nd iteration to capture rate metrics"
                        time.sleep(1)
                        cs = Collector.run_single_check(check, verbose=True)
                        print CollectorStatus.render_check_status(cs)

                    check.stop()

    elif 'configcheck' == command or 'configtest' == command:
        configcheck()

    elif 'jmx' == command:
        if len(args) < 2 or args[1] not in JMX_LIST_COMMANDS.keys():
            print "#" * 80
            print "JMX tool to be used to help configuring your JMX checks."
            print "See http://docs.datadoghq.com/integrations/java/ for more information"
            print "#" * 80
            print "\n"
            print "You have to specify one of the following commands:"
            for command, desc in JMX_LIST_COMMANDS.iteritems():
                print "      - %s [OPTIONAL: LIST OF CHECKS]: %s" % (command, desc)
            print "Example: sudo /etc/init.d/datadog-agent jmx list_matching_attributes tomcat jmx solr"
            print "\n"

        else:
            jmx_command = args[1]
            checks_list = args[2:]
            confd_directory = get_confd_path(get_os())

            jmx_process = JMXFetch(confd_directory, agentConfig)
            jmx_process.configure()
            should_run = jmx_process.should_run()

            if should_run:
                jmx_process.run(jmx_command, checks_list, reporter="console")
            else:
                print "Couldn't find any valid JMX configuration in your conf.d directory: %s" % confd_directory
                print "Have you enabled any JMX check ?"
                print "If you think it's not normal please get in touch with Datadog Support"

    elif 'flare' == command:
        Flare.check_user_rights()
        case_id = int(args[1]) if len(args) > 1 else None
        f = Flare(True, case_id)
        f.collect()
        try:
            f.upload()
        except Exception, e:
            print 'The upload failed:\n{0}'.format(str(e))
开发者ID:KnownSubset,项目名称:dd-agent,代码行数:104,代码来源:agent.py

示例11: main

# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import upload [as 别名]

#.........这里部分代码省略.........
        agent.stop()

    elif "restart" == command:
        log.info("Restart daemon")
        agent.restart()

    elif "status" == command:
        agent.status()

    elif "info" == command:
        return agent.info(verbose=options.verbose)

    elif "foreground" == command:
        logging.info("Running in foreground")
        if autorestart:
            # Set-up the supervisor callbacks and fork it.
            logging.info("Running Agent with auto-restart ON")

            def child_func():
                agent.start(foreground=True)

            def parent_func():
                agent.start_event = False

            AgentSupervisor.start(parent_func, child_func)
        else:
            # Run in the standard foreground.
            agent.start(foreground=True)

    elif "check" == command:
        if len(args) < 2:
            sys.stderr.write(
                "Usage: %s check <check_name> [check_rate]\n"
                "Add check_rate as last argument to compute rates\n" % sys.argv[0]
            )
            return 1

        check_name = args[1]
        try:
            import checks.collector

            # Try the old-style check first
            print getattr(checks.collector, check_name)(log).check(agentConfig)
        except Exception:
            # If not an old-style check, try checks.d
            checks = load_check_directory(agentConfig, hostname)
            for check in checks["initialized_checks"]:
                if check.name == check_name:
                    check.run()
                    print check.get_metrics()
                    print check.get_events()
                    print check.get_service_checks()
                    if len(args) == 3 and args[2] == "check_rate":
                        print "Running 2nd iteration to capture rate metrics"
                        time.sleep(1)
                        check.run()
                        print check.get_metrics()
                        print check.get_events()
                        print check.get_service_checks()
                    check.stop()

    elif "configcheck" == command or "configtest" == command:
        configcheck()

    elif "jmx" == command:
        from jmxfetch import JMX_LIST_COMMANDS, JMXFetch

        if len(args) < 2 or args[1] not in JMX_LIST_COMMANDS.keys():
            print "#" * 80
            print "JMX tool to be used to help configuring your JMX checks."
            print "See http://docs.datadoghq.com/integrations/java/ for more information"
            print "#" * 80
            print "\n"
            print "You have to specify one of the following commands:"
            for command, desc in JMX_LIST_COMMANDS.iteritems():
                print "      - %s [OPTIONAL: LIST OF CHECKS]: %s" % (command, desc)
            print "Example: sudo /etc/init.d/datadog-agent jmx list_matching_attributes tomcat jmx solr"
            print "\n"

        else:
            jmx_command = args[1]
            checks_list = args[2:]
            confd_directory = get_confd_path(get_os())

            jmx_process = JMXFetch(confd_directory, agentConfig)
            should_run = jmx_process.run(jmx_command, checks_list, reporter="console")
            if not should_run:
                print "Couldn't find any valid JMX configuration in your conf.d directory: %s" % confd_directory
                print "Have you enabled any JMX check ?"
                print "If you think it's not normal please get in touch with Datadog Support"

    elif "flare" == command:
        Flare.check_user_rights()
        case_id = int(args[1]) if len(args) > 1 else None
        f = Flare(True, case_id)
        f.collect()
        try:
            f.upload()
        except Exception, e:
            print "The upload failed:\n{0}".format(str(e))
开发者ID:miketheman,项目名称:dd-agent,代码行数:104,代码来源:agent.py


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