-
Notifications
You must be signed in to change notification settings - Fork 21
/
ce
50 lines (39 loc) · 1.22 KB
/
ce
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
"""
About: ComNetsEmu CLI utility
"""
import argparse
import sys
from mininet.log import LEVELS, debug, error, info, lg
from comnetsemu.clean import cleanup
def run():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbosity", choices=LEVELS.keys(), default="info")
parser.add_argument("-c", "--clean", action="store_true", help="Run cleanups")
args = parser.parse_args()
lg.setLogLevel(args.verbosity)
if args.clean:
cleanup()
# TODO: <05-08-19, Zuo> Add helpers to setup Userspace network framework like DPDK #
if __name__ == "__main__":
try:
run()
except KeyboardInterrupt:
info("\n\nKeyboard Interrupt. Shutting down and cleaning up...\n\n")
cleanup()
except Exception:
# Print exception
type_, val_, trace_ = sys.exc_info()
errorMsg = (
"-" * 80
+ "\n"
+ "Caught exception. Cleaning up...\n\n"
+ "%s: %s\n" % (type_.__name__, val_)
+ "-" * 80
+ "\n"
)
error(errorMsg)
# Print stack trace to debug log
import traceback
stackTrace = traceback.format_exc()
debug(stackTrace + "\n")