-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.py
31 lines (26 loc) · 914 Bytes
/
utils.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
import configparser
import os.path
armadillo_dir_path = os.path.join(os.path.expanduser("~"), ".armadillo")
policy_file_path = armadillo_dir_path + "/policy.ini"
dns_policy_path = armadillo_dir_path + "/dns.ini"
dpi_policy_path = armadillo_dir_path + "/dpi.ini"
armadillo_pids_path = armadillo_dir_path + "/armadillo.pid"
parsed_policy = armadillo_dir_path + "/parsed_policy.csv"
parsed_dns = armadillo_dir_path + "/parsed_dns.csv"
parsed_dpi = armadillo_dir_path + "/parsed_dpi.csv"
# Return config parser from file
def get_config(file_path):
config = configparser.ConfigParser()
config.read(file_path)
return config
# Save to file
def save_to_file(config,
file_path):
with open(file_path, 'w') as configfile:
config.write(configfile)
# Parsing file
def parse_file(rows,
file_path):
file = open(file_path, "w")
file.write(rows)
file.close()