1
0
Fork 0
asrc-dev/include/argparser.py
Christian Damken 1207c6b225 - cleaned class argparser
- commented and cleaned asrc-server.py
- renamed includes/content.py to includes/comm.py
- renamed class content to comm
- made some vars (aliases, server_version, protocol_version, verbiosity) global in class comm
- added init() to class comm for setting lobal vars
- moved motd() from asrc-server-py to class comm
- conformed comm.motd() to reference
- added comm.header() for building the headers
- added includes/statuscodes.py with class statuscodes with dict description for storing the status codes and their description
- added docstrings
2013-04-26 12:55:37 +02:00

77 lines
2.3 KiB
Python

# includes/argparser.py
#
# module version: 1.0.20130425
#
class argparser:
def parse(program_version, protocol_version):
"""
Parses comand line arguments
"""
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),
help = "increase output verbosity. Can be from 0 "\
"(only default output) to 3 (debug messages).")
parser.add_argument(
"-h",
"--host",
help = "IP or hostname (use 0.0.0.0 for all interfaces) on which "\
"the server should listen")
parser.add_argument(
"-p",
"--port",
help = "the port on which the server should listen")
parser.add_argument(
"-t",
"--timeout",
help = "timeout of a connection in seconds - still "\
"doesn't work obviously...")
parser.add_argument(
"-e",
"--encoding",
help = "encoding to be used when communicating with clients")
return parser.parse_args()