-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.py
61 lines (44 loc) · 1.57 KB
/
helper.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
55
56
57
58
59
60
61
import subprocess
from user import user
class helper():
def make_iplist(self,rawlist):
u = user()
count = 0
output = []
number = len(rawlist["address_detail"])
for _ in range(number):
detail = str(rawlist["address_detail"][count][1]).split('|')
if len(detail) == 2:
username = detail[0]
date = detail[1]
status = "Ok"
# check if username exists already
username_exists = int(u.check_user(username))
if not username_exists == 1:
status = "Orphaned"
else:
username = detail[0]
date = None
status = "Manually Created"
ip = str(rawlist["address_ip"][count][1])
output.append({"username": username, "ip": ip, "status": status, "datetime": date})
count += 1
return output
def make_iplistonly(self,rawlist):
u = user()
count = 0
output = {}
number = len(rawlist["address_detail"])
for _ in range(number):
detail = str(rawlist["address_detail"][count][1]).split('|')
if len(detail) == 2:
username = detail[0]
else:
username = detail[0]
ip = str(rawlist["address_ip"][count][1])
if username in output:
output[str(username)] = output[str(username)] + [ip]
else:
output[str(username)] = [ip]
count += 1
return output