3 from __future__
import print_function
4 from builtins
import range
6 from operator
import itemgetter
18 for (path, dirs, files)
in os.walk(dirIn):
20 if 'CVS' in path:
continue
21 if '.glimpse_' in path:
continue
22 if 'Configuration/PyReleaseValidation/data/run/' in path:
continue
25 if '.glimpse_index' in file:
continue
26 fileName = os.path.join(path, file)
27 fileSize = os.path.getsize(fileName)
32 if os.path.isfile(fileName):
38 jsonFile = open(jsonFileName,
'w')
41 print(
'treeInfo info written to ', jsonFileName)
42 except Exception
as e:
43 print(
"error writing json file:",
str(e))
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))
58 topDirs = sorted(self.
dirSizes.
items() , key=itemgetter(1), reverse=
True)
59 topFiles = sorted(self.
fileSizes.
items(), key=itemgetter(1), reverse=
True)
66 print(
"found ",len(emptyFiles),
"empty files. ")
68 print(
"found ", len(self.
dirSizes),
'directories, top 10 are:')
82 opts, args = getopt.getopt(sys.argv[1:],
"c:o:", [
'checkDir=',
'outFile='])
86 for opt, arg
in opts :
88 if opt
in (
'-c',
"--checkDir", ):
91 if opt
in (
'-o',
"--outFile", ):
95 ta.analyzePath(checkDir)
98 except getopt.GetoptError
as e:
102 if __name__ ==
'__main__':