-
Notifications
You must be signed in to change notification settings - Fork 12
/
config.py
54 lines (43 loc) · 1.45 KB
/
config.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
47
48
49
50
51
52
53
54
from __future__ import print_function
import os
import sys
import logging
if sys.version_info[0] < 3:
import ConfigParser as configparser
else:
import configparser
config = configparser.SafeConfigParser()
get = config.get
config_dir = os.path.dirname(__file__)
def parser_config():
config_file = os.path.join(config_dir, "conf")
if not os.path.exists(config_file):
sys.stderr.write("Error: Unable to find the config file!\n")
sys.exit(1)
# parse the configuration
global config
config.readfp(open(config_file))
parser_config()
COMP = {
"Permission": "permission",
"Activity": "activity",
"Service": "service",
"Receiver": "receiver",
"Provider": "provider",
"Hardware": "hardware",
"Intentfilter": 'intent-filter',
"Android_API": "android_api",
"Java_API": "java_api",
"User_String": "const-string",
"User_Class": "user_class",
"User_Method": "user_method",
"OpCode": "opcode",
"Asset": "asset",
"Notdefined": 'not_defined'
}
logging.basicConfig(level=logging.INFO, filename=os.path.join(config_dir, "log"), filemode="w",
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s: %(message)s',
datefmt='%Y/%m/%d %H:%M:%S')
ErrorHandler = logging.StreamHandler()
ErrorHandler.setLevel(logging.WARNING)
ErrorHandler.setFormatter(logging.Formatter('%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s: %(message)s'))