60 lines
1.6 KiB
Python
Executable File
60 lines
1.6 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import csv
|
|
import json
|
|
|
|
skip_list = [
|
|
'D:\Tank\Home',
|
|
'D:\Tank\Shares\hr',
|
|
'D:\Tank\Shares\payroll',
|
|
'D:\Tank\Shares\cis'
|
|
]
|
|
share_names = {
|
|
'D:\Tank\Shares\\acad': ['acad', 'V:\\'],
|
|
'D:\Tank\Shares\common': ['common', 'X:\\'],
|
|
'D:\Tank\Shares\commercial': ['commercial', 'N:\\'],
|
|
'D:\Tank\Shares\scans': ['scans', 'J:\\'],
|
|
'D:\Tank\Shares\costing': ['costing', 'K:\\'],
|
|
'D:\Tank\Shares\marketing': ['marketing', 'M:\\'],
|
|
'D:\Tank\Shares\\almar': ['almar', 'O:\\'],
|
|
'D:\Tank\Shares\production': ['production', 'P:\\'],
|
|
'D:\Tank\Shares\\recreation': ['recreation', 'R:\\'],
|
|
'D:\Tank\Shares\photos': ['photos', 'U:\\'],
|
|
}
|
|
|
|
f = open("/tmp/dhcp.csv")
|
|
csv_f = csv.reader(f)
|
|
x = csv_f.next()
|
|
dhcp_list = {}
|
|
|
|
for row in csv_f:
|
|
dhcp_list[row[0]] = row[8][:-20].upper()
|
|
|
|
f = open('/tmp/files.csv')
|
|
csv_f = csv.reader(f)
|
|
x = csv_f.next()
|
|
file_list = []
|
|
|
|
for row in csv_f:
|
|
item = {}
|
|
if any(share in row[8] for share in skip_list):
|
|
continue
|
|
if row[8][-1:] == '\\':
|
|
continue
|
|
item['user'] = row[2][11:].lower()
|
|
item['computer'] = dhcp_list.get(row[1], 'Unknown')
|
|
if len(row[12]) > 0:
|
|
item['share'] = share_names[row[8][:len(row[8]) - len(row[12]) - 1]][0]
|
|
item['file'] = (share_names[row[8][:len(row[8]) -
|
|
len(row[12]) - 1]][1] +
|
|
row[12])
|
|
else:
|
|
item['share'] = share_names[row[8]][0]
|
|
item['file'] = share_names[row[8]][1]
|
|
file_list.append(item)
|
|
|
|
result = {'count': len(file_list), 'data': file_list}
|
|
|
|
with open('/var/www/openfiles/files.json', 'w') as f:
|
|
json.dump(result, f)
|