From: Andrei Pavel Date: Mon, 17 Jun 2024 15:26:05 +0000 (+0300) Subject: [#3287] address review X-Git-Tag: Kea-2.7.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3791bb03b0b82654a3e22a20878646b73b746b2e;p=thirdparty%2Fkea.git [#3287] address review --- diff --git a/hammer.py b/hammer.py index 839318dd09..37df11ba4f 100755 --- a/hammer.py +++ b/hammer.py @@ -384,9 +384,9 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False # security issue. with subprocess.Popen(cmd, cwd=cwd, env=env, shell=True, # nosec: B602 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as pipe: - if timeout is not None: - pipe.wait(timeout) try: + if timeout is not None: + pipe.wait(timeout) stdout, _ = pipe.communicate() except subprocess.TimeoutExpired as e: pipe.kill() diff --git a/src/lib/util/python/gen_wiredata.py.in b/src/lib/util/python/gen_wiredata.py.in index bab72dbc48..9b2deae62b 100644 --- a/src/lib/util/python/gen_wiredata.py.in +++ b/src/lib/util/python/gen_wiredata.py.in @@ -1455,17 +1455,16 @@ usage = 'usage: %prog [options] input_file' def main(): - parser = argparse.ArgumentParser(usage=usage) + parser = argparse.ArgumentParser(usage=usage.format(prog=sys.argv[0])) parser.add_argument('-o', '--output', action='store', dest='output', default=None, metavar='FILE', help='output file name [default: prefix of input_file]') + parser.add_argument(dest='input_file', default=None, help='input file name') args = parser.parse_args() - if len(args) == 0: - parser.error('input file is missing') - configfile = args[0] - + configfile = args.input_file outputfile = args.output + if not outputfile: m = re.match(r'(.*)\.[^.]+$', configfile) if m: @@ -1473,13 +1472,12 @@ def main(): else: raise ValueError('output file is not specified and input file is not in the form of "output_file.suffix"') - # DeprecationWarning: use ConfigParser directly - config = configparser.SafeConfigParser() # pylint: disable=deprecated-class + config = configparser.ConfigParser() config.read(configfile) output = open(outputfile, 'w', encoding='utf-8') # pylint: disable=consider-using-with - print_header(outputfile, configfile) + print_header(output, configfile) # First try the 'custom' mode; if it fails assume the query mode. try: