CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 8 of file storeTreeInfo.py.

Constructor & Destructor Documentation

def storeTreeInfo.TreeAnalyzer.__init__ (   self,
  outFileName 
)

Definition at line 10 of file storeTreeInfo.py.

10 
11  def __init__(self, outFileName):
12  self.dirSizes = {}
13  self.fileSizes = {}
14  self.outFileName = outFileName
15  print("going to write to:",self.outFileName)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

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, print(), and str.

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

Definition at line 53 of file storeTreeInfo.py.

References storeTreeInfo.TreeAnalyzer.dirSizes, storeTreeInfo.TreeAnalyzer.fileSizes, print(), and sistrip::SpyUtilities.range().

53 
54  def show(self):
55 
56  # for p,s in self.dirSizes.items():
57  # print p, s
58 
59  topDirs = sorted(self.dirSizes.items() , key=itemgetter(1), reverse=True)
60  topFiles = sorted(self.fileSizes.items(), key=itemgetter(1), reverse=True)
61 
62  emptyFiles = []
63  for pair in topFiles:
64  p, s = pair
65  if s == 0:
66  emptyFiles.append(p)
67  print("found ",len(emptyFiles),"empty files. ")
68 
69  print("found ", len(self.dirSizes), 'directories, top 10 are:')
70  for i in range(10):
71  print(topDirs[i])
72 
73  print("found ", len(self.fileSizes), 'files, top 10 are:')
74  for i in range(10):
75  print(topFiles[i])
76 
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Data Documentation

storeTreeInfo.TreeAnalyzer.dirSizes

Definition at line 11 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath(), and storeTreeInfo.TreeAnalyzer.show().

storeTreeInfo.TreeAnalyzer.fileSizes

Definition at line 12 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath(), and storeTreeInfo.TreeAnalyzer.show().

storeTreeInfo.TreeAnalyzer.outFileName

Definition at line 13 of file storeTreeInfo.py.

Referenced by storeTreeInfo.TreeAnalyzer.analyzePath().