| 1 |
ninoborges |
8 |
## This program will take a list of user names & based on this, list will
|
| 2 |
|
|
##connect to the repository SQL database and get the U drive info. With this
|
| 3 |
|
|
## info it will then connect to everyones U: and examin the size of the users
|
| 4 |
|
|
## personal.mdb file.
|
| 5 |
|
|
#EBorges
|
| 6 |
|
|
#02.26.02
|
| 7 |
|
|
|
| 8 |
|
|
import dbi
|
| 9 |
|
|
import odbc
|
| 10 |
|
|
import os, string
|
| 11 |
|
|
|
| 12 |
|
|
def Connect_to_db():
|
| 13 |
|
|
myconn = odbc.odbc('MW_repository')
|
| 14 |
|
|
mycursor = myconn.cursor()
|
| 15 |
|
|
mycursor.execute('SELECT NetLogin, NetUDrivePath FROM Employees')
|
| 16 |
|
|
mydata = mycursor.fetchall()
|
| 17 |
|
|
mycursor.close()
|
| 18 |
|
|
myconn.close()
|
| 19 |
|
|
return mydata
|
| 20 |
|
|
def Main():
|
| 21 |
|
|
new_file = ""
|
| 22 |
|
|
sql_data = Connect_to_db()
|
| 23 |
|
|
f=open('C:\\personal_mdb_all_new.log','r')
|
| 24 |
|
|
contents = f.readlines()
|
| 25 |
|
|
f.close()
|
| 26 |
|
|
o=open('C:\\Formatted_results.txt','w')
|
| 27 |
|
|
for x in contents:
|
| 28 |
|
|
username = string.split(x)
|
| 29 |
|
|
username = username [1]
|
| 30 |
|
|
username = string.lower(username)
|
| 31 |
|
|
for y in sql_data:
|
| 32 |
|
|
if username == y[0]:
|
| 33 |
|
|
second = str(y[1])
|
| 34 |
|
|
#new_file = y[0]+ "," + y[1] + "\n"
|
| 35 |
|
|
new_file = y[0]+ "," + second + "\n"
|
| 36 |
|
|
o.write(new_file)
|
| 37 |
|
|
break
|
| 38 |
|
|
o.close()
|
| 39 |
|
|
|
| 40 |
|
|
def Main_two():
|
| 41 |
|
|
f=open('c:\\Formatted_results.txt','r')
|
| 42 |
|
|
contents = f.readlines()
|
| 43 |
|
|
f.close()
|
| 44 |
|
|
o=open('c:\\Formatted_results2.txt','w')
|
| 45 |
|
|
print contents [1]
|
| 46 |
|
|
for x in contents:
|
| 47 |
|
|
start = string.find(x,"\\")
|
| 48 |
|
|
end = string.find(x,"\n")
|
| 49 |
|
|
path = x [start:end]
|
| 50 |
|
|
#path = string.replace(path, '\\','\\\\')
|
| 51 |
|
|
#path = path[1:]
|
| 52 |
|
|
path = path + "\\wfw\\personal.mdb"
|
| 53 |
|
|
print path
|
| 54 |
|
|
try:
|
| 55 |
|
|
size = os.path.getsize(path)
|
| 56 |
|
|
except OSError:
|
| 57 |
|
|
size = 0
|
| 58 |
|
|
size = str(size)
|
| 59 |
|
|
print size
|
| 60 |
|
|
end_two = string.find(x,"\n")
|
| 61 |
|
|
line = x[:end_two] + "," + size + "\n"
|
| 62 |
|
|
o.write(line)
|
| 63 |
|
|
o.close()
|
| 64 |
|
|
if __name__ == '__main__':
|
| 65 |
|
|
#Main()
|
| 66 |
|
|
Main_two() |