Skip to content

Commit a7165d7

Browse files
committed
Revert "Fix flake 8 style warnings"
This reverts commit b8fd431 which accidentally introduced a regression for some versions of python. Signed-off-by: Brian Behlendorf <[email protected]> Issue #7929
1 parent e897a23 commit a7165d7

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

tests/test-runner/bin/test-runner.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Copyright (c) 2017 Datto Inc.
1717
#
1818

19-
import configparser
19+
import ConfigParser
2020
import os
2121
import logging
2222
from datetime import datetime
@@ -27,7 +27,7 @@
2727
from subprocess import PIPE
2828
from subprocess import Popen
2929
from sys import argv
30-
from sys import maxsize
30+
from sys import maxint
3131
from threading import Timer
3232
from time import time
3333

@@ -204,23 +204,23 @@ def run(self, options):
204204
if needed. Run the command, and update the result object.
205205
"""
206206
if options.dryrun is True:
207-
print(self)
207+
print self
208208
return
209209

210210
privcmd = self.update_cmd_privs(self.pathname, self.user)
211211
try:
212212
old = os.umask(0)
213213
if not os.path.isdir(self.outputdir):
214-
os.makedirs(self.outputdir, mode=0o777)
214+
os.makedirs(self.outputdir, mode=0777)
215215
os.umask(old)
216-
except OSError as e:
216+
except OSError, e:
217217
fail('%s' % e)
218218

219219
self.result.starttime = time()
220220
proc = Popen(privcmd, stdout=PIPE, stderr=PIPE)
221221
# Allow a special timeout value of 0 to mean infinity
222222
if int(self.timeout) == 0:
223-
self.timeout = maxsize
223+
self.timeout = maxint
224224
t = Timer(int(self.timeout), self.kill_cmd, [proc])
225225

226226
try:
@@ -274,7 +274,7 @@ def log(self, logger, options):
274274
logger.debug('%s%s%s' % (msga, pad, msgb))
275275

276276
lines = sorted(self.result.stdout + self.result.stderr,
277-
key=lambda x: x[0])
277+
cmp=lambda x, y: cmp(x[0], y[0]))
278278

279279
for dt, line in lines:
280280
logger.debug('%s %s' % (dt.strftime("%H:%M:%S.%f ")[:11], line))
@@ -552,7 +552,7 @@ def read(self, logger, options):
552552
in the 'DEFAULT' section. If the Test or TestGroup passes
553553
verification, add it to the TestRun.
554554
"""
555-
config = configparser.RawConfigParser()
555+
config = ConfigParser.RawConfigParser()
556556
if not len(config.read(options.runfile)):
557557
fail("Coulnd't read config file %s" % options.runfile)
558558

@@ -608,7 +608,7 @@ def write(self, options):
608608

609609
defaults = dict([(prop, getattr(options, prop)) for prop, _ in
610610
self.defaults])
611-
config = configparser.RawConfigParser(defaults)
611+
config = ConfigParser.RawConfigParser(defaults)
612612

