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


Python modules.load函数代码示例

本文整理汇总了Python中modules.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: build

 def build(self):
     data.loadSettings()
     if data.credentials.isDefined():
         self.connect()
         data.scanGrounds()
     modules.load(data.moduleNames)
     self._main = MainWindow()
     return self._main
开发者ID:ATT-JBO,项目名称:pyGate-config,代码行数:8,代码来源:main.py

示例2: onModuleToggled

    def onModuleToggled(self, renderer, path):
        """ A module has been enabled/disabled """
        row  = self.list.getRow(path)
        name = row[ROW_MODINFO][modules.MODINFO_NAME]

        if row[ROW_ENABLED]:
            modules.unload(name)
        else:
            try:                             modules.load(name)
            except modules.LoadException, e: gui.errorMsgBox(self.window, _('Unable to load this module.'), str(e))

        self.fillList()
开发者ID:Nenuphar,项目名称:decibel-audio-player,代码行数:12,代码来源:preferences.py

示例3: __init__

    def __init__(self, agentConfig, emitters, systemStats):
        self.emit_duration = None
        self.agentConfig = agentConfig
        # system stats is generated by config.get_system_stats
        self.agentConfig["system_stats"] = systemStats
        # agent config is used during checks, system_stats can be accessed through the config
        self.os = get_os()
        self.plugins = None
        self.emitters = emitters
        self.metadata_interval = int(agentConfig.get("metadata_interval", 10 * 60))
        self.metadata_start = time.time()
        socket.setdefaulttimeout(15)
        self.run_count = 0
        self.continue_running = True
        self.metadata_cache = None
        self.initialized_checks_d = []
        self.init_failed_checks_d = []

        # Unix System Checks
        self._unix_system_checks = {
            "disk": u.Disk(log),
            "io": u.IO(log),
            "load": u.Load(log),
            "memory": u.Memory(log),
            "processes": u.Processes(log),
            "cpu": u.Cpu(log),
        }

        # Win32 System `Checks
        self._win32_system_checks = {
            "disk": w32.Disk(log),
            "io": w32.IO(log),
            "proc": w32.Processes(log),
            "memory": w32.Memory(log),
            "network": w32.Network(log),
            "cpu": w32.Cpu(log),
        }

        # Old-style metric checks
        self._ganglia = Ganglia(log)
        self._dogstream = Dogstreams.init(log, self.agentConfig)
        self._ddforwarder = DdForwarder(log, self.agentConfig)

        # Agent Metrics
        self._agent_metrics = CollectorMetrics(log)

        self._metrics_checks = []

        # Custom metric checks
        for module_spec in [s.strip() for s in self.agentConfig.get("custom_checks", "").split(",")]:
            if len(module_spec) == 0:
                continue
            try:
                self._metrics_checks.append(modules.load(module_spec, "Check")(log))
                log.info("Registered custom check %s" % module_spec)
                log.warning(
                    "Old format custom checks are deprecated. They should be moved to the checks.d interface as old custom checks will be removed in a next version"
                )
            except Exception, e:
                log.exception("Unable to load custom check module %s" % module_spec)
开发者ID:kzw,项目名称:dd-agent,代码行数:60,代码来源:collector.py

示例4: init

    def init(cls, logger, log_path, parser_spec=None, parser_args=None, config=None):
        class_based = False
        parse_func = None
        parse_args = tuple(parser_args or ())

        if parser_spec:
            try:
                parse_func = modules.load(parser_spec)
                if isinstance(parse_func, type):
                    logger.info('Instantiating class-based dogstream')
                    parse_func = parse_func(
                        user_args=parse_args or (),
                        logger=logger,
                        log_path=log_path,
                        config=config,
                    )
                    parse_args = ()
                    class_based = True
                else:
                    logger.info('Instantiating function-based dogstream')
            except Exception:
                logger.exception(traceback.format_exc())
                logger.error('Could not load Dogstream line parser "%s" PYTHONPATH=%s' % (
                    parser_spec,
                    os.environ.get('PYTHONPATH', ''))
                )
            logger.info("dogstream: parsing %s with %s (requested %s)" % (log_path, parse_func, parser_spec))
        else:
            logger.info("dogstream: parsing %s with default parser" % log_path)

        return cls(logger, log_path, parse_func, parse_args, class_based=class_based)
开发者ID:p1r4te,项目名称:dd-agent,代码行数:31,代码来源:datadog.py

