]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3287] address review
authorAndrei Pavel <andrei@isc.org>
Mon, 17 Jun 2024 15:26:05 +0000 (18:26 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 20 Jun 2024 15:52:09 +0000 (18:52 +0300)
hammer.py
src/lib/util/python/gen_wiredata.py.in

index 839318dd094c9f2c7ac13963327931484de5fc19..37df11ba4fd08fe759a59e5b028d3b5badf3ce00 100755 (executable)
--- 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()
index bab72dbc485a6c14a00ecc5379947a718986efa4..9b2deae62b171e8fe649a2bc009c924437e40af1 100644 (file)
@@ -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: