CMS 3D CMS Logo

Public Member Functions | Public Attributes

storeTreeInfo::TreeAnalyzer Class Reference

List of all members.

Public Member Functions

def __init__
def analyzePath
def show

Public Attributes

 dirSizes
 fileSizes
 outFileName

Detailed Description

Definition at line 6 of file storeTreeInfo.py.


Constructor & Destructor Documentation

def storeTreeInfo::TreeAnalyzer::__init__ (   self,
  outFileName 
)

Definition at line 8 of file storeTreeInfo.py.

00009                                    :
00010         self.dirSizes  = {}
00011         self.fileSizes = {}
00012         self.outFileName = outFileName
00013         print "going to write to:",self.outFileName
        

Member Function Documentation

void HLTMuonValidator::analyzePath (   self,
  dirIn 
)

Definition at line 14 of file storeTreeInfo.py.

00015                                  :
00016 
00017         for (path, dirs, files) in os.walk(dirIn):
00018 
00019             if 'CVS' in path: continue
00020             if '.glimpse_' in path: continue
00021             if 'Configuration/PyReleaseValidation/data/run/' in path: continue
00022             
00023             for file in files:
00024                 if '.glimpse_index' in file: continue
00025                 fileName = os.path.join(path, file)
00026                 fileSize = os.path.getsize(fileName)
00027                 if path in self.dirSizes.keys() :
00028                     self.dirSizes[path] += fileSize
00029                 else:
00030                     self.dirSizes[path] =  fileSize
00031                 if os.path.isfile(fileName):
00032                     self.fileSizes[fileName] = fileSize
00033 
00034         try:
00035             import json
00036             jsonFileName = self.outFileName
00037             jsonFile = open(jsonFileName, 'w')
00038             json.dump([os.path.abspath(dirIn), self.dirSizes, self.fileSizes], jsonFile)
00039             jsonFile.close()
00040             print 'treeInfo info  written to ', jsonFileName
00041         except Exception, e:
00042             print "error writing json file:", str(e)
00043 
00044         try:
00045             import pickle
00046             pklFileName = self.outFileName.replace('.json','.pkl')
00047             pickle.dump([os.path.abspath(dirIn), self.dirSizes, self.fileSizes], open(pklFileName, 'w') )
00048             print 'treeInfo info  written to ', pklFileName
00049         except Exception, e:
00050             print "error writing pkl file:", str(e)
        
def storeTreeInfo::TreeAnalyzer::show (   self)

Definition at line 51 of file storeTreeInfo.py.

00052                   :
00053 
00054         # for p,s in self.dirSizes.items():
00055         #     print p, s
00056 
00057         topDirs  = sorted(self.dirSizes.items() , key=itemgetter(1), reverse=True)
00058         topFiles = sorted(self.fileSizes.items(), key=itemgetter(1), reverse=True)
00059 
00060         emptyFiles = []
00061         for pair in topFiles:
00062             p, s = pair
00063             if s == 0:
00064                 emptyFiles.append(p)
00065         print "found ",len(emptyFiles),"empty files. "
00066 
00067         print "found ", len(self.dirSizes.keys()), 'directories, top 10 are:'
00068         for i in range(10):
00069             print topDirs[i]
00070 
00071         print "found ", len(self.fileSizes.keys()), 'files, top 10 are:'
00072         for i in range(10):
00073             print topFiles[i]
00074 


Member Data Documentation

Definition at line 8 of file storeTreeInfo.py.

Definition at line 8 of file storeTreeInfo.py.

Definition at line 8 of file storeTreeInfo.py.