fix#83 and some parsing cases

This commit is contained in:
Matteo ℱan 2020-07-29 22:23:36 +02:00
parent 771b70d376
commit d5fa609de5
No known key found for this signature in database
GPG Key ID: 3C30A05BC133D9B6
2 changed files with 3 additions and 4 deletions

View File

@ -406,9 +406,9 @@ def kms_parser_check_optionals(userarg, zeroarg, onearg, msg = 'optional py-kms
if elem and elem not in allarg: if elem and elem not in allarg:
raise KmsParserException("%s argument `" %msg + found + "`:" + " expected " + num + " unrecognized: '%s'" %elem) raise KmsParserException("%s argument `" %msg + found + "`:" + " expected " + num + " unrecognized: '%s'" %elem)
def kms_parser_check_positionals(config, parse_method, arguments = None, msg = 'positional py-kms server'): def kms_parser_check_positionals(config, parse_method, arguments = [], force_parse = False, msg = 'positional py-kms server'):
try: try:
if arguments: if arguments or force_parse:
config.update(vars(parse_method(arguments))) config.update(vars(parse_method(arguments)))
else: else:
config.update(vars(parse_method())) config.update(vars(parse_method()))

View File

@ -69,7 +69,6 @@ class KeyServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
selector.register(fileobj = self, events = selectors.EVENT_READ) selector.register(fileobj = self, events = selectors.EVENT_READ)
# self-pipe trick. # self-pipe trick.
selector.register(fileobj = self.r_service.fileno(), events = selectors.EVENT_READ) selector.register(fileobj = self.r_service.fileno(), events = selectors.EVENT_READ)
selector.register(fileobj = self.w_service.fileno(), events = selectors.EVENT_WRITE)
while not self.__shutdown_request: while not self.__shutdown_request:
ready = selector.select(timeout) ready = selector.select(timeout)
@ -261,7 +260,7 @@ def server_options():
# python3 pykms_Server.py 1.2.3.4 1234 --pykms_optionals etrigan start --daemon_optionals # python3 pykms_Server.py 1.2.3.4 1234 --pykms_optionals etrigan start --daemon_optionals
kms_parser_check_optionals(userarg[0:pos], pykmssrv_zeroarg, pykmssrv_onearg, exclude_opt_len = ['-F', '--logfile']) kms_parser_check_optionals(userarg[0:pos], pykmssrv_zeroarg, pykmssrv_onearg, exclude_opt_len = ['-F', '--logfile'])
kms_parser_check_positionals(srv_config, server_parser.parse_args, arguments = userarg[0:pos]) kms_parser_check_positionals(srv_config, server_parser.parse_args, arguments = userarg[0:pos], force_parse = True)
kms_parser_check_optionals(userarg[pos:], etrigan_zeroarg, etrigan_onearg, msg = 'optional etrigan') kms_parser_check_optionals(userarg[pos:], etrigan_zeroarg, etrigan_onearg, msg = 'optional etrigan')
kms_parser_check_positionals(srv_config, daemon_parser.parse_args, arguments = userarg[pos:], msg = 'positional etrigan') kms_parser_check_positionals(srv_config, daemon_parser.parse_args, arguments = userarg[pos:], msg = 'positional etrigan')