def main(): args = parse_cmd_line() if OptionChecker.checkFileName(args["auth_file"]): generate_auth_file(args["auth_file"]) else: exit("Invalid file name") # Create the server, binding to localhost on port 9999 SocketServer.TCPServer.allow_reuse_address = True server = SocketServer.TCPServer(("127.0.0.1", int(args['port'])), Bank) # Activate the server; this will keep running until you # interrupt the program with Ctrl-C try: server.serve_forever() except KeyboardInterrupt: sys.exit
#Check that account name and mode of operation are provided if options.a == None: sys.exit(255) elif not options.n and not options.d and not options.w and not options.g: sys.exit(255) elif options.n and (options.d or options.w or options.g): sys.exit(255) elif options.d and (options.n or options.w or options.g): sys.exit(255) elif options.w and (options.n or options.d or options.g): sys.exit(255) elif options.g and (options.n or options.w or options.d): sys.exit(255) #Check that modes of operation values are valid: if options.n and (not OptionChecker.checkFloat(options.n) or float(options.n) < 10.00): sys.exit(255) if options.d and (not OptionChecker.checkFloat(options.d) or float(options.d)) <= 0.00: sys.exit(255) if options.w and (not OptionChecker.checkFloat(options.w) or float(options.w)) <= 0.00: sys.exit(255) #Check that file and account names meets specifications if not OptionChecker.checkFileName(os.path.split(options.s)[-1]): sys.exit(255) if not OptionChecker.checkAccountName(options.a): sys.exit(255) #Check that ipAddress meets specifications if not OptionChecker.checkIPAddress(options.i): sys.exit(255)