forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckDirSizes.py
More file actions
executable file
·30 lines (24 loc) · 848 Bytes
/
checkDirSizes.py
File metadata and controls
executable file
·30 lines (24 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
from __future__ import print_function
import sys
from pickle import Pickler
from _py2with3compatibility import run_cmd
def doDu(what):
error, out = run_cmd('du -k -s %s' % what)
if error:
print("Error while getting directory size.")
sys.exit(1)
results = [l.split() for l in out.split("\n")]
return dict([(pkg.strip().replace("src/", ''), int(sz.strip() * 1024))
for (sz, pkg) in results])
if __name__ == '__main__':
try:
f = open('dirSizeInfo.pkl', 'wb')
pklr = Pickler(f, protocol=2)
pklr.dump(doDu("src lib bin"))
pklr.dump(doDu("src/*/*"))
f.close()
except Exception as e:
print("ERROR during pickling results for dir size:", str(e))
sys.exit(1)
print("Successfully pickled results for dir size !")