4 from operator
import itemgetter
16 for (path, dirs, files)
in os.walk(dirIn):
18 if 'CVS' in path:
continue
19 if '.glimpse_' in path:
continue
20 if 'Configuration/PyReleaseValidation/data/run/' in path:
continue
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() :
30 if os.path.isfile(fileName):
36 jsonFile = open(jsonFileName,
'w')
39 print 'treeInfo info written to ', jsonFileName
40 except Exception
as e:
41 print "error writing json file:", str(e)
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)
56 topDirs = sorted(self.dirSizes.items() , key=itemgetter(1), reverse=
True)
57 topFiles = sorted(self.fileSizes.items(), key=itemgetter(1), reverse=
True)
64 print "found ",len(emptyFiles),
"empty files. "
66 print "found ", len(self.dirSizes.keys()),
'directories, top 10 are:'
70 print "found ", len(self.fileSizes.keys()),
'files, top 10 are:'
80 opts, args = getopt.getopt(sys.argv[1:],
"c:o:", [
'checkDir=',
'outFile='])
84 for opt, arg
in opts :
86 if opt
in (
'-c',
"--checkDir", ):
89 if opt
in (
'-o',
"--outFile", ):
93 ta.analyzePath(checkDir)
96 except getopt.GetoptError
as e:
97 print "unknown option", str(e)
100 if __name__ ==
'__main__':