| 1 |
ninoborges |
8 |
## SumOwnerCompiler.py
|
| 2 |
|
|
## This program will get all the possible owners of Summaiton cases, given a directory to start from, and
|
| 3 |
|
|
## compile this into a comma seperated list of cases and possible owners. This is used when we need to clean
|
| 4 |
|
|
## us a bunch of Summation cases and need to contact the responsible person first.
|
| 5 |
|
|
## EBorges
|
| 6 |
|
|
## 10.5.04
|
| 7 |
|
|
|
| 8 |
|
|
import os
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
def GetPossibleOwners(dir):
|
| 12 |
|
|
caseName = "file not found!"
|
| 13 |
|
|
#database = "db not found!"
|
| 14 |
|
|
possiblePeople = []
|
| 15 |
|
|
try:
|
| 16 |
|
|
contents = open(dir + '\\sumcase.txt','r').readlines()
|
| 17 |
|
|
caseName = contents[0].split('NAME')[1].replace('\n','')
|
| 18 |
|
|
database = contents[5].split('\\')[-1].replace('\n','')
|
| 19 |
|
|
#print os.listdir(dir)
|
| 20 |
|
|
if os.path.exists(dir+'\\Database'):
|
| 21 |
|
|
databasePath = dir + '\\Database\\' + database
|
| 22 |
|
|
else:
|
| 23 |
|
|
databasePath = dir
|
| 24 |
|
|
for file in os.listdir(databasePath + '\\' + database + '.sw'):
|
| 25 |
|
|
if file.split('.')[1] == 'INI':
|
| 26 |
|
|
possiblePeople.append(file.split('.')[0])
|
| 27 |
|
|
if os.path.exists(databasePath + '\\Profiles'):
|
| 28 |
|
|
for file2 in os.listdir(databasePath + '\\Profiles'):
|
| 29 |
|
|
possiblePeople.append(file2)
|
| 30 |
|
|
except:
|
| 31 |
|
|
pass
|
| 32 |
|
|
return caseName,possiblePeople
|
| 33 |
|
|
|
| 34 |
|
|
if __name__ == '__main__':
|
| 35 |
|
|
count = 0
|
| 36 |
|
|
topDir = r"\\pit\sw"
|
| 37 |
|
|
workDir = r"c:\test_dir\SumOwnerCompiler"
|
| 38 |
|
|
if os.path.isdir(workDir):
|
| 39 |
|
|
pass
|
| 40 |
|
|
else:
|
| 41 |
|
|
os.mkdir(workDir)
|
| 42 |
|
|
workFile = open(workDir + "\\SumOwnerCompiled.txt",'a')
|
| 43 |
|
|
for dir in os.listdir(topDir):
|
| 44 |
|
|
if os.path.isdir(topDir + '\\' + dir):
|
| 45 |
|
|
#print dir
|
| 46 |
|
|
lines = GetPossibleOwners(topDir + '\\' + dir)
|
| 47 |
|
|
print "-------------------------------------------------------------------------------"
|
| 48 |
|
|
print lines[0]
|
| 49 |
|
|
print '\n'
|
| 50 |
|
|
for name in lines[1]:
|
| 51 |
|
|
print name
|
| 52 |
|
|
workFile.write(name + '|' + lines[0] + '|' + dir + '\n')
|
| 53 |
|
|
workFile.close() |