# includes/argparser.py # # module version: 1.1.20130625 # 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") parser.add_argument( "--mkpasswd", action = "store_true", help = "encode a password with SHA512") return parser.parse_args()