-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheckFile.py
60 lines (49 loc) · 1.28 KB
/
checkFile.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
#!/bin/bash python
import os,time
import cPickle as pickle
start = time.time()
fileSeen = 'MACSeen.txt'
fileKnown = 'MACKnown.txt'
newSeen = 'NewMACSeen.txt'
newKnown = {}
name = ""
try:
seen = list(pickle.load(open(fileSeen, "ab+")))
except:
print "New Seen File!"
seen = open(fileSeen, "ab+")
try:
known = pickle.load(open(fileKnown, "ab+"))
except:
print "New Known File!"
known = open(fileKnown, "ab+")
print "Valid names are at least 5 characters, without spaces"
print " "
for item in seen:
print "Do you have a name for this MAC? ", item
name = raw_input('Name>>> ')
if len(name) > 5:
newKnown[item] = name
seen.remove(item)
print known
print "-------------------------------------"
print newKnown
print "The above item(s) are going to be added to the pool of known MAC addresses, ok?"
confirmation = raw_input('Confirm yes, otherwise changes will be discarded> ')
confirmation.lower()
if confirmation == "y":
confirmation = "yes"
if confirmation == "yes":
print type(known)
newKnown = pickle.dumps(newKnown)
try:
known.write(newKnown)
except:
known = pickle.dumps(newKnown)
else:
print "Changes discarded"
print "-------------------------------------"
#known.close()
finish = time.time()
elapsed = finish - start
print "Report completed in ", elapsed, " seconds."