Example #1
0
def has_option(group, field, conf_type='global'):
    raise NotImplementedError(
        'Use config.get_config([config_type]) and .has_option method')
    """Return whether an option is available for that section"""
    conf = ConfigParser.RawConfigParser()
    conf.read(_resolve_conf_name(conf_type))
    return conf.has_option(group, field)
Example #2
0
def clist(group, conf_type='global'):
    raise NotImplementedError(
        'Use config.get_config([config_type]) and .getlist method')
    """List configuration values"""
    conf = ConfigParser.RawConfigParser()
    conf.read(_resolve_conf_name(conf_type))
    return conf.items(group)
Example #3
0
def c(group, field, conf_type='global'):
    raise NotImplementedError(
        'Use config.get_config([config_type]) and .get<type> methods')
    """Get configuration value"""
    conf = ConfigParser.RawConfigParser()
    conf.read(_resolve_conf_name(conf_type))
    return conf.get(group, field)
Example #4
0
def make_wwwc_main_config():
    import ConfigParser

    config = ConfigParser.RawConfigParser()
    # write in reverse order
    config.add_section('userdata')
    user_id = addon.getSetting('user_id')
    if not user_id == '':
        config.set('userdata', 'user_id', user_id)

    config.add_section('main')
    config.set('main', 'resolution', addon.getSetting('resolution'))

    tmp_path = addon.getSetting('tmp_path')
    if not tmp_path:
        import tempfile
        tmp_path = tempfile.mkdtemp()
    config.set('main', 'stream_file', os.path.join(tmp_path, 'stream.fifo'))
    config.set('main', 'tmp_path', tmp_path)
    proxy = addon.getSetting('proxy')
    if not proxy == '':
        config.set('main', 'proxy', proxy)
    config.set(
        'main', 'uagent',
        'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0]'
    )

    configfile = os.path.join(tmp_path, 'wwwc_config.ini')
    try:
        os.remove(configfile)
    except:
        pass
    write_wilmaa_conf(configfile, config)

    return configfile
Example #5
0
def cs(group, field, value, conf_type='global'):
    raise NotImplementedError(
        'Use config.get_config([config_type]) and .setoption method')
    """Set configuration value"""
    conf = ConfigParser.RawConfigParser()
    fnm = _resolve_conf_name(conf_type)
    conf.read(fnm)
    conf.set(group, field, value)
    with open(fnm, 'wb') as configfile:
        conf.write(configfile)
Example #6
0
def getList():
    cfg = ConfigParser.RawConfigParser()
    cfgFile = os.path.join('config', 'list.cfg')
    cfg.read(cfgFile)
    hostList = []
    for sec in cfg.sections():
        hostInfo = {}
        hostInfo['name'] = sec
        for opt in cfg.options(sec):
            hostInfo[opt] = cfg.get(sec, opt)
        hostList.append(hostInfo)
    return hostList
Example #7
0
    def LoadPlugin(self):
        try:
            self.Plugin = ConfigParser.RawConfigParser()
            self.Plugin.read(self.Args.plugin)
        except ConfigParser.MissingSectionHeaderError:
            print self.Args.plugin + " Is not an OSSIM plugin file"
            sys.exit()

        for rule in self.Plugin.sections():
            if rule.lower() not in commonvars.SECTIONS_NOT_RULES:
                self.SIDs[rule] = self.Plugin.get(rule, 'regexp')

        validator = pluginvalidate.PluginValidator(self.Plugin)
        if validator.IsValid() == False: sys.exit()
Example #8
0
def getListDb():

    cfg = ConfigParser.RawConfigParser()
    cfgFile = os.path.join('config', 'config.cfg')
    #         print cfgFile,os.path.isfile(cfgFile)
    cfg.read(cfgFile)
    cj_center = cfg.get('swi_center', 'cj')
    if ',' in cj_center:
        cj_list = []
        for cj in cj_center.split(','):
            cj_list.append(cj)
        str = "','".join(cj_list)
    print str
    query_string = """
    SELECT swi_serial, device_type, 
       create_ip, user_name, pass_word, port, secret, verboses,
       event_log, crc, sfp, throughput
    FROM ref.ref_code_monitor_san_info;
    """

    rdb = fleta_dbms.FletaDb()
    print 'query :', query_string
    rows = rdb.getRaw(query_string)
    swList = []

    for row in rows:
        log_bit = False
        crc_bit = True
        sfp_bit = True
        throughput_bit = True

        log_str = row[8]
        crc_str = row[9]
        sfp_str = row[10]
        thr_str = row[11]
        bitDic = {}
        if log_str == 'O':
            log_bit = True
        else:
            log_bit = False
        if crc_str == 'O':
            crc_bit = True
        else:
            crc_bit = False
        if sfp_str == 'O':
            sfp_bit = True
        else:
            sfp_bit = False
        if thr_str == 'O':
            throughput_bit = True
        else:
            throughput_bit = False


#         print row
        bitDic['log_bit'] = log_bit
        bitDic['crc_bit'] = crc_bit
        bitDic['sfp_bit'] = sfp_bit
        bitDic['throughput_bit'] = throughput_bit
        sw = {}
        sw['name'] = row[0]
        sw['ip'] = row[2]
        sw['username'] = row[3]
        sw['password'] = row[4]
        sw['device_type'] = row[1]
        sw['secret'] = False
        sw['verbose'] = False
        sw['targetList'] = bitDic
        #         print sw

        if sw['ip'] <> None:
            pat = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
            isip = pat.match(sw['ip'])
            if isip:
                swList.append(sw)

    return swList