ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Gather_ImgDir_Sizes_OLD.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 2891 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 """
2    
3     UPDATE: This is the original program that did the gathering en mass. Now that we've gathered all
4     of the sizes of the old and existing database, we now want a program that will just give a total
5     of what X CLM is on the dis and only from dis18, dis19 and dis20.
6    
7     Gather_ImgDir_Sizes
8    
9     This program will be the second part of a system that gathers the dir sizes of the image clm folder.
10     It requires a text file of all possible C_D dirs and a text file of the client matters that you want it
11     to find.
12    
13     """
14    
15     import os, directorySize2
16    
17    
18    
19    
20     if __name__ == '__main__':
21     mattersToProcessList = open(r"\\lisdisdss01\ercdis12\Admin\Share\Manny\APP\3rdPhase\ProcessME.txt").readlines()
22     imgLocationsList = open(r"\\lisdisdss01\ercdis12\Admin\Share\Manny\APP\C_D_MasterList.txt").readlines()
23     outputFile = open(r"\\lisdisdss01\ercdis12\Admin\Share\Manny\APP\3rdPhase\Processed.txt",'w')
24     imageDirCLMDict = {}
25    
26     ## Make the master dictionary of clientmatternumbers = list of dirs
27     print "Creating the master dictionary..."
28     for loc in imgLocationsList:
29     loc = loc.replace("\n","")
30     dirList = os.listdir(loc)
31     for x in dirList:
32     try:
33     if imageDirCLMDict[x]:
34     imageDirCLMDict[x].append(os.path.join(loc, x))
35     except:
36     imageDirCLMDict[x] = [os.path.join(loc, x)]
37     print "Dictionary complete.\n"
38    
39     print "Processing Matter List ...\n\n"
40     for matter in mattersToProcessList:
41     matterExists = True
42     matter = matter.replace("\n","")
43     print "Processing %s..."% matter
44     outputFile.write(matter + "|")
45     try:
46     dataDirs = imageDirCLMDict[matter]
47     except:
48     print "%s does not exist on the image servers!"% matter
49     outputFile.write("Does not exist on image server\n\n")
50     matterExists = False
51     if matterExists:
52     numberOfDataDirs = len(dataDirs)
53     outputFile.write("There are %d data directories for this matter.\n"% numberOfDataDirs)
54     sizes = []
55     for dataSite in dataDirs:
56     print "parsing %s..."% dataSite
57     outputFile.write(matter + "|"+dataSite + "|" )
58     try:
59     dataDirSize = directorySize2.get_dir_size(dataSite)
60     outputFile.write(dataDirSize + "\n")
61     sizes.append(dataDirSize)
62     except:
63     outputFile.write("<ERROR!!>\n")
64     print matter + " was zero.\n"
65     print matter + " is:"
66     print sizes
67     print "\n"
68     #outputFile.write("|")
69     #for s in sizes:
70     # outputFile.writelines(s+",")
71     outputFile.write("\n\n\n")
72    
73     outputFile.close()
74    
75