Convert to using argparse

This commit is contained in:
Orien Vandenbergh 2016-11-11 18:21:07 -07:00
parent 0451fdbb5b
commit 69096baf78

View File

@ -17,6 +17,7 @@ __ssl_addition__ = 'rhmoult'
import sys import sys
import os import os
import argparse
#import sys # Modification by rmoulton #import sys # Modification by rmoulton
#import ssl # Modification by rmoulton #import ssl # Modification by rmoulton
@ -35,13 +36,19 @@ class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
def main(HandlerClass=SimpleHTTPRequestHandler, ServerClass=HTTPServer, protocol="HTTP/1.0"): def main(HandlerClass=SimpleHTTPRequestHandler, ServerClass=HTTPServer, protocol="HTTP/1.0"):
if sys.argv[1:]: parser = argparse.ArgumentParser(description='Listen and receive the incoming audit records')
port = int(sys.argv[1]) parser.add_argument('--port', type=int, help='the port number to listen on')
parser.add_argument('--dir', help='the port number to listen on')
args = parser.parse_args()
if args.port:
port = args.port
else: else:
port = 8000 port = 8000
if sys.argv[2:]: if args.dir:
os.chdir(sys.argv[2]) os.chdir(args.dir)
server_address = ('', port) server_address = ('', port)