comparison roundup/scripts/roundup_demo.py @ 7926:05f36a527a45

feat: allow setting URL hostname with -H option to roundup-demo The underlying demo.py code already supported this. Also update man page ading -H and fixing formatting for a number of entries. Clarify that hostname can be used with -B to listen on the ip address for that host. Refactor port handling to reduce line length.
author John Rouillard <rouilj@ieee.org>
date Thu, 02 May 2024 21:49:17 -0400
parents f5f09ed9a783
children 39013eba1aaf
comparison
equal deleted inserted replaced
7925:f5f09ed9a783 7926:05f36a527a45
69 add_help=True) 69 add_help=True)
70 70
71 cli.add_argument('-B', '--bind_address', 71 cli.add_argument('-B', '--bind_address',
72 default="127.0.0.1", 72 default="127.0.0.1",
73 help=( "Choose address for server to listen at.\n" 73 help=( "Choose address for server to listen at.\n"
74 "Use 0.0.0.0 to bind to all addreses.\n" 74 "Use 0.0.0.0 to bind to all addreses. Use\n"
75 "the external name of the computer to bind to\n"
76 "the external host interface.\n"
75 "Default: %(default)s.\n\n")) 77 "Default: %(default)s.\n\n"))
76 cli.add_argument('-b', '--backend_db', 78 cli.add_argument('-b', '--backend_db',
77 choices=backends, 79 choices=backends,
78 help=( "Choose backend database. Default: %s.\n\n" % 80 help=( "Choose backend database. Default: %s.\n\n" %
79 DEFAULT_BACKEND)) 81 DEFAULT_BACKEND))
82 cli.add_argument('-H', '--hostname',
83 default="localhost",
84 help=( "Choose hostname for the server.\n"
85 "Default: %(default)s.\n\n"
86 ))
80 cli.add_argument('-t', '--template', 87 cli.add_argument('-t', '--template',
81 choices=templates, 88 choices=templates,
82 help="Use specified template. (*)\n\n") 89 help="Use specified template. (*)\n\n")
83 cli.add_argument('-p', '--port', 90 cli.add_argument('-p', '--port',
84 type=int, 91 type=int,
85 help=( "Listen at this port. Default: search for\n" 92 help=( "Listen at this port. Default: search for\n"
86 "open port starting at %s\n\n" % DEFAULT_PORT)) 93 "open port starting at %s\n\n" % DEFAULT_PORT))
87 cli.add_argument('-P', '--urlport', 94 cli.add_argument('-P', '--urlport',
88 type=int, 95 type=int,
89 help=( "Set docker external port. If using\n" 96 help=( "Set docker external port. If using\n"
90 " docker ... -p 9090:8917 ..." 97 " docker ... -p 9090:8917 ...\n"
91 "this should be set to 9090. " 98 "this should be set to 9090.\n"
92 "Default: as selected by --port\n\n")) 99 "Default: as selected by --port\n\n"))
93 cli.add_argument('-V', '--version', action='version', 100 cli.add_argument('-V', '--version', action='version',
94 version='Roundup version %s'%roundup_version, 101 version='Roundup version %s'%roundup_version,
95 help=( 102 help=(
96 "Show program's version number: %s and exit\n" % 103 "Show program's version number: %s and exit\n" %
106 "Depricated, use -b instead.\n" 113 "Depricated, use -b instead.\n"
107 "If it is used, you *must* specify directory.\n\n")) 114 "If it is used, you *must* specify directory.\n\n"))
108 115
109 cli.add_argument('nuke', nargs='?', metavar='nuke', choices=['nuke'], 116 cli.add_argument('nuke', nargs='?', metavar='nuke', choices=['nuke'],
110 help=( "The word 'nuke' will delete tracker and reset.\n" 117 help=( "The word 'nuke' will delete tracker and reset.\n"
111 "E.G. %(prog)s -b sqlite -t classic ./mytracker nuke\n") % {"prog": sys.argv[0]}) 118 "E.G. %(prog)s -b sqlite \\ \n"
119 "-t classic ./mytracker nuke\n") % {"prog": sys.argv[0]})
112 120
113 cli_args = cli.parse_args() 121 cli_args = cli.parse_args()
114 122
115 # collect all positional args in order in array to parse 123 # collect all positional args in order in array to parse
116 # strip all None. 124 # strip all None.
166 template = DEFAULT_TEMPLATE 174 template = DEFAULT_TEMPLATE
167 elif template not in templates: 175 elif template not in templates:
168 print("Unknown template: %s. Exiting." % template) 176 print("Unknown template: %s. Exiting." % template)
169 exit(1) 177 exit(1)
170 # install 178 # install
179 url_port = cli_args.urlport or cli_args.port or DEFAULT_PORT
171 demo.install_demo(home, backend, 180 demo.install_demo(home, backend,
172 admin.AdminTool().listTemplates()[template]['path'], 181 admin.AdminTool().listTemplates()[template]['path'],
173 use_port=cli_args.urlport or cli_args.port or DEFAULT_PORT) 182 use_port=url_port, use_host=cli_args.hostname)
174 else: 183 else:
175 # make sure that no options are specified that are only useful on initialization. 184 # make sure that no options are specified that are only useful on initialization.
176 if ( cli_args.backend or cli_args.template or 185 if ( cli_args.backend or cli_args.template or
177 cli_args.backend_db ): 186 cli_args.backend_db ):
178 usage(home, cli, msg=( 187 usage(home, cli, msg=(

Roundup Issue Tracker: http://roundup-tracker.org/