BmnRoot
Loading...
Searching...
No Matches
stats.py
Go to the documentation of this file.
1import sys
2if sys.version_info[0] < 3:
3 print("Must be using Python 3, exiting!")
4 sys.exit(1)
5
6import argparse
7import json
8import warnings
9import os
10
11from file_size.file_size import SizeStatComputer
12from log_time.log_time import TimeStatComputer
13from utils import plot_all_stats
14
15def main():
16 print("Statistics calculation script started.")
17 parser = argparse.ArgumentParser(
18 description='Script for file size and time statistics.\
19 For more info see README.md file'
20 )
21 parser.add_argument(
22 '--dir', '-d',
23 nargs=1,
24 type=str,
25 help='Name of directory to explore',
26 required=True
27 )
28 parser.add_argument(
29 '--size', '-s',
30 action='store_true',
31 help='Compute file size statistics'
32 )
33 parser.add_argument(
34 '--time', '-t',
35 action='store_true',
36 help='Compute time statistics'
37 )
38 parser.add_argument(
39 '--recursive', '-r',
40 action='store_true',
41 help='Recursive data search'
42 )
43 parser.add_argument(
44 '--config', '-c',
45 nargs=1,
46 type=str,
47 help='Path to JSON config file',
48 required=True
49 )
50 parser.add_argument(
51 '--output', '-o',
52 nargs='?',
53 type=str,
54 help='Path to output file, default is ./output.png',
55 default='./output.png'
56 )
57
58 args = parser.parse_args()
59
60 _dir, size, time, config, output, recursive = \
61 args.dir[0], args.size, args.time, args.config[0], args.output, args.recursive
62
63 if not os.path.isdir(_dir):
64 print("Error: Directory {} not found!".format(_dir))
65 sys.exit(1)
66
67 if not os.path.isfile(config):
68 print("Error: Config file {} not found!".format(config))
69 sys.exit(1)
70
71 config_dict = json.load(open(config, 'r'))
72
73 plot_all_stats(size, time, config_dict, _dir, output, recursive)
74
75 print("Script execution finished.")
76
77
78if __name__ == '__main__':
79 main()
main()
Definition stats.py:15