Christian Damken
daa40d6367
- class file folder is include/ - moved content handler to an individual class file (include/content.py) - added argument parser (include/argparser.py) -- doesn't work yet like expected
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
# includes/argparser.py
|
|
#
|
|
# module version: 1.0.20130424
|
|
#
|
|
|
|
|
|
class argparser:
|
|
|
|
def parse(program_version, protocol_version):
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description = "The server side of the "\
|
|
"aliased server remote control",
|
|
add_help = False)
|
|
|
|
|
|
parser.add_argument(
|
|
"--help",
|
|
action = "help",
|
|
help = "show this help message and exit")
|
|
|
|
parser.add_argument(
|
|
"--version",
|
|
action = "version",
|
|
version = "Server version: " + program_version +\
|
|
" / Protocol version: " + protocol_version)
|
|
|
|
grp_pid_file_failure = parser.add_mutually_exclusive_group()
|
|
grp_pid_file_failure.add_argument(
|
|
"-n",
|
|
"--delete-pid-file",
|
|
action = "store_true",
|
|
help = "deletes the pid file and starts the server")
|
|
|
|
grp_pid_file_failure.add_argument(
|
|
"-m",
|
|
"--allow-multiple-instances",
|
|
action = "store_true",
|
|
help = "ignores the pid file and starts the server. "\
|
|
"Will not create another pid file.")
|
|
|
|
parser.add_argument(
|
|
"-v",
|
|
"--verbosity",
|
|
type = int,
|
|
choices = range(0, 4),
|
|
# default = -1,
|
|
help = "increase output verbosity. Can be from 0 "\
|
|
"(only default output) to 3 (debug messages).")
|
|
|
|
parser.add_argument(
|
|
"-h",
|
|
"--host",
|
|
# default = -1,
|
|
help = "IP or hostname (use 0.0.0.0 for all interfaces) on which "\
|
|
"the server should listen")
|
|
|
|
parser.add_argument(
|
|
"-p",
|
|
"--port",
|
|
# default = -1,
|
|
help = "the port on which the server should listen")
|
|
|
|
parser.add_argument(
|
|
"-t",
|
|
"--timeout",
|
|
# default = -1,
|
|
help = "timeout of a connection in seconds - still "\
|
|
"doesn't work obviously...")
|
|
|
|
parser.add_argument(
|
|
"-e",
|
|
"--encoding",
|
|
# default = -1,
|
|
help = "encoding to be used when communicating with clients")
|
|
|
|
return parser.parse_args()
|