Skip to content

Commit 3791bb0

Browse files
committed
[#3287] address review
1 parent 9c35a4d commit 3791bb0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Diff for: hammer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
384384
# security issue.
385385
with subprocess.Popen(cmd, cwd=cwd, env=env, shell=True, # nosec: B602
386386
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as pipe:
387-
if timeout is not None:
388-
pipe.wait(timeout)
389387
try:
388+
if timeout is not None:
389+
pipe.wait(timeout)
390390
stdout, _ = pipe.communicate()
391391
except subprocess.TimeoutExpired as e:
392392
pipe.kill()

Diff for: src/lib/util/python/gen_wiredata.py.in

+6-8
Original file line numberDiff line numberDiff line change
@@ -1455,31 +1455,29 @@ usage = 'usage: %prog [options] input_file'
14551455

14561456

14571457
def main():
1458-
parser = argparse.ArgumentParser(usage=usage)
1458+
parser = argparse.ArgumentParser(usage=usage.format(prog=sys.argv[0]))
14591459
parser.add_argument('-o', '--output', action='store', dest='output',
14601460
default=None, metavar='FILE',
14611461
help='output file name [default: prefix of input_file]')
1462+
parser.add_argument(dest='input_file', default=None, help='input file name')
14621463
args = parser.parse_args()
14631464

1464-
if len(args) == 0:
1465-
parser.error('input file is missing')
1466-
configfile = args[0]
1467-
1465+
configfile = args.input_file
14681466
outputfile = args.output
1467+
14691468
if not outputfile:
14701469
m = re.match(r'(.*)\.[^.]+$', configfile)
14711470
if m:
14721471
outputfile = m.group(1)
14731472
else:
14741473
raise ValueError('output file is not specified and input file is not in the form of "output_file.suffix"')
14751474

1476-
# DeprecationWarning: use ConfigParser directly
1477-
config = configparser.SafeConfigParser() # pylint: disable=deprecated-class
1475+
config = configparser.ConfigParser()
14781476
config.read(configfile)
14791477

14801478
output = open(outputfile, 'w', encoding='utf-8') # pylint: disable=consider-using-with
14811479

1482-
print_header(outputfile, configfile)
1480+
print_header(output, configfile)
14831481

14841482
# First try the 'custom' mode; if it fails assume the query mode.
14851483
try:

0 commit comments

Comments
 (0)