-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (28 loc) · 1.05 KB
/
main.py
File metadata and controls
32 lines (28 loc) · 1.05 KB
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
31
32
import argparse
from executors import HumanExecutor, InodeExecutor, BaseExecutor
def main():
'''Command line utility which execute and parse df command'''
parser = argparse.ArgumentParser()
parser.add_argument("--human", action='store_true',
help="Display filesystems statistics\
in human-readable format")
parser.add_argument("--inode", action='store_true',
help="Getting information about inode's\
in a filesystems")
try:
args = parser.parse_args()
if args.human:
result = HumanExecutor().execute()
elif args.inode:
result = InodeExecutor().execute()
else:
result = BaseExecutor().execute()
except Exception as error:
result = BaseExecutor().result(None, str(error), 1)
finally:
if result:
print(result)
with open("result.json", "w") as f:
f.write(result)
if __name__ == "__main__":
main()