CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
storeTreeInfo.TreeAnalyzer Class Reference
Inheritance diagram for storeTreeInfo.TreeAnalyzer:

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.

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

Member Function Documentation

def storeTreeInfo.TreeAnalyzer.analyzePath (   self,
  dirIn 
)

Definition at line 14 of file storeTreeInfo.py.

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

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

Definition at line 51 of file storeTreeInfo.py.

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

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