示例5: __init__

    def __init__(self, agentConfig, emitters, systemStats):
        self.emit_duration = None
        self.agentConfig = agentConfig
        # system stats is generated by config.get_system_stats
        self.agentConfig['system_stats'] = systemStats
        # agent config is used during checks, system_stats can be accessed through the config
        self.os = get_os()
        self.plugins = None
        self.emitters = emitters            
        self.metadata_interval = int(agentConfig.get('metadata_interval', 10 * 60))
        self.metadata_start = time.time()
        socket.setdefaulttimeout(15)
        self.run_count = 0
        self.continue_running = True
        self.metadata_cache = None
        self.checks_d = []
        
        # Unix System Checks
        self._unix_system_checks = {
            'disk': u.Disk(log),
            'io': u.IO(log),
            'load': u.Load(log),
            'memory': u.Memory(log),
            'processes': u.Processes(log),
            'cpu': u.Cpu(log)
        }

        # Win32 System `Checks
        self._win32_system_checks = {
            'disk': w32.Disk(log),
            'io': w32.IO(log),
            'proc': w32.Processes(log),
            'memory': w32.Memory(log),
            'network': w32.Network(log),
            'cpu': w32.Cpu(log)
        }

        # Old-style metric checks
        self._ganglia = Ganglia(log)
        self._cassandra = Cassandra()
        self._dogstream = Dogstreams.init(log, self.agentConfig)
        self._ddforwarder = DdForwarder(log, self.agentConfig)

        # Agent Metrics
        self._agent_metrics = CollectorMetrics(log)

        # Metric Checks
        self._metrics_checks = [
            Memcache(log),
        ]

        # Custom metric checks
        for module_spec in [s.strip() for s in self.agentConfig.get('custom_checks', '').split(',')]:
            if len(module_spec) == 0: continue
            try:
                self._metrics_checks.append(modules.load(module_spec, 'Check')(log))
                log.info("Registered custom check %s" % module_spec)
            except Exception, e:
                log.exception('Unable to load custom check module %s' % module_spec)
开发者ID:fragallia,项目名称:dd-agent,代码行数:59,代码来源:collector.py

示例6: test_modname_load_specified

 def test_modname_load_specified(self):
     """When the specifier contains a module name, any provided default
     should be overridden"""
     self.assertEquals(
         modules.load(
             'tests.target_module:specified_target',
             'default_target'),
         'SPECIFIED'
     )
开发者ID:CaptTofu,项目名称:dd-agent,代码行数:9,代码来源:test_modules.py

示例7: get_emitters

    def get_emitters(self):
        emitters = [http_emitter]
        custom = [s.strip() for s in self.config.get("custom_emitters", "").split(",")]
        for emitter_spec in custom:
            if not emitter_spec:
                continue
            emitters.append(modules.load(emitter_spec, "emitter"))

        return emitters
开发者ID:sschepens,项目名称:dd-agent,代码行数:9,代码来源:agent.py

示例8: test_modname_load_specified

 def test_modname_load_specified(self):
     """When the specifier contains a module name, any provided default
     should be overridden"""
     self.assertEquals(
         modules.load(
             '{0}:specified_target'.format(TARGET_MODULE),
             'default_target'),
         'SPECIFIED'
     )
开发者ID:serverdensity,项目名称:sd-agent,代码行数:9,代码来源:test_modules.py

示例9: test_modname_load_default

 def test_modname_load_default(self):
     """When the specifier contains no module name, any provided default
     should be used"""
     self.assertEquals(
         modules.load(
             'tests.target_module',
             'default_target'),
         'DEFAULT'
     )
开发者ID:CaptTofu,项目名称:dd-agent,代码行数:9,代码来源:test_modules.py

示例10: get_emitters

    def get_emitters(self):
        emitters = [http_emitter]
        custom = [s.strip() for s in
            self.config.get('custom_emitters', '').split(',')]
        for emitter_spec in custom:
            if not emitter_spec:
                continue
            emitters.append(modules.load(emitter_spec, 'emitter'))

        return emitters
开发者ID:Osterjour,项目名称:dd-agent,代码行数:10,代码来源:agent.py

示例11: __init__

    def __init__(self, agentConfig, emitters):
        self.agentConfig = agentConfig
        self.plugins = None
        self.emitters = emitters
        self.os = None

        self.checksLogger = logging.getLogger("checks")
        socket.setdefaulttimeout(15)

        self._apache = Apache(self.checksLogger)
        self._nginx = Nginx(self.checksLogger)
        self._disk = Disk(self.checksLogger)
        self._io = IO()
        self._load = Load(self.checksLogger)
        self._memory = Memory(self.checksLogger)
        self._network = Network(self.checksLogger)
        self._processes = Processes()
        self._cpu = Cpu()
        self._couchdb = CouchDb(self.checksLogger)
        self._mongodb = MongoDb(self.checksLogger)
        self._mysql = MySql(self.checksLogger)
        self._pgsql = PostgreSql(self.checksLogger)
        self._rabbitmq = RabbitMq()
        self._ganglia = Ganglia(self.checksLogger)
        self._cassandra = Cassandra()
        self._redis = Redis(self.checksLogger)
        self._jvm = Jvm(self.checksLogger)
        self._tomcat = Tomcat(self.checksLogger)
        self._activemq = ActiveMQ(self.checksLogger)
        self._solr = Solr(self.checksLogger)
        self._memcache = Memcache(self.checksLogger)
        self._dogstream = Dogstreams.init(self.checksLogger, self.agentConfig)
        self._ddforwarder = DdForwarder(self.checksLogger, self.agentConfig)

        # All new checks should be metrics checks:
        self._metrics_checks = [
            Cacti(self.checksLogger),
            Redis(self.checksLogger),
            Varnish(self.checksLogger),
            ElasticSearch(self.checksLogger),
        ]

        for module_spec in [s.strip() for s in self.agentConfig.get("custom_checks", "").split(",")]:
            if len(module_spec) == 0:
                continue
            try:
                self._metrics_checks.append(modules.load(module_spec, "Check")(self.checksLogger))
                self.checksLogger.info("Registered custom check %s" % module_spec)
            except Exception, e:
                self.checksLogger.exception("Unable to load custom check module %s" % module_spec)
