Пример #1
0
def main():
    '''Parse command-line arguments and start up the simulation'''
    parser = OptionParser()
    parser.prog = "fs.py"
    parser.add_option("-f", "--logfile", dest="logfile", 
                      default="", help="Send log to file (default: log to stderr)")
    parser.add_option("-d", "--debug", dest="debug", 
                      default=0, action="count", 
                      help="Turn on debugging output (may be given multiple times to increase debug output)")
    parser.add_option("-t", "--simtime", dest="simtime", 
                      default=300, type=int,
                      help="Set amount of simulation time (default: 300 sec)")
    parser.add_option("-i", "--interval", dest="interval", 
                      default=1.0, type=float,
                      help="Set the simulation tick interval (sec) (default: 1 sec)")
    parser.add_option("-c", "--configonly", dest="configonly",
                      default=False, action="store_true",
                      help="Just do configuration then exit")
    parser.add_option("-s", "--seed", dest="seed",
                      default=None, type="int",
                      help="Set random number generation seed (default: seed based on system time)")
    (options, args) = parser.parse_args()

    if len(args) != 1:
        print >> sys.stderr,"Usage: %s [options] <scenario.[dot,json]>" % (sys.argv[0])
        sys.exit(0)

    random.seed(options.seed)
    fscommon.setup_logger(options.logfile, options.debug)

    sim = FsCore(options.interval, endtime=options.simtime, debug=options.debug)
    signal.signal(signal.SIGINT, sim.sighandler)
    sys.path.append(".")
    sim.run(args[0], configonly=options.configonly)
Пример #2
0
 def setUpClass(cls):
     '''Set up logging; turn on debug messages'''
     fscommon.setup_logger(None, True)
Пример #3
0
def main():
    '''Parse command-line arguments and start up the simulation'''
    parser = OptionParser()
    parser.prog = "fs.py"
    parser.add_option("-f",
                      "--logfile",
                      dest="logfile",
                      default="",
                      help="Send log to file (default: log to stderr)")
    parser.add_option(
        "-d",
        "--debug",
        dest="debug",
        default=0,
        action="count",
        help=
        "Turn on debugging output (may be given multiple times to increase debug output)"
    )
    parser.add_option("-t",
                      "--simtime",
                      dest="simtime",
                      default=300,
                      type=int,
                      help="Set amount of simulation time (default: 300 sec)")
    parser.add_option(
        "-i",
        "--interval",
        dest="interval",
        default=1.0,
        type=float,
        help="Set the simulation tick interval (sec) (default: 1 sec)")
    parser.add_option("-c",
                      "--configonly",
                      dest="configonly",
                      default=False,
                      action="store_true",
                      help="Just do configuration then exit")
    parser.add_option(
        "-s",
        "--seed",
        dest="seed",
        default=None,
        type="int",
        help=
        "Set random number generation seed (default: seed based on system time)"
    )
    (options, args) = parser.parse_args()

    if len(args) != 1:
        print >> sys.stderr, "Usage: %s [options] <scenario.[dot,json]>" % (
            sys.argv[0])
        sys.exit(0)

    random.seed(options.seed)
    fscommon.setup_logger(options.logfile, options.debug)

    sim = FsCore(options.interval,
                 endtime=options.simtime,
                 debug=options.debug)
    signal.signal(signal.SIGINT, sim.sighandler)
    sys.path.append(".")
    sim.run(args[0], configonly=options.configonly)
Пример #4
0
 def setUpClass(cls):
     '''Set up logging; turn on debug messages'''
     fscommon.setup_logger(None, True)