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


Python Plugin.run方法代码示例

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


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

示例1: __run_plugin__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import run [as 别名]
 def __run_plugin__ (self, filename, verbose, raw):
   try:
     plugin = Plugin (filename, self.__ossim_config, self.__severity_list, verbose, raw)
   except (PluginError, PluginConfigParserError) as e:
     if verbose > 0:
       print ''
       Output.warning (e.msg)
     else:
       self.__summary.append ({'plugin': e.plugin, 'warning': e.msg})
   except Exception as e:
     print ''
     Output.error ('Unknown error parsing plugin "%s": %s' % (filename, str(e)))
   else:
     if (plugin.get_enable()) and (plugin.get_checks_len() > 0) and (plugin.check_category (self.__category_list)):
       self.__summary.append (plugin.run ())
     else:
       del plugin
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:19,代码来源:doctor.py

示例2: __run_plugin__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import run [as 别名]
    def __run_plugin__(self, filename, verbose, raw):
        # Parse the plugin configuration file.
        # Check if file exists
        if not path.isfile(filename):
            msg = 'Plugin file does not exist: %s' % filename
            self.__generate_blocked_output(config_file=None,
                                           plugin=filename,
                                           plugin_data={},
                                           sections=[],
                                           error_msg=msg)
            return

        # Check for file extension.
        if not filename.endswith('.plg'):
            msg = 'File extension is not .plg'
            self.__generate_blocked_output(config_file=None,
                                           plugin=filename,
                                           plugin_data={},
                                           sections=[],
                                           error_msg=msg)
            return

        # Check for db connections and some other basic param config
        cfg_msg = ''
        for key in self.__successful_config.keys():
            if not self.__successful_config[key]['result']:
                cfg_msg = ';'.join([cfg_msg, self.__successful_config[key]['error']])
        if cfg_msg != '':
            self.__generate_blocked_output(config_file=None,
                                           plugin=filename,
                                           plugin_data={},
                                           sections=[],
                                           error_msg=cfg_msg)

        config_file = None
        try:
            config_file = self.__load_plugin_file(filename)
        except PluginError as e:
            self.__generate_blocked_output(config_file=None,
                                           plugin=e.plugin,
                                           plugin_data={},
                                           sections=[],
                                           error_msg=e.msg)

            return

        # Fill the Plugin Object
        if config_file:
            try:
                plugin = Plugin(filename,
                                config_file,
                                self.__alienvault_config,
                                self.__severity_list,
                                self.__appliance_type_list,
                                self.__ignore_dummy_platform,
                                verbose,
                                raw)

                if (plugin.get_checks_len() > 0) and (plugin.check_category(self.__category_list)):
                    result = plugin.run()
                    self.__in_strike_zone &= result.get('strike_zone', True)
                    self.__summary[plugin.get_name()] = result
                else:
                    del plugin

            except (PluginError, PluginConfigParserError, CheckError) as e:

                if verbose > 0:
                    Output.warning(e.msg)

                sections = []
                try:
                    sections = config_file.sections()
                except Exception:
                    pass

                self.__generate_blocked_output(config_file=config_file,
                                               plugin=e.plugin,
                                               plugin_data=e.kwargs,
                                               sections=sections,
                                               error_msg=e.msg)

            except KeyError, msg:
                Output.error('Unknown error running plugin "%s": %s' % (filename, str(msg)))
开发者ID:jpalanco,项目名称:alienvault-ossim,代码行数:86,代码来源:doctor.py

示例3: main

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import run [as 别名]
def main():
    plugin = Plugin("param.json")
    plugin.initialize()
    plugin.run()
开发者ID:jdgwartney,项目名称:boundary-plugin-shell,代码行数:6,代码来源:index.py

示例4: Credentials

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import run [as 别名]
        )
            

credentials = Credentials(username, password)
model       = Model(config_login, config_repo, config_branch, config_filename, credentials)

cfg         = json.loads(model.config.data)
plugins     = cfg['plugins'].keys()
args        = cfg['plugins'].values()

scheduler = Scheduler()

for name,arg in zip(plugins, args):
    data_filename = os.path.join(model.uuid, name)
    data_file     = Datastore(model.data_repo, data_filename)
    plug_filename = name + ".py"
    plug_file     = Datastore(model.plugin_repo, plug_filename)
    plug = Plugin(plug_file, data_file, name)

    # Scheduled for running according to some interval
    schedule_string = arg.get('schedule', None)
    if schedule_string is not None:
        exec "scheduler.%s.do(plug.run, arg)" % schedule_string

    # Always run immidiately
    plug.run(arg)

while True:
    scheduler.run_pending()
    sleep(1)
开发者ID:simonvpe,项目名称:trj,代码行数:32,代码来源:trj.py


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