开发者ID:SafPlusPlus,项目名称:dd-agent,代码行数:50,代码来源:common.py

示例12: __init__

	def __init__ (self, name="default"):
		asyncore.dispatcher.__init__(self)
		self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
		self.name = name
		conf = config.link[name]
		self.connectedto = conf['remote']
		self.connect (self.connectedto)
		self.sid = conf['sid']
		self.conf = conf
		
		self.sendq = ''
		self.recvq = ''
		
		self.protocol = modules.load(conf['protocol'], self)
开发者ID:GunioRobot,项目名称:Pseudo-Server,代码行数:14,代码来源:pseudo-server.py

示例13: __init__

 def __init__(self, config):
     self.agentConfig = config
     self.emitterThreads = []
     for emitter_spec in [s.strip() for s in self.agentConfig.get("custom_emitters", "").split(",")]:
         if len(emitter_spec) == 0:
             continue
         logging.info("Setting up custom emitter %r", emitter_spec)
         try:
             thread = EmitterThread(
                 name=emitter_spec, emitter=modules.load(emitter_spec, "emitter"), logger=logging, config=config
             )
             thread.start()
             self.emitterThreads.append(thread)
         except Exception, e:
             logging.error("Unable to start thread for emitter: %r", emitter_spec, exc_info=True)
开发者ID:miketheman,项目名称:dd-agent,代码行数:15,代码来源:ddagent.py

示例14: run

    def run(self, agentConfig=None, run_forever=True):
        """Main loop of the collector"""
        agentLogger = logging.getLogger('agent')
        systemStats = get_system_stats()
        agentLogger.debug('System Properties: ' + str(systemStats))

        if agentConfig is None:
            agentConfig = get_config()

        # Load the checks.d checks
        checksd = load_check_directory(agentConfig)

        # Try to fetch instance Id from EC2 if not hostname has been set
        # in the config file.
        # DEPRECATED
        if agentConfig.get('hostname') is None and agentConfig.get('use_ec2_instance_id'):
            instanceId = EC2.get_instance_id()
            if instanceId is not None:
                agentLogger.info("Running on EC2, instanceId: %s" % instanceId)
                agentConfig['hostname'] = instanceId
            else:
                agentLogger.info('Not running on EC2, using hostname to identify this server')

        emitters = [http_emitter]
        for emitter_spec in [s.strip() for s in agentConfig.get('custom_emitters', '').split(',')]:
            if len(emitter_spec) == 0: continue
            emitters.append(modules.load(emitter_spec, 'emitter'))

        check_freq = int(agentConfig['check_freq'])

        # Checks instance
        c = checks(agentConfig, emitters)

        # Watchdog
        watchdog = None
        if agentConfig.get("watchdog", True):
            watchdog = Watchdog(check_freq * WATCHDOG_MULTIPLIER)
            watchdog.reset()

        # Run checks once, to get once-in-a-run data
        c.doChecks(True, systemStats, checksd)

        # Main loop
        while run_forever:
            if watchdog is not None:
                watchdog.reset()
            time.sleep(check_freq)
            c.doChecks(checksd=checksd)
开发者ID:DevOpsDave,项目名称:dd-agent,代码行数:48,代码来源:agent.py

示例15: __init__

 def __init__(self, config):
     self.agentConfig = config
     self.emitterThreads = []
     for emitter_spec in [s.strip() for s in self.agentConfig.get('custom_emitters', '').split(',')]:
         if len(emitter_spec) == 0:
             continue
         logging.info('Setting up custom emitter %r', emitter_spec)
         try:
             thread = EmitterThread(
                 name=emitter_spec,
                 emitter=modules.load(emitter_spec, 'emitter'),
                 logger=logging,
                 config=config,
             )
             thread.start()
             self.emitterThreads.append(thread)
         except Exception:
             logging.error('Unable to start thread for emitter: %r', emitter_spec, exc_info=True)
     logging.info('Done with custom emitters')
开发者ID:DavidXArnold,项目名称:dd-agent,代码行数:19,代码来源:ddagent.py


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