-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim.py
More file actions
65 lines (54 loc) · 1.69 KB
/
Copy pathsim.py
File metadata and controls
65 lines (54 loc) · 1.69 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# @file sim.py
# @brief statup and AP mode selection
# MODULE_ARCH:
# CLASS_ARCH:
# GLOBAL USAGE:
#standard
import getopt
import sys
import unittest
#extend
from configobj import ConfigObj
import simpy
#library
import lib.globalclasses as gc
from lib.const import *
import codes.app as app
import codes.model as md
import codes.cli as cli
import codes.ut as ut
import codes.ui as ui
#Spec: program init, mode selection, start
#How/NeedToKnow:
if __name__ =='__main__':
# Read system parameters which are assigned while we launching "start.py".
# If the input parameter is invalid, then display usage and return "command
# line syntax" error code.
apmode = AP_MODE_NORMAL
#command line paramters handler
try:
opts, args = getopt.getopt(sys.argv[1:], "ht", [])
for opt, arg in opts:
if opt == '-h':
print ('sim.py [ -h ] [ -t ]')
print (' -h, --help: help message')
print (' -t, --test: unit test mode')
sys.exit()
elif opt in ("-t", "--test"):
apmode = AP_MODE_UNITTEST
print("Running as unittest mode!")
except getopt.GetoptError:
print ('usage: sim.py [ -h ] [ -t ]')
sys.exit(2)
#init global classes
gc.SETTING = ConfigObj("include/sim.ini")
gc.UI = ui.UserInterface()
gc.VIRUS = md.VirusModel()
gc.GAP = app.SApp()
gc.CLI = cli.Cli()
#run by different mode
if apmode == AP_MODE_UNITTEST:
suite = unittest.TestLoader().loadTestsFromTestCase(ut.UTGeneral)
unittest.TextTestRunner(verbosity = 2).run(suite)
else:
gc.CLI.cmdloop()