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 8 of file storeTreeInfo.py.

Constructor & Destructor Documentation

def storeTreeInfo.TreeAnalyzer.__init__ (   self,
  outFileName 
)

Definition at line 10 of file storeTreeInfo.py.

10  def __init__(self, outFileName):
11  self.dirSizes = {}
12  self.fileSizes = {}
13  self.outFileName = outFileName
14  print("going to write to:",self.outFileName)
15 
def __init__(self, outFileName)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66

Member Function Documentation

def storeTreeInfo.TreeAnalyzer.analyzePath (   self,
  dirIn 
)

Definition at line 16 of file storeTreeInfo.py.

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, storeTreeInfo.TreeAnalyzer.outFileName, edm.print(), and str.

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

Definition at line 53 of file storeTreeInfo.py.

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, and edm.print().

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

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

Member Data Documentation

storeTreeInfo.TreeAnalyzer.dirSizes
storeTreeInfo.TreeAnalyzer.fileSizes
storeTreeInfo.TreeAnalyzer.outFileName

Definition at line 13 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().