CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
storeTreeInfo.TreeAnalyzer Class Reference
Inheritance diagram for storeTreeInfo.TreeAnalyzer:

Public Member Functions

def __init__ (self, outFileName)
 
def analyzePath (self, dirIn)
 
def show (self)
 

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.

8  def __init__(self, outFileName):
9  self.dirSizes = {}
10  self.fileSizes = {}
11  self.outFileName = outFileName
12  print "going to write to:",self.outFileName
13 
def __init__(self, outFileName)
Definition: storeTreeInfo.py:8

Member Function Documentation

def storeTreeInfo.TreeAnalyzer.analyzePath (   self,
  dirIn 
)

Definition at line 14 of file storeTreeInfo.py.

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, storeTreeInfo.TreeAnalyzer.outFileName, and harvestTrackValidationPlots.str.

14  def analyzePath(self, dirIn) :
15 
16  for (path, dirs, files) in os.walk(dirIn):
17 
18  if 'CVS' in path: continue
19  if '.glimpse_' in path: continue
20  if 'Configuration/PyReleaseValidation/data/run/' in path: continue
21 
22  for file in files:
23  if '.glimpse_index' in file: continue
24  fileName = os.path.join(path, file)
25  fileSize = os.path.getsize(fileName)
26  if path in self.dirSizes.keys() :
27  self.dirSizes[path] += fileSize
28  else:
29  self.dirSizes[path] = fileSize
30  if os.path.isfile(fileName):
31  self.fileSizes[fileName] = fileSize
32 
33  try:
34  import json
35  jsonFileName = self.outFileName
36  jsonFile = open(jsonFileName, 'w')
37  json.dump([os.path.abspath(dirIn), self.dirSizes, self.fileSizes], jsonFile)
38  jsonFile.close()
39  print 'treeInfo info written to ', jsonFileName
40  except Exception as e:
41  print "error writing json file:", str(e)
42 
43  try:
44  import pickle
45  pklFileName = self.outFileName.replace('.json','.pkl')
46  pickle.dump([os.path.abspath(dirIn), self.dirSizes, self.fileSizes], open(pklFileName, 'w') )
47  print 'treeInfo info written to ', pklFileName
48  except Exception as e:
49  print "error writing pkl file:", str(e)
50 
def analyzePath(self, dirIn)
def storeTreeInfo.TreeAnalyzer.show (   self)

Definition at line 51 of file storeTreeInfo.py.

Referenced by Vispa.Main.AboutDialog.AboutDialog.onScreen(), Vispa.Gui.BoxContentDialog.BoxContentDialog.onScreen(), and Vispa.Gui.FindDialog.FindDialog.onScreen().

51  def show(self):
52 
53  # for p,s in self.dirSizes.items():
54  # print p, s
55 
56  topDirs = sorted(self.dirSizes.items() , key=itemgetter(1), reverse=True)
57  topFiles = sorted(self.fileSizes.items(), key=itemgetter(1), reverse=True)
58 
59  emptyFiles = []
60  for pair in topFiles:
61  p, s = pair
62  if s == 0:
63  emptyFiles.append(p)
64  print "found ",len(emptyFiles),"empty files. "
65 
66  print "found ", len(self.dirSizes.keys()), 'directories, top 10 are:'
67  for i in range(10):
68  print topDirs[i]
69 
70  print "found ", len(self.fileSizes.keys()), 'files, top 10 are:'
71  for i in range(10):
72  print topFiles[i]
73 
74 

Member Data Documentation

storeTreeInfo.TreeAnalyzer.dirSizes

Definition at line 9 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().

storeTreeInfo.TreeAnalyzer.fileSizes

Definition at line 10 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().

storeTreeInfo.TreeAnalyzer.outFileName

Definition at line 11 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().