From 69096baf78232d02e6742a739c917ffeb1733605 Mon Sep 17 00:00:00 2001 From: Orien Vandenbergh Date: Fri, 11 Nov 2016 18:21:07 -0700 Subject: [PATCH] Convert to using argparse --- ghetto/audit/ssl_thread_server.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ghetto/audit/ssl_thread_server.py b/ghetto/audit/ssl_thread_server.py index 1be88eb..e4e1536 100644 --- a/ghetto/audit/ssl_thread_server.py +++ b/ghetto/audit/ssl_thread_server.py @@ -17,6 +17,7 @@ __ssl_addition__ = 'rhmoult' import sys import os +import argparse #import sys # 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"): - if sys.argv[1:]: - port = int(sys.argv[1]) + parser = argparse.ArgumentParser(description='Listen and receive the incoming audit records') + 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: port = 8000 - if sys.argv[2:]: - os.chdir(sys.argv[2]) + if args.dir: + os.chdir(args.dir) server_address = ('', port)