def parse_arguments(argv):
    """
    Parse command line arguments and override local configuration

    :params args: Array of command line arguments
    """

    parser = argparse.ArgumentParser(description="GNS3 server version {}".format(__version__))
    parser.add_argument("-v", "--version", help="show the version", action="version", version=__version__)
    parser.add_argument("--host", help="run on the given host/IP address")
    parser.add_argument("--port", help="run on the given port", type=int)
    parser.add_argument("--ssl", action="store_true", help="run in SSL mode")
    parser.add_argument("--no-ubridge", action="store_false", help="do not use ubridge to handle node connections")
    parser.add_argument("--config", help="Configuration file")
    parser.add_argument("--certfile", help="SSL cert file")
    parser.add_argument("--certkey", help="SSL key file")
    parser.add_argument("--record", help="save curl requests into a file (for developers)")
    parser.add_argument("-L", "--local", action="store_true", help="local mode (allows some insecure operations)")
    parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports")
    parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout")
    parser.add_argument("-d", "--debug", action="store_true", help="show debug logs")
    parser.add_argument("--shell", action="store_true", help="start a shell inside the server (debugging purpose only you need to install ptpython before)")
    parser.add_argument("--log", help="send output to logfile instead of console")
    parser.add_argument("--daemon", action="store_true", help="start as a daemon")
    parser.add_argument("--pid", help="store process pid")
    parser.add_argument("--profile", help="Settings profile (blank will use default settings files)")

    args = parser.parse_args(argv)
    if args.config:
        Config.instance(files=[args.config], profile=args.profile)
    else:
        Config.instance(profile=args.profile)

    config = Config.instance().get_section_config("Server")
    defaults = {
        "host": config.get("host", "0.0.0.0"),
        "port": config.get("port", 3080),
        "ssl": config.getboolean("ssl", False),
        "certfile": config.get("certfile", ""),
        "certkey": config.get("certkey", ""),
        "record": config.get("record", ""),
        "local": config.getboolean("local", False),
        "allow": config.getboolean("allow_remote_console", False),
        "quiet": config.getboolean("quiet", False),
        "debug": config.getboolean("debug", False),
        "logfile": config.getboolean("logfile", "")
    }

    parser.set_defaults(**defaults)
    return parser.parse_args(argv)
def parse_arguments ( argv ) : parser = argparse . ArgumentParser ( description = "GNS3 server version {}" . format ( __version__ ) ) parser . add_argument ( "-v" , "--version" , help = "show the version" , action = "version" , version = __version__ ) parser . add_argument ( "--host" , help = "run on the given host/IP address" ) parser . add_argument ( "--port" , help = "run on the given port" , type = int ) parser . add_argument ( "--ssl" , action = "store_true" , help = "run in SSL mode" ) parser . add_argument ( "--no-ubridge" , action = "store_false" , help = "do not use ubridge to handle node connections" ) parser . add_argument ( "--config" , help = "Configuration file" ) parser . add_argument ( "--certfile" , help = "SSL cert file" ) parser . add_argument ( "--certkey" , help = "SSL key file" ) parser . add_argument ( "--record" , help = "save curl requests into a file (for developers)" ) parser . add_argument ( "-L" , "--local" , action = "store_true" , help = "local mode (allows some insecure operations)" ) parser . add_argument ( "-A" , "--allow" , action = "store_true" , help = "allow remote connections to local console ports" ) parser . add_argument ( "-q" , "--quiet" , action = "store_true" , help = "do not show logs on stdout" ) parser . add_argument ( "-d" , "--debug" , action = "store_true" , help = "show debug logs" ) parser . add_argument ( "--shell" , action = "store_true" , help = "start a shell inside the server (debugging purpose only you need to install ptpython before)" ) parser . add_argument ( "--log" , help = "send output to logfile instead of console" ) parser . add_argument ( "--daemon" , action = "store_true" , help = "start as a daemon" ) parser . add_argument ( "--pid" , help = "store process pid" ) parser . add_argument ( "--profile" , help = "Settings profile (blank will use default settings files)" ) args = parser . parse_args ( argv ) if args . config : Config . instance ( files = [ args . config ] , profile = args . profile ) else : Config . instance ( profile = args . profile ) config = Config . instance ( ) . get_section_config ( "Server" ) defaults = { "host" : config . get ( "host" , "0.0.0.0" ) , "port" : config . get ( "port" , 3080 ) , "ssl" : config . getboolean ( "ssl" , False ) , "certfile" : config . get ( "certfile" , "" ) , "certkey" : config . get ( "certkey" , "" ) , "record" : config . get ( "record" , "" ) , "local" : config . getboolean ( "local" , False ) , "allow" : config . getboolean ( "allow_remote_console" , False ) , "quiet" : config . getboolean ( "quiet" , False ) , "debug" : config . getboolean ( "debug" , False ) , "logfile" : config . getboolean ( "logfile" , "" ) } parser . set_defaults ( ** defaults ) return parser . parse_args ( argv )
Parse command line arguments and override local configuration

    :params args: Array of command line arguments