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

◆ __init__()

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 

Member Function Documentation

◆ analyzePath()

def storeTreeInfo.TreeAnalyzer.analyzePath (   self,
  dirIn 
)

Definition at line 16 of file storeTreeInfo.py.

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 

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, relativeConstraints.keys, storeTreeInfo.TreeAnalyzer.outFileName, print(), python.rootplot.root2matplotlib.replace(), and str.

◆ show()

def storeTreeInfo.TreeAnalyzer.show (   self)

Definition at line 53 of file storeTreeInfo.py.

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 

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, mps_monitormerge.items, print(), and FastTimerService_cff.range.

Member Data Documentation

◆ dirSizes

storeTreeInfo.TreeAnalyzer.dirSizes

◆ fileSizes

storeTreeInfo.TreeAnalyzer.fileSizes

◆ outFileName

storeTreeInfo.TreeAnalyzer.outFileName

Definition at line 13 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
str
#define str(s)
Definition: TestProcessor.cc:53
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444