613613
for test in sorted(self.tests.keys()):
614614
config.add_section(test)
@@ -637,15 +637,14 @@ def complete_outputdirs(self):
637637
"""
638638
done = False
639639
components = 0
640-
tmp_dict = dict(list(self.tests.items()) +
641-
list(self.testgroups.items()))
640+
tmp_dict = dict(self.tests.items() + self.testgroups.items())
642641
total = len(tmp_dict)
643642
base = self.outputdir
644643

645644
while not done:
646645
paths = []
647646
components -= 1
648-
for testfile in list(tmp_dict.keys()):
647+
for testfile in tmp_dict.keys():
649648
uniq = '/'.join(testfile.split('/')[components:]).lstrip('/')
650649
if uniq not in paths:
651650
paths.append(uniq)
@@ -673,9 +672,9 @@ def setup_logging(self, options):
673672
if options.cmd is not 'wrconfig':
674673
try:
675674
old = os.umask(0)
676-
os.makedirs(self.outputdir, mode=0o777)
675+
os.makedirs(self.outputdir, mode=0777)
677676
os.umask(old)
678-
except OSError as e:
677+
except OSError, e:
679678
fail('%s' % e)
680679
filename = os.path.join(self.outputdir, 'log')
681680

@@ -708,8 +707,8 @@ def run(self, options):
708707
if not os.path.exists(logsymlink):
709708
os.symlink(self.outputdir, logsymlink)
710709
else:
711-
print('Could not make a symlink to directory %s' % (
712-
self.outputdir))
710+
print 'Could not make a symlink to directory %s' % (
711+
self.outputdir)
713712
iteration = 0
714713
while iteration < options.iterations:
715714
for test in sorted(self.tests.keys()):
@@ -722,17 +721,17 @@ def summary(self):
722721
if Result.total is 0:
723722
return 2
724723

725-
print('\nResults Summary')
726-
for key in list(Result.runresults.keys()):
724+
print '\nResults Summary'
725+
for key in Result.runresults.keys():
727726
if Result.runresults[key] is not 0:
728-
print('%s\t% 4d' % (key, Result.runresults[key]))
727+
print '%s\t% 4d' % (key, Result.runresults[key])
729728

730729
m, s = divmod(time() - self.starttime, 60)
731730
h, m = divmod(m, 60)
732-
print('\nRunning Time:\t%02d:%02d:%02d' % (h, m, s))
733-
print('Percent passed:\t%.1f%%' % ((float(Result.runresults['PASS']) /
734-
float(Result.total)) * 100))
735-
print('Log directory:\t%s' % self.outputdir)
731+
print '\nRunning Time:\t%02d:%02d:%02d' % (h, m, s)
732+
print 'Percent passed:\t%.1f%%' % ((float(Result.runresults['PASS']) /
733+
float(Result.total)) * 100)
734+
print 'Log directory:\t%s' % self.outputdir
736735

737736
if Result.runresults['FAIL'] > 0:
738737
return 1
@@ -805,7 +804,7 @@ def find_tests(testrun, options):
805804

806805

807806
def fail(retstr, ret=1):
808-
print('%s: %s' % (argv[0], retstr))
807+
print '%s: %s' % (argv[0], retstr)
809808
exit(ret)
810809

811810

tests/test-runner/bin/zts-report.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@
277277

278278

279279
def usage(s):
280-
print(s)
280+
print s
281281
sys.exit(1)
282282

283283

284284
def process_results(pathname):
285285
try:
286286
f = open(pathname)
287-
except IOError as e:
288-
print('Error opening file: %s' % e)
287+
except IOError, e:
288+
print 'Error opening file: %s' % e
289289
sys.exit(1)
290290

291291
prefix = '/zfs-tests/tests/functional/'
@@ -316,14 +316,14 @@ def process_results(pathname):
316316
results = process_results(sys.argv[1])
317317

318318
if summary['total'] == 0:
319-
print("\n\nNo test results were found.")
320-
print("Log directory: %s" % summary['logfile'])
319+
print "\n\nNo test results were found."
320+
print "Log directory: %s" % summary['logfile']
321321
sys.exit(0)
322322

323323
expected = []
324324
unexpected = []
325325

326-
for test in list(results.keys()):
326+
for test in results.keys():
327327
if results[test] == "PASS":
328328
continue
329329

@@ -340,7 +340,7 @@ def process_results(pathname):
340340
else:
341341
expected.append(test)
342342

343-
print("\nTests with results other than PASS that are expected:")
343+
print "\nTests with results other than PASS that are expected:"
344344
for test in sorted(expected):
345345
issue_url = 'https://github.com/zfsonlinux/zfs/issues/'
346346

@@ -366,21 +366,20 @@ def process_results(pathname):
366366
continue
367367
else:
368368
expect = "UNKNOWN REASON"
369-
print(" %s %s (%s)" % (results[test], test, expect))
369+
print " %s %s (%s)" % (results[test], test, expect)
370370

371-
print("\nTests with result of PASS that are unexpected:")
371+
print "\nTests with result of PASS that are unexpected:"
372372
for test in sorted(known.keys()):
373373
# We probably should not be silently ignoring the case
374374
# where "test" is not in "results".
375375
if test not in results or results[test] != "PASS":
376376
continue
377-
print(" %s %s (expected %s)" % (results[test], test,
378-
known[test][0]))
377+
print " %s %s (expected %s)" % (results[test], test, known[test][0])
379378

380-
print("\nTests with results other than PASS that are unexpected:")
379+
print "\nTests with results other than PASS that are unexpected:"
381380
for test in sorted(unexpected):
382381
expect = "PASS" if test not in known else known[test][0]
383-
print(" %s %s (expected %s)" % (results[test], test, expect))
382+
print " %s %s (expected %s)" % (results[test], test, expect)
384383

385384
if len(unexpected) == 0:
386385
sys.exit(0)

0 commit comments

Comments
 (0)