-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathparser.py
47 lines (41 loc) · 1.31 KB
/
parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Name : parser.py
# Version : 0.1
# Author : Abdesslem Amri
# Date : 15-01-2014
# Owner : Abdesslem Amri
# License : GPLv2
# Description : This script is used to parse configuration value from the configuration file.
#-----------------------------------------------------------------------
__author__ = 'ask3m'
import ConfigParser
def testParse():
Config = ConfigParser.ConfigParser()
Config.read("config.ini")
print Config.sections()
#testParse()
def ConfigSectionMap(section):
Config = ConfigParser.ConfigParser()
Config.read("config.ini")
dict1 = {}
options = Config.options(section)
for option in options:
try:
dict1[option] = Config.get(section, option)
if dict1[option] == -1:
print("skip: %s" % option)
except:
print("exception on %s!" % option)
dict1[option] = None
return dict1
Config = ConfigParser.ConfigParser()
Config.read("config.ini")
SnortDir = ConfigSectionMap("snort")['directory']
NetsimDir = ConfigSectionMap("Inetsim")['directory']
NetsimInter = ConfigSectionMap("Inetsim")['interface']
#NetsimInter = Config.getboolean("Inetsim", "interface")
print SnortDir
print NetsimDir
print NetsimInter