| 1 |
Description: Update python2 to python3 |
| 2 |
Thank you: https://src.fedoraproject.org/rpms/nfsometer/blob/f32/f/nfsometer_py3.patch |
| 3 |
. |
| 4 |
nfsometer (1.9-1) UNRELEASED; urgency=medium |
| 5 |
. |
| 6 |
* Initial release. (Closes: #nnnn) <nnnn is the bug number of your ITP> |
| 7 |
Author: Gürkan Myczko <[email protected]> |
| 8 |
|
| 9 |
--- |
| 10 |
The information above should follow the Patch Tagging Guidelines, please |
| 11 |
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here |
| 12 |
are templates for supplementary fields that you might want to add: |
| 13 |
|
| 14 |
Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>) |
| 15 |
Bug: <upstream-bugtracker-url> |
| 16 |
Bug-Debian: https://bugs.debian.org/<bugnumber> |
| 17 |
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> |
| 18 |
Forwarded: (no|not-needed|<patch-forwarded-url>) |
| 19 |
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>) |
| 20 |
Reviewed-By: <name and email of someone who approved/reviewed the patch> |
| 21 |
Last-Update: 2023-04-27 |
| 22 |
|
| 23 |
--- nfsometer-1.9.orig/nfsometer.py |
| 24 |
+++ nfsometer-1.9/nfsometer.py |
| 25 |
@@ -1,4 +1,4 @@ |
| 26 |
-#!/usr/bin/env python |
| 27 |
+#!/usr/bin/env python3 |
| 28 |
""" |
| 29 |
Copyright 2012 NetApp, Inc. All Rights Reserved, |
| 30 |
contribution by Weston Andros Adamson <[email protected]> |
| 31 |
@@ -15,6 +15,7 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 32 |
import posix |
| 33 |
import sys |
| 34 |
import os |
| 35 |
+#import six |
| 36 |
|
| 37 |
from nfsometerlib import trace |
| 38 |
from nfsometerlib import options |
| 39 |
@@ -46,19 +47,19 @@ def mode_notes(opts): |
| 40 |
collection = TraceCollection(opts.resultdir) |
| 41 |
collection.notes_edit() |
| 42 |
|
| 43 |
- print 'Saved notes for results %s' % (opts.resultdir) |
| 44 |
+ print('Saved notes for results %s' % (opts.resultdir)) |
| 45 |
|
| 46 |
def mode_list(opts): |
| 47 |
collection = TraceCollection(opts.resultdir) |
| 48 |
|
| 49 |
- print 'Result directory \'%s\' contains:\n\n%s' % \ |
| 50 |
- (opts.resultdir, '\n'.join(collection.show_contents(pre=''))) |
| 51 |
+ print('Result directory \'%s\' contains:\n\n%s' % \ |
| 52 |
+ (opts.resultdir, '\n'.join(collection.show_contents(pre='')))) |
| 53 |
|
| 54 |
def mode_workloads(opts): |
| 55 |
- print "Available workloads:" |
| 56 |
- print " %s" % '\n '.join(available_workloads()) |
| 57 |
- print "Unavailable workloads:" |
| 58 |
- print " %s" % '\n '.join(unavailable_workloads()) |
| 59 |
+ print("Available workloads:") |
| 60 |
+ print(" %s" % '\n '.join(available_workloads())) |
| 61 |
+ print("Unavailable workloads:") |
| 62 |
+ print(" %s" % '\n '.join(unavailable_workloads())) |
| 63 |
|
| 64 |
def mode_loadgen(opts): |
| 65 |
# XXX check idle? |
| 66 |
@@ -75,7 +76,7 @@ def mode_fetch_trace(opts, fetch_only=Fa |
| 67 |
check_idle_before_start(opts) |
| 68 |
collection = TraceCollection(opts.resultdir) |
| 69 |
trace.run_traces(collection, opts, fetch_only=fetch_only) |
| 70 |
- print |
| 71 |
+ print('') |
| 72 |
|
| 73 |
def mode_report(opts): |
| 74 |
collection = TraceCollection(opts.resultdir) |
| 75 |
@@ -83,7 +84,7 @@ def mode_report(opts): |
| 76 |
rpt = ReportSet(collection, opts.serial_graph_gen) |
| 77 |
rpt.generate_reports() |
| 78 |
else: |
| 79 |
- print "No tracedirs found" |
| 80 |
+ print("No tracedirs found") |
| 81 |
|
| 82 |
def main(): |
| 83 |
opts = options.Options() |
| 84 |
@@ -129,5 +130,5 @@ if __name__ == '__main__': |
| 85 |
try: |
| 86 |
main() |
| 87 |
except KeyboardInterrupt: |
| 88 |
- print >>sys.stderr, "\nCancelled by user...\n" |
| 89 |
+ print("\nCancelled by user...\n", file=sys.stderr) |
| 90 |
|
| 91 |
--- nfsometer-1.9.orig/nfsometerlib/cmd.py |
| 92 |
+++ nfsometer-1.9/nfsometerlib/cmd.py |
| 93 |
@@ -12,9 +12,9 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 94 |
""" |
| 95 |
|
| 96 |
import os |
| 97 |
-import posix |
| 98 |
import sys |
| 99 |
import subprocess |
| 100 |
+#import six |
| 101 |
|
| 102 |
# command wrappers |
| 103 |
def simplecmd(args): |
| 104 |
@@ -41,11 +41,11 @@ class CmdErrorOut(CmdError): |
| 105 |
def cmd(args, raiseerrorcode=True, raiseerrorout=True, instr='', |
| 106 |
env=None, pass_output=False): |
| 107 |
|
| 108 |
- #print "command> %s" % args |
| 109 |
+ #print("command> %s" % args) |
| 110 |
|
| 111 |
if env: |
| 112 |
- curenv = dict(posix.environ) |
| 113 |
- for k,v in env.iteritems(): |
| 114 |
+ curenv = dict(os.environ) |
| 115 |
+ for k,v in env.items(): |
| 116 |
curenv[k] = v |
| 117 |
env = curenv |
| 118 |
|
| 119 |
@@ -82,11 +82,13 @@ def cmd(args, raiseerrorcode=True, raise |
| 120 |
(args, errstr)) |
| 121 |
|
| 122 |
if outstr: |
| 123 |
- o_str = outstr.split('\n') |
| 124 |
+ o_str = outstr.decode('utf-8').split('\n') |
| 125 |
else: |
| 126 |
o_str = '' |
| 127 |
|
| 128 |
if errstr: |
| 129 |
+ if isinstance(errstr, bytes): |
| 130 |
+ errstr = errstr.decode('utf-8') |
| 131 |
e_str = errstr.split('\n') |
| 132 |
else: |
| 133 |
e_str = '' |
| 134 |
--- nfsometer-1.9.orig/nfsometerlib/collection.py |
| 135 |
+++ nfsometer-1.9/nfsometerlib/collection.py |
| 136 |
@@ -14,11 +14,12 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 137 |
import os |
| 138 |
import numpy as np |
| 139 |
from subprocess import call |
| 140 |
+#import six |
| 141 |
|
| 142 |
-from config import * |
| 143 |
-from selector import Selector |
| 144 |
-import parse |
| 145 |
-from trace import TraceAttrs |
| 146 |
+from .config import * |
| 147 |
+from .selector import Selector |
| 148 |
+from . import parse |
| 149 |
+from .trace import TraceAttrs |
| 150 |
|
| 151 |
class Stat: |
| 152 |
""" |
| 153 |
@@ -64,7 +65,7 @@ class Stat: |
| 154 |
return "Stat(name=%r, values=%r, tracedirs=%r)" % \ |
| 155 |
(self.name, self._values, self._tracedirs) |
| 156 |
|
| 157 |
- def __nonzero__(self): |
| 158 |
+ def __bool__(self): |
| 159 |
return not self.empty() |
| 160 |
|
| 161 |
def num_runs(self): |
| 162 |
@@ -75,7 +76,7 @@ class Stat: |
| 163 |
""" return the value for the run associated with tracedir """ |
| 164 |
try: |
| 165 |
run = self._tracedirs.index(tracedir) |
| 166 |
- except ValueError, e: |
| 167 |
+ except ValueError as e: |
| 168 |
if args: |
| 169 |
assert len(args) == 1 |
| 170 |
return args[0] |
| 171 |
@@ -83,7 +84,7 @@ class Stat: |
| 172 |
|
| 173 |
try: |
| 174 |
return self._values[run] |
| 175 |
- except IndexError, e: |
| 176 |
+ except IndexError as e: |
| 177 |
if args: |
| 178 |
assert len(args) == 1 |
| 179 |
return args[0] |
| 180 |
@@ -161,12 +162,12 @@ class Bucket: |
| 181 |
self._empty = None |
| 182 |
self._num_runs = None |
| 183 |
|
| 184 |
- def __nonzero__(self): |
| 185 |
+ def __bool__(self): |
| 186 |
return not self.empty() |
| 187 |
|
| 188 |
def _sort(self): |
| 189 |
if not self._sorted: |
| 190 |
- self._stats.sort(lambda x,y: -1 * cmp(x.mean(), y.mean())) |
| 191 |
+ self._stats.sort(key=lambda x: x.mean(), reverse=True) |
| 192 |
self._sorted = True |
| 193 |
|
| 194 |
def foreach(self): |
| 195 |
@@ -182,12 +183,12 @@ class Bucket: |
| 196 |
|
| 197 |
def mean(self): |
| 198 |
if self._mean == None: |
| 199 |
- self._mean = np.mean(self._sum_by_tracedir.values()) |
| 200 |
+ self._mean = np.mean(list(self._sum_by_tracedir.values())) |
| 201 |
return self._mean |
| 202 |
|
| 203 |
def std(self): |
| 204 |
if self._std == None: |
| 205 |
- self._std = np.std(self._sum_by_tracedir.values()) |
| 206 |
+ self._std = np.std(list(self._sum_by_tracedir.values())) |
| 207 |
return self._std |
| 208 |
|
| 209 |
def max(self): |
| 210 |
@@ -223,7 +224,7 @@ class Bucket: |
| 211 |
if not d in self._tracedirs: |
| 212 |
self._tracedirs.append(d) |
| 213 |
|
| 214 |
- if not self._sum_by_tracedir.has_key(d): |
| 215 |
+ if d not in self._sum_by_tracedir: |
| 216 |
self._sum_by_tracedir[d] = 0.0 |
| 217 |
self._sum_by_tracedir[d] += vals[i] |
| 218 |
|
| 219 |
@@ -240,15 +241,16 @@ class TraceStats: |
| 220 |
self._num_runs = None |
| 221 |
|
| 222 |
def add_attr(self, name, value): |
| 223 |
- if not self._attrs.has_key(name): |
| 224 |
- self._attrs[name] = set() |
| 225 |
- self._attrs[name].add(value) |
| 226 |
+ if name not in self._attrs: |
| 227 |
+ self._attrs[name] = set([value]) |
| 228 |
+ else: |
| 229 |
+ self._attrs[name].add(value) |
| 230 |
|
| 231 |
def get_attr(self, name): |
| 232 |
return self._attrs[name] |
| 233 |
|
| 234 |
def has_attr(self, name): |
| 235 |
- return self._attrs.has_key(name) |
| 236 |
+ return name in self._attrs |
| 237 |
|
| 238 |
def merge_attrs(self, new): |
| 239 |
str_attrs = ['workload_command', 'workload_description'] |
| 240 |
@@ -264,7 +266,7 @@ class TraceStats: |
| 241 |
""" add a value for the key. should be called once on each key for |
| 242 |
every workload result directory """ |
| 243 |
|
| 244 |
- if not self._values.has_key(key): |
| 245 |
+ if key not in self._values: |
| 246 |
self._values[key] = Stat(key) |
| 247 |
|
| 248 |
self._values[key].add_value(float(value), filename, tracedir) |
| 249 |
@@ -293,7 +295,7 @@ class TraceStats: |
| 250 |
every workload result directory """ |
| 251 |
assert isinstance(stat, Stat), repr(stat) |
| 252 |
|
| 253 |
- if not self._values.has_key(bucket_name): |
| 254 |
+ if bucket_name not in self._values: |
| 255 |
self._values[bucket_name] = Bucket(bucket_name) |
| 256 |
|
| 257 |
self._values[bucket_name].add_stat_to_bucket(stat) |
| 258 |
@@ -337,7 +339,7 @@ class TraceCollection: |
| 259 |
# new |
| 260 |
elif ent.startswith(TRACE_DIR_PREFIX) and os.path.isdir(ent): |
| 261 |
self.load_tracedir(ent) |
| 262 |
- except IOError, e: |
| 263 |
+ except IOError as e: |
| 264 |
self.warn(ent, str(e)) |
| 265 |
|
| 266 |
os.chdir(cwd) |
| 267 |
@@ -351,7 +353,7 @@ class TraceCollection: |
| 268 |
servers = set() |
| 269 |
paths = set() |
| 270 |
|
| 271 |
- for sel, tracestat in self._tracestats.iteritems(): |
| 272 |
+ for sel, tracestat in self._tracestats.items(): |
| 273 |
parse.gather_buckets(self, tracestat) |
| 274 |
|
| 275 |
workloads.add(sel.workload) |
| 276 |
@@ -391,7 +393,7 @@ class TraceCollection: |
| 277 |
def notes_get(self): |
| 278 |
notes_file = os.path.join(self.resultsdir, NOTES_FILE) |
| 279 |
try: |
| 280 |
- return file(notes_file).readlines() |
| 281 |
+ return open(notes_file).readlines() |
| 282 |
except IOError: |
| 283 |
return [] |
| 284 |
|
| 285 |
@@ -401,19 +403,19 @@ class TraceCollection: |
| 286 |
if msg.startswith('[Errno '): |
| 287 |
msg = msg[msg.find(']') + 1:] |
| 288 |
|
| 289 |
- if not self._warnings.has_key(tracedir): |
| 290 |
+ if tracedir not in self._warnings: |
| 291 |
self._warnings[tracedir] = [] |
| 292 |
self._warnings[tracedir].append(msg.replace(tracedir, '[dir]/')) |
| 293 |
warn(tracedir + ': ' + msg) |
| 294 |
|
| 295 |
def warnings(self): |
| 296 |
- return [ (d, tuple(self._warnings[d])) for d in self._warnings.keys() ] |
| 297 |
+ return [ (d, tuple(self._warnings[d])) for d in list(self._warnings.keys()) ] |
| 298 |
|
| 299 |
def empty(self): |
| 300 |
return len(self._tracestats) == 0 |
| 301 |
|
| 302 |
def set_stat_info(self, key, info): |
| 303 |
- if not self._stat_info.has_key(key): |
| 304 |
+ if key not in self._stat_info: |
| 305 |
self._stat_info[key] = info |
| 306 |
else: |
| 307 |
assert self._stat_info[key] == info, \ |
| 308 |
@@ -450,7 +452,7 @@ class TraceCollection: |
| 309 |
|
| 310 |
assert sel.is_valid_key(), "Invalid key: %r" % sel |
| 311 |
|
| 312 |
- if not self._tracestats.has_key(sel): |
| 313 |
+ if sel not in self._tracestats: |
| 314 |
self._tracestats[sel] = TraceStats(self) |
| 315 |
|
| 316 |
return self._tracestats[sel] |
| 317 |
@@ -462,7 +464,7 @@ class TraceCollection: |
| 318 |
""" return True if this collection has any traces matching 'selection', |
| 319 |
otherwise returns False """ |
| 320 |
for x in selection.foreach(): |
| 321 |
- if self._tracestats.has_key(x): |
| 322 |
+ if x in self._tracestats: |
| 323 |
return True |
| 324 |
return False |
| 325 |
|
| 326 |
@@ -474,7 +476,7 @@ class TraceCollection: |
| 327 |
attr_file = os.path.join(tracedir, 'arguments') |
| 328 |
trace_attrs = TraceAttrs(filename=attr_file).to_dict() |
| 329 |
|
| 330 |
- for k, v in trace_attrs.iteritems(): |
| 331 |
+ for k, v in trace_attrs.items(): |
| 332 |
attr[k] = v |
| 333 |
|
| 334 |
return attr |
| 335 |
@@ -485,7 +487,7 @@ class TraceCollection: |
| 336 |
returns empty string if nothing is found |
| 337 |
""" |
| 338 |
def _check_lines(f): |
| 339 |
- return '\n'.join([ x[2:] for x in file(f).readlines() |
| 340 |
+ return '\n'.join([ x[2:] for x in open(f).readlines() |
| 341 |
if x.startswith('>') and x.lower().find('nfs:') >= 0 ]) |
| 342 |
|
| 343 |
diff = os.path.join(tracedir, 'dmesg.diff') |
| 344 |
@@ -528,14 +530,18 @@ class TraceCollection: |
| 345 |
for subsel in selection.foreach(): |
| 346 |
try: |
| 347 |
tracestat = self.get_trace(subsel) |
| 348 |
- except KeyError: |
| 349 |
+ except KeyError as e: |
| 350 |
continue |
| 351 |
|
| 352 |
if tracestat.has_attr(attr_name): |
| 353 |
trace_attr = tracestat.get_attr(attr_name) |
| 354 |
attr = attr.union(trace_attr) |
| 355 |
|
| 356 |
- attr = list(attr) |
| 357 |
+ if not attr: |
| 358 |
+ attr = [] |
| 359 |
+ else: |
| 360 |
+ attr = list(attr) |
| 361 |
+ |
| 362 |
attr.sort() |
| 363 |
|
| 364 |
return tuple(attr) |
| 365 |
@@ -568,9 +574,9 @@ class TraceCollection: |
| 366 |
if not mdt in map_order: |
| 367 |
map_order.append(mdt) |
| 368 |
|
| 369 |
- if not tmpmap.has_key(mdt): |
| 370 |
+ if mdt not in tmpmap: |
| 371 |
tmpmap[mdt] = {} |
| 372 |
- if not tmpmap[mdt].has_key(nruns): |
| 373 |
+ if nruns not in tmpmap[mdt]: |
| 374 |
tmpmap[mdt][nruns] = [] |
| 375 |
|
| 376 |
tmpmap[mdt][nruns].append(subsel.workload) |
| 377 |
@@ -578,10 +584,10 @@ class TraceCollection: |
| 378 |
wmap = {} |
| 379 |
worder = [] |
| 380 |
for mdt in map_order: |
| 381 |
- if not tmpmap.has_key(mdt): |
| 382 |
+ if mdt not in tmpmap: |
| 383 |
continue |
| 384 |
|
| 385 |
- runs = tmpmap[mdt].keys() |
| 386 |
+ runs = list(tmpmap[mdt].keys()) |
| 387 |
runs.sort() |
| 388 |
|
| 389 |
for r in runs: |
| 390 |
@@ -633,7 +639,7 @@ class TraceCollection: |
| 391 |
order = ['workload', 'client', 'server', 'mountopt', 'detect', 'tag', 'kernel', 'path'] |
| 392 |
|
| 393 |
for subsel in selection.foreach(order): |
| 394 |
- assert not vals.has_key(subsel) |
| 395 |
+ assert subsel not in vals |
| 396 |
vals[subsel] = {} |
| 397 |
|
| 398 |
try: |
| 399 |
--- nfsometer-1.9.orig/nfsometerlib/config.py |
| 400 |
+++ nfsometer-1.9/nfsometerlib/config.py |
| 401 |
@@ -12,7 +12,7 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 402 |
""" |
| 403 |
|
| 404 |
import re |
| 405 |
-import os, posix, stat, sys |
| 406 |
+import os, stat, sys |
| 407 |
import socket |
| 408 |
|
| 409 |
NFSOMETER_VERSION='1.9' |
| 410 |
@@ -20,7 +20,7 @@ NFSOMETER_VERSION='1.9' |
| 411 |
NFSOMETER_MANPAGE='nfsometer.1' |
| 412 |
|
| 413 |
NFSOMETERLIB_DIR=os.path.split(__file__)[0] |
| 414 |
-NFSOMETER_DIR=os.path.join(posix.environ['HOME'], '.nfsometer') |
| 415 |
+NFSOMETER_DIR=os.path.join(os.environ['HOME'], '.nfsometer') |
| 416 |
|
| 417 |
|
| 418 |
# |
| 419 |
@@ -47,7 +47,7 @@ TRACE_LOADGEN_STAGGER_MAX = 60 |
| 420 |
# |
| 421 |
MOUNTDIR=os.path.join(RUNNING_TRACE_DIR, 'mnt') |
| 422 |
WORKLOADFILES_ROOT=os.path.join(NFSOMETER_DIR, 'workload_files') |
| 423 |
-RESULTS_DIR=os.path.join(posix.environ['HOME'], 'nfsometer_results') |
| 424 |
+RESULTS_DIR=os.path.join(os.environ['HOME'], 'nfsometer_results') |
| 425 |
HOSTNAME=socket.getfqdn() |
| 426 |
RUNROOT='%s/nfsometer_runroot_%s' % (MOUNTDIR, HOSTNAME) |
| 427 |
HTML_DIR="%s/html" % NFSOMETERLIB_DIR |
| 428 |
@@ -139,7 +139,7 @@ TEMPLATE_REPORTINFO='%s/report_info.html |
| 429 |
_TEMPLATE_CACHE={} |
| 430 |
def html_template(filename): |
| 431 |
global _TEMPLATE_CACHE |
| 432 |
- if not _TEMPLATE_CACHE.has_key(filename): |
| 433 |
+ if filename not in _TEMPLATE_CACHE: |
| 434 |
_TEMPLATE_CACHE[filename] = Template(filename=filename) |
| 435 |
return _TEMPLATE_CACHE[filename] |
| 436 |
|
| 437 |
@@ -244,7 +244,7 @@ def groups_by_nfsvers(groups): |
| 438 |
gmap = {} |
| 439 |
for g in groups: |
| 440 |
vers = mountopts_version(g.mountopt) |
| 441 |
- if not gmap.has_key(vers): |
| 442 |
+ if vers not in gmap: |
| 443 |
gmap[vers] = [] |
| 444 |
gmap[vers].append(g) |
| 445 |
return gmap |
| 446 |
--- nfsometer-1.9.orig/nfsometerlib/graph.py |
| 447 |
+++ nfsometer-1.9/nfsometerlib/graph.py |
| 448 |
@@ -11,15 +11,15 @@ ANY WARRANTY; without even the implied w |
| 449 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 450 |
""" |
| 451 |
|
| 452 |
-#!/usr/bin/env python |
| 453 |
+#!/usr/bin/env python3 |
| 454 |
|
| 455 |
import multiprocessing |
| 456 |
-import cPickle |
| 457 |
-import os, sys, time |
| 458 |
+import pickle as cPickle |
| 459 |
+import os, sys, time, errno |
| 460 |
|
| 461 |
-from collection import * |
| 462 |
-from config import * |
| 463 |
-import selector |
| 464 |
+from .collection import * |
| 465 |
+from .config import * |
| 466 |
+from . import selector |
| 467 |
|
| 468 |
_GRAPH_COLLECTION = None |
| 469 |
|
| 470 |
@@ -52,8 +52,8 @@ class GraphFactory: |
| 471 |
|
| 472 |
try: |
| 473 |
os.mkdir(self.imagedir) |
| 474 |
- except OSError, e: |
| 475 |
- assert e.errno == os.errno.EEXIST |
| 476 |
+ except OSError as e: |
| 477 |
+ assert e.errno == errno.EEXIST |
| 478 |
|
| 479 |
self._entries = set(os.listdir(imagedir)) |
| 480 |
|
| 481 |
@@ -104,8 +104,8 @@ class GraphFactory: |
| 482 |
if classes: |
| 483 |
other_attrs.append('class="%s"' % ' '.join(classes)) |
| 484 |
|
| 485 |
- if attrs.has_key('groups'): |
| 486 |
- if not attrs.has_key('gmap'): |
| 487 |
+ if 'groups' in attrs: |
| 488 |
+ if 'gmap' not in attrs: |
| 489 |
attrs['gmap'] = groups_by_nfsvers(attrs['groups']) |
| 490 |
gmap = attrs['gmap'] |
| 491 |
|
| 492 |
@@ -116,7 +116,7 @@ class GraphFactory: |
| 493 |
cur = 0 |
| 494 |
sub_src = [] |
| 495 |
for vers in NFS_VERSIONS: |
| 496 |
- if not gmap.has_key(vers): |
| 497 |
+ if vers not in gmap: |
| 498 |
continue |
| 499 |
|
| 500 |
assert cur < num |
| 501 |
@@ -288,26 +288,26 @@ class GraphFactory: |
| 502 |
|
| 503 |
inform('\rGraph Summary: ') |
| 504 |
if self.gen_count: |
| 505 |
- print ' %u images generated' % self.gen_count |
| 506 |
+ print(' %u images generated' % self.gen_count) |
| 507 |
if self.cached_count: |
| 508 |
- print ' %u cached images' % self.cached_count |
| 509 |
+ print(' %u cached images' % self.cached_count) |
| 510 |
if self.prune_count: |
| 511 |
- print ' %u files pruned' % self.prune_count |
| 512 |
+ print(' %u files pruned' % self.prune_count) |
| 513 |
|
| 514 |
def _fmt_data(x, scale): |
| 515 |
assert not isinstance(x, (list, tuple)) |
| 516 |
- if isinstance(x, Stat): |
| 517 |
+ if isinstance(x, Stat) or type(x).__name__ == 'Stat': |
| 518 |
return x.mean() / scale, x.std() / scale |
| 519 |
|
| 520 |
# disallow? |
| 521 |
- elif isinstance(x, (float, int, long)): |
| 522 |
+ elif isinstance(x, (float, int)): |
| 523 |
return x, 0.0 |
| 524 |
|
| 525 |
elif x == None: |
| 526 |
# when graphing, no data can just be zero |
| 527 |
return 0.0, 0.0 |
| 528 |
|
| 529 |
- raise ValueError('Unexpected data type for %r' % (val,)) |
| 530 |
+ raise ValueError('Unexpected data type for %r' % (x,)) |
| 531 |
|
| 532 |
def _graphize_units(units): |
| 533 |
if not units: |
| 534 |
@@ -321,7 +321,7 @@ def graph_cb_wrapper(graph_f, imgfile, a |
| 535 |
graph_f(imgfile, attrs) |
| 536 |
except KeyboardInterrupt: |
| 537 |
return False |
| 538 |
- except Exception, e: |
| 539 |
+ except Exception as e: |
| 540 |
return e |
| 541 |
return True |
| 542 |
|
| 543 |
@@ -365,7 +365,7 @@ def make_bargraph_cb(imgfile, attrs): |
| 544 |
ax1 = fig.add_subplot(111) |
| 545 |
ax1.set_autoscale_on(True) |
| 546 |
ax1.autoscale_view(True,True,True) |
| 547 |
- for i in ax1.spines.itervalues(): |
| 548 |
+ for i in ax1.spines.values(): |
| 549 |
i.set_linewidth(0.0) |
| 550 |
|
| 551 |
# width of bars within a group |
| 552 |
@@ -409,14 +409,14 @@ def make_bargraph_cb(imgfile, attrs): |
| 553 |
|
| 554 |
val = vals[g].get(key, None) |
| 555 |
hidx = 0 # default hatch |
| 556 |
- if isinstance(val, Bucket): |
| 557 |
+ if isinstance(val, Bucket) or type(val).__name__ == 'Bucket': |
| 558 |
for s in val.foreach(): |
| 559 |
x_v, x_s = _fmt_data(s, scale) |
| 560 |
hidx = hatch_map[s.name] |
| 561 |
|
| 562 |
- assert not valmap[key].has_key(hidx), \ |
| 563 |
+ assert hidx not in valmap[key], \ |
| 564 |
'%u, %r' % (hidx, val) |
| 565 |
- assert not errmap[key].has_key(hidx), \ |
| 566 |
+ assert hidx not in errmap[key], \ |
| 567 |
'%u, %r' % (hidx, val) |
| 568 |
valmap[key][hidx] = x_v |
| 569 |
errmap[key][hidx] = x_s |
| 570 |
@@ -496,7 +496,7 @@ def make_legend_cb(imgfile, attr): |
| 571 |
ax1 = fig.add_subplot(111) |
| 572 |
ax1.set_autoscale_on(True) |
| 573 |
ax1.autoscale_view(True,True,True) |
| 574 |
- for i in ax1.spines.itervalues(): |
| 575 |
+ for i in ax1.spines.values(): |
| 576 |
i.set_linewidth(0.0) |
| 577 |
|
| 578 |
ax1.get_xaxis().set_visible(False) |
| 579 |
--- nfsometer-1.9.orig/nfsometerlib/options.py |
| 580 |
+++ nfsometer-1.9/nfsometerlib/options.py |
| 581 |
@@ -14,8 +14,9 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 582 |
import os, posix, sys |
| 583 |
import getopt |
| 584 |
import re |
| 585 |
+#import six |
| 586 |
|
| 587 |
-from config import * |
| 588 |
+from .config import * |
| 589 |
|
| 590 |
_progname = sys.argv[0] |
| 591 |
|
| 592 |
@@ -356,7 +357,7 @@ Example 8: Long running nfsometer trace |
| 593 |
try: |
| 594 |
opts, args = getopt.getopt(sys.argv[1:], shortstr, longlist) |
| 595 |
|
| 596 |
- except getopt.GetoptError, err: |
| 597 |
+ except getopt.GetoptError as err: |
| 598 |
self.usage(str(err)) |
| 599 |
|
| 600 |
# parse options |
| 601 |
@@ -464,7 +465,7 @@ Example 8: Long running nfsometer trace |
| 602 |
for x in mountopts: |
| 603 |
try: |
| 604 |
vers = mountopts_version(x) |
| 605 |
- except ValueError, e: |
| 606 |
+ except ValueError as e: |
| 607 |
self.usage(str(e)) |
| 608 |
self.mountopts.append(x) |
| 609 |
|
| 610 |
@@ -490,7 +491,7 @@ Example 8: Long running nfsometer trace |
| 611 |
err = False |
| 612 |
for name in ('NFSOMETER_CMD', 'NFSOMETER_NAME', 'NFSOMETER_DESC',): |
| 613 |
if not name in posix.environ: |
| 614 |
- print >>sys.stderr, "%s not set" % name |
| 615 |
+ print("%s not set" % name, file=sys.stderr) |
| 616 |
err = True |
| 617 |
|
| 618 |
if err: |
| 619 |
@@ -564,10 +565,9 @@ Example 8: Long running nfsometer trace |
| 620 |
return lines |
| 621 |
|
| 622 |
def error(self, msg=''): |
| 623 |
- print >>sys.stderr, msg |
| 624 |
- print >>sys.stderr, \ |
| 625 |
- '\nrun "%s --help" and "%s examples" for more info' % \ |
| 626 |
- (_progname, _progname) |
| 627 |
+ print(msg, file=sys.stderr) |
| 628 |
+ print('\nrun "%s --help" and "%s examples" for more info' % \ |
| 629 |
+ (_progname, _progname), file=sys.stderr) |
| 630 |
sys.stderr.flush() |
| 631 |
sys.exit(1) |
| 632 |
|
| 633 |
@@ -593,19 +593,19 @@ Example 8: Long running nfsometer trace |
| 634 |
return self._synopsis_fmt % script |
| 635 |
|
| 636 |
def examples(self): |
| 637 |
- print >>sys.stdout, self._examples() |
| 638 |
+ print(self._examples()) |
| 639 |
|
| 640 |
def usage(self, msg=''): |
| 641 |
- print >>sys.stderr, "usage: %s" % self._synopsis(_progname) |
| 642 |
- print >>sys.stderr, self._modes_description(_progname) |
| 643 |
+ print("usage: %s" % self._synopsis(_progname), file=sys.stderr) |
| 644 |
+ print(self._modes_description(_progname), file=sys.stderr) |
| 645 |
|
| 646 |
- print >>sys.stderr |
| 647 |
- print >>sys.stderr, "Options:" |
| 648 |
- print >>sys.stderr, ' %s' % '\n '.join(self._option_help()) |
| 649 |
+ print("", file=sys.stderr) |
| 650 |
+ print("Options:", file=sys.stderr) |
| 651 |
+ print(' %s' % '\n '.join(self._option_help()), file=sys.stderr) |
| 652 |
|
| 653 |
if msg: |
| 654 |
- print >>sys.stderr |
| 655 |
- print >>sys.stderr, "Error: " + msg |
| 656 |
+ print('', file=sys.stderr) |
| 657 |
+ print("Error: " + msg, file=sys.stderr); |
| 658 |
|
| 659 |
sys.exit(1) |
| 660 |
|
| 661 |
@@ -635,5 +635,6 @@ Example 8: Long running nfsometer trace |
| 662 |
for i in range(len(o)): |
| 663 |
o[i] = o[i].strip().replace('-', '\\-') |
| 664 |
|
| 665 |
- file(output_path, 'w+').write('\n'.join(o)) |
| 666 |
+ with open(output_path, 'w+') as f: |
| 667 |
+ f.write('\n'.join(o)) |
| 668 |
|
| 669 |
--- nfsometer-1.9.orig/nfsometerlib/parse.py |
| 670 |
+++ nfsometer-1.9/nfsometerlib/parse.py |
| 671 |
@@ -13,8 +13,9 @@ FOR A PARTICULAR PURPOSE. See the GNU Ge |
| 672 |
|
| 673 |
import os |
| 674 |
import re |
| 675 |
+#import six |
| 676 |
|
| 677 |
-from config import * |
| 678 |
+from .config import * |
| 679 |
|
| 680 |
# |
| 681 |
# Regular Expressions section |
| 682 |
@@ -113,7 +114,7 @@ class BucketDef: |
| 683 |
return r |
| 684 |
|
| 685 |
def add_key(self, bucket_name, key, display): |
| 686 |
- if self._key2bucket.has_key(key) or key in self._other_keys: |
| 687 |
+ if key in self._key2bucket or key in self._other_keys: |
| 688 |
return |
| 689 |
|
| 690 |
if display: |
| 691 |
@@ -189,7 +190,7 @@ nfsstat_op_map_def = { |
| 692 |
), |
| 693 |
} |
| 694 |
nfsstat_op_map = {} |
| 695 |
-for b, ops in nfsstat_op_map_def.iteritems(): |
| 696 |
+for b, ops in nfsstat_op_map_def.items(): |
| 697 |
for o in ops: |
| 698 |
nfsstat_op_map[o] = b |
| 699 |
|
| 700 |
@@ -245,7 +246,7 @@ mountstat_op_map_def = { |
| 701 |
} |
| 702 |
|
| 703 |
mountstat_op_map = {} |
| 704 |
-for b, ops in mountstat_op_map_def.iteritems(): |
| 705 |
+for b, ops in mountstat_op_map_def.items(): |
| 706 |
for o in ops: |
| 707 |
mountstat_op_map[o] = b |
| 708 |
|
| 709 |
@@ -299,7 +300,7 @@ def parse_tracedir(collection, tracestat |
| 710 |
|
| 711 |
try: |
| 712 |
p(tracestat, tracedir, attrs) |
| 713 |
- except Exception, e: |
| 714 |
+ except Exception as e: |
| 715 |
collection.warn(tracedir, str(e)) |
| 716 |
|
| 717 |
|
| 718 |
@@ -310,7 +311,7 @@ def parse_time(tracestat, tracedir, attr |
| 719 |
|
| 720 |
path = os.path.join(tracedir, filename) |
| 721 |
|
| 722 |
- lines = [ x.strip() for x in file(path) if x.strip() ] |
| 723 |
+ lines = [ x.strip() for x in open(path) if x.strip() ] |
| 724 |
assert len(lines) == 3 |
| 725 |
|
| 726 |
def _parse_time(minutes, seconds): |
| 727 |
@@ -376,8 +377,7 @@ def parse_mountstats(tracestat, tracedir |
| 728 |
|
| 729 |
path = os.path.join(tracedir, filename) |
| 730 |
|
| 731 |
- f = file(path) |
| 732 |
- |
| 733 |
+ f = open(path) |
| 734 |
for line in f: |
| 735 |
found = False |
| 736 |
|
| 737 |
@@ -388,7 +388,7 @@ def parse_mountstats(tracestat, tracedir |
| 738 |
|
| 739 |
m = RE['ms_read_norm'].match(line) |
| 740 |
if m: |
| 741 |
- val = long(m.group(1)) |
| 742 |
+ val = int(m.group(1)) |
| 743 |
tracestat.add_stat(prefix + 'read_normal', |
| 744 |
val, 'B', |
| 745 |
'Bytes read through the read() syscall', |
| 746 |
@@ -400,7 +400,7 @@ def parse_mountstats(tracestat, tracedir |
| 747 |
|
| 748 |
m = RE['ms_write_norm'].match(line) |
| 749 |
if m: |
| 750 |
- val = long(m.group(1)) |
| 751 |
+ val = int(m.group(1)) |
| 752 |
tracestat.add_stat(prefix + 'write_normal', |
| 753 |
val, 'B', |
| 754 |
'Bytes written through write() syscall', |
| 755 |
@@ -412,7 +412,7 @@ def parse_mountstats(tracestat, tracedir |
| 756 |
|
| 757 |
m = RE['ms_read_odir'].match(line) |
| 758 |
if m: |
| 759 |
- val = long(m.group(1)) |
| 760 |
+ val = int(m.group(1)) |
| 761 |
tracestat.add_stat(prefix + 'read_odirect', |
| 762 |
val, 'B', |
| 763 |
'Bytes read through read(O_DIRECT) syscall', |
| 764 |
@@ -424,7 +424,7 @@ def parse_mountstats(tracestat, tracedir |
| 765 |
|
| 766 |
m = RE['ms_write_odir'].match(line) |
| 767 |
if m: |
| 768 |
- val = long(m.group(1)) |
| 769 |
+ val = int(m.group(1)) |
| 770 |
tracestat.add_stat(prefix + 'write_odirect', |
| 771 |
val, 'B', |
| 772 |
'Bytes written through write(O_DIRECT) syscall', |
| 773 |
@@ -436,7 +436,7 @@ def parse_mountstats(tracestat, tracedir |
| 774 |
|
| 775 |
m = RE['ms_read_nfs'].match(line) |
| 776 |
if m: |
| 777 |
- val = long(m.group(1)) |
| 778 |
+ val = int(m.group(1)) |
| 779 |
tracestat.add_stat(prefix + 'read_nfs', |
| 780 |
val, 'B', |
| 781 |
'Bytes read via NFS RPCs', |
| 782 |
@@ -448,7 +448,7 @@ def parse_mountstats(tracestat, tracedir |
| 783 |
|
| 784 |
m = RE['ms_write_nfs'].match(line) |
| 785 |
if m: |
| 786 |
- val = long(m.group(1)) |
| 787 |
+ val = int(m.group(1)) |
| 788 |
tracestat.add_stat(prefix + 'write_nfs', |
| 789 |
val, 'B', |
| 790 |
'Bytes written via NFS RPCs', |
| 791 |
@@ -461,21 +461,21 @@ def parse_mountstats(tracestat, tracedir |
| 792 |
m = RE['ms_rpc_line'].match(line) |
| 793 |
if m: |
| 794 |
tracestat.add_stat(prefix + 'rpc_requests', |
| 795 |
- long(m.group(1)), 'RPCs', |
| 796 |
+ int(m.group(1)), 'RPCs', |
| 797 |
'Count of RPC requests', |
| 798 |
BETTER_LESS_IF_IO_BOUND, |
| 799 |
None, |
| 800 |
filename, |
| 801 |
tracedir) |
| 802 |
tracestat.add_stat(prefix + 'rpc_replies', |
| 803 |
- long(m.group(2)), 'RPCs', |
| 804 |
+ int(m.group(2)), 'RPCs', |
| 805 |
'Count of RPC replies', |
| 806 |
BETTER_LESS_IF_IO_BOUND, |
| 807 |
None, |
| 808 |
filename, |
| 809 |
tracedir) |
| 810 |
tracestat.add_stat(prefix + 'xid_not_found', |
| 811 |
- long(m.group(3)), 'RPCs', |
| 812 |
+ int(m.group(3)), 'RPCs', |
| 813 |
'Count of RPC replies that couldn\'t be matched ' + |
| 814 |
'with a request', |
| 815 |
BETTER_ALWAYS_LESS, |
| 816 |
@@ -487,7 +487,7 @@ def parse_mountstats(tracestat, tracedir |
| 817 |
m = RE['ms_rpc_backlog'].match(line) |
| 818 |
if m: |
| 819 |
tracestat.add_stat(prefix + 'backlog_queue_avg', |
| 820 |
- long(m.group(1)), 'RPCs', |
| 821 |
+ int(m.group(1)), 'RPCs', |
| 822 |
'Average number of outgoing requests on the backlog ' + |
| 823 |
'queue', |
| 824 |
BETTER_ALWAYS_LESS, |
| 825 |
@@ -500,9 +500,10 @@ def parse_mountstats(tracestat, tracedir |
| 826 |
op = None |
| 827 |
oplineno = 0 |
| 828 |
for line in f: |
| 829 |
- m = RE['ms_ops_header'].match(line.strip()) |
| 830 |
+ ls = line.strip() |
| 831 |
+ m = RE['ms_ops_header'].match(ls) |
| 832 |
if m: |
| 833 |
- assert op == None |
| 834 |
+ #assert op is None,"failed op==None, m==%s" % m |
| 835 |
op = m.group(1) |
| 836 |
op_bucket = mountstat_op_map.get(op, BUCKET_OTHER) |
| 837 |
oplineno = 1 |
| 838 |
@@ -511,7 +512,7 @@ def parse_mountstats(tracestat, tracedir |
| 839 |
if oplineno == 1: |
| 840 |
m = RE['ms_ops_line1'].match(line) |
| 841 |
if m: |
| 842 |
- assert op != None |
| 843 |
+ assert op is not None,"failed op != None" |
| 844 |
oplineno += 1 |
| 845 |
continue |
| 846 |
|
| 847 |
@@ -563,6 +564,8 @@ def parse_mountstats(tracestat, tracedir |
| 848 |
elif op: |
| 849 |
raise ParseError("Didn't match line: %s" % line) |
| 850 |
|
| 851 |
+ f.close() |
| 852 |
+ |
| 853 |
def parse_nfsiostat(tracestat, tracedir, attrs): |
| 854 |
prefix = 'nfsiostat:' |
| 855 |
stat_desc = 'output of nfsiostat(1)' |
| 856 |
@@ -570,7 +573,7 @@ def parse_nfsiostat(tracestat, tracedir, |
| 857 |
|
| 858 |
path = os.path.join(tracedir, filename) |
| 859 |
|
| 860 |
- lines = file(path).readlines() |
| 861 |
+ lines = open(path).readlines() |
| 862 |
|
| 863 |
# skip until we find our mount |
| 864 |
name=None |
| 865 |
@@ -656,7 +659,7 @@ def parse_nfsstats(tracestat, tracedir, |
| 866 |
|
| 867 |
path = os.path.join(tracedir, filename) |
| 868 |
|
| 869 |
- lines = file(path).readlines() |
| 870 |
+ lines = open(path).readlines() |
| 871 |
|
| 872 |
m = RE['ns_rpc_title'].match(lines[0]) |
| 873 |
|
| 874 |
@@ -675,7 +678,7 @@ def parse_nfsstats(tracestat, tracedir, |
| 875 |
raise ParseError("Can't find RPC call count") |
| 876 |
|
| 877 |
tracestat.add_stat(prefix + 'rpc_calls', |
| 878 |
- long(m.group(1)), 'Calls', |
| 879 |
+ int(m.group(1)), 'Calls', |
| 880 |
'Count of RPC calls', |
| 881 |
BETTER_LESS_IF_IO_BOUND, |
| 882 |
None, |
| 883 |
@@ -709,12 +712,12 @@ def parse_nfsstats(tracestat, tracedir, |
| 884 |
m = RE['ns_count_data'].match(line) |
| 885 |
if m: |
| 886 |
for i, t in enumerate(titles): |
| 887 |
- assert not op_counts.has_key(t), "dup op count %s" % t |
| 888 |
- op_counts[t] = long(m.group(i+1)) |
| 889 |
+ assert t not in op_counts, "dup op count %s" % t |
| 890 |
+ op_counts[t] = int(m.group(i+1)) |
| 891 |
|
| 892 |
titles = None |
| 893 |
|
| 894 |
- for op, count in op_counts.iteritems(): |
| 895 |
+ for op, count in op_counts.items(): |
| 896 |
if count: |
| 897 |
op_bucket = nfsstat_op_map.get(op, BUCKET_OTHER) |
| 898 |
tracestat.add_stat(prefix + op.upper() + ' Count', |
| 899 |
@@ -734,7 +737,8 @@ def parse_filebench(tracestat, tracedir, |
| 900 |
|
| 901 |
# NOTE: BETTER_* based on fact that filebench output is only ever time bound |
| 902 |
found = False |
| 903 |
- for line in file(path): |
| 904 |
+ with open(path) as f: |
| 905 |
+ for line in f: |
| 906 |
m = RE['filebench_stats'].match(line) |
| 907 |
if m: |
| 908 |
tracestat.add_stat(prefix + 'op_count', |
| 909 |
@@ -784,16 +788,15 @@ def parse_proc_mountstats(tracestat, tra |
| 910 |
|
| 911 |
path = os.path.join(tracedir, filename) |
| 912 |
|
| 913 |
- f = file(path) |
| 914 |
- |
| 915 |
- found = False |
| 916 |
- for line in f: |
| 917 |
+ with open(path) as f: |
| 918 |
+ found = False |
| 919 |
+ for line in f: |
| 920 |
m = RE['pms_events'].match(line) |
| 921 |
if m: |
| 922 |
found = True |
| 923 |
|
| 924 |
tracestat.add_stat(prefix + 'inode_revalidate', |
| 925 |
- long(m.group(1)), 'events', |
| 926 |
+ int(m.group(1)), 'events', |
| 927 |
'Count of inode_revalidate events', |
| 928 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 929 |
None, |
| 930 |
@@ -801,7 +804,7 @@ def parse_proc_mountstats(tracestat, tra |
| 931 |
tracedir) |
| 932 |
|
| 933 |
tracestat.add_stat(prefix + 'dentry_revalidate', |
| 934 |
- long(m.group(2)), 'events', |
| 935 |
+ int(m.group(2)), 'events', |
| 936 |
'Count of dentry_revalidate events', |
| 937 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 938 |
None, |
| 939 |
@@ -809,7 +812,7 @@ def parse_proc_mountstats(tracestat, tra |
| 940 |
tracedir) |
| 941 |
|
| 942 |
tracestat.add_stat(prefix + 'data_invalidate', |
| 943 |
- long(m.group(3)), 'events', |
| 944 |
+ int(m.group(3)), 'events', |
| 945 |
'Count of data_invalidate events', |
| 946 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 947 |
None, |
| 948 |
@@ -817,7 +820,7 @@ def parse_proc_mountstats(tracestat, tra |
| 949 |
tracedir) |
| 950 |
|
| 951 |
tracestat.add_stat(prefix + 'attr_invalidate', |
| 952 |
- long(m.group(4)), 'events', |
| 953 |
+ int(m.group(4)), 'events', |
| 954 |
'Count of attr_invalidate events', |
| 955 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 956 |
None, |
| 957 |
@@ -825,7 +828,7 @@ def parse_proc_mountstats(tracestat, tra |
| 958 |
tracedir) |
| 959 |
|
| 960 |
tracestat.add_stat(prefix + 'vfs_open', |
| 961 |
- long(m.group(5)), 'events', |
| 962 |
+ int(m.group(5)), 'events', |
| 963 |
'Count of file and directory opens', |
| 964 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 965 |
None, |
| 966 |
@@ -833,7 +836,7 @@ def parse_proc_mountstats(tracestat, tra |
| 967 |
tracedir) |
| 968 |
|
| 969 |
tracestat.add_stat(prefix + 'vfs_lookup', |
| 970 |
- long(m.group(6)), 'events', |
| 971 |
+ int(m.group(6)), 'events', |
| 972 |
'Count of lookups', |
| 973 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 974 |
None, |
| 975 |
@@ -841,7 +844,7 @@ def parse_proc_mountstats(tracestat, tra |
| 976 |
tracedir) |
| 977 |
|
| 978 |
tracestat.add_stat(prefix + 'vfs_access', |
| 979 |
- long(m.group(7)), 'events', |
| 980 |
+ int(m.group(7)), 'events', |
| 981 |
'Count of access calls', |
| 982 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 983 |
None, |
| 984 |
@@ -849,7 +852,7 @@ def parse_proc_mountstats(tracestat, tra |
| 985 |
tracedir) |
| 986 |
|
| 987 |
tracestat.add_stat(prefix + 'vfs_updatepage', |
| 988 |
- long(m.group(8)), 'events', |
| 989 |
+ int(m.group(8)), 'events', |
| 990 |
'Count of updatepage calls', |
| 991 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 992 |
None, |
| 993 |
@@ -857,7 +860,7 @@ def parse_proc_mountstats(tracestat, tra |
| 994 |
tracedir) |
| 995 |
|
| 996 |
tracestat.add_stat(prefix + 'vfs_readpage', |
| 997 |
- long(m.group(9)), 'events', |
| 998 |
+ int(m.group(9)), 'events', |
| 999 |
'Count of readpage calls', |
| 1000 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1001 |
None, |
| 1002 |
@@ -865,7 +868,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1003 |
tracedir) |
| 1004 |
|
| 1005 |
tracestat.add_stat(prefix + 'vfs_readpages', |
| 1006 |
- long(m.group(10)), 'events', |
| 1007 |
+ int(m.group(10)), 'events', |
| 1008 |
'Count of readpages calls', |
| 1009 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1010 |
None, |
| 1011 |
@@ -873,7 +876,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1012 |
tracedir) |
| 1013 |
|
| 1014 |
tracestat.add_stat(prefix + 'vfs_writepage', |
| 1015 |
- long(m.group(11)), 'events', |
| 1016 |
+ int(m.group(11)), 'events', |
| 1017 |
'Count of writepage calls', |
| 1018 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1019 |
None, |
| 1020 |
@@ -881,7 +884,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1021 |
tracedir) |
| 1022 |
|
| 1023 |
tracestat.add_stat(prefix + 'vfs_writepages', |
| 1024 |
- long(m.group(12)), 'events', |
| 1025 |
+ int(m.group(12)), 'events', |
| 1026 |
'Count of writepages calls', |
| 1027 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1028 |
None, |
| 1029 |
@@ -889,7 +892,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1030 |
tracedir) |
| 1031 |
|
| 1032 |
tracestat.add_stat(prefix + 'vfs_getdents', |
| 1033 |
- long(m.group(13)), 'events', |
| 1034 |
+ int(m.group(13)), 'events', |
| 1035 |
'Count of getdents calls', |
| 1036 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1037 |
None, |
| 1038 |
@@ -897,7 +900,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1039 |
tracedir) |
| 1040 |
|
| 1041 |
tracestat.add_stat(prefix + 'vfs_setattr', |
| 1042 |
- long(m.group(14)), 'events', |
| 1043 |
+ int(m.group(14)), 'events', |
| 1044 |
'Count of setattr calls', |
| 1045 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1046 |
None, |
| 1047 |
@@ -905,7 +908,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1048 |
tracedir) |
| 1049 |
|
| 1050 |
tracestat.add_stat(prefix + 'vfs_flush', |
| 1051 |
- long(m.group(15)), 'events', |
| 1052 |
+ int(m.group(15)), 'events', |
| 1053 |
'Count of flush calls', |
| 1054 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1055 |
None, |
| 1056 |
@@ -913,7 +916,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1057 |
tracedir) |
| 1058 |
|
| 1059 |
tracestat.add_stat(prefix + 'vfs_fsync', |
| 1060 |
- long(m.group(16)), 'events', |
| 1061 |
+ int(m.group(16)), 'events', |
| 1062 |
'Count of fsync calls', |
| 1063 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1064 |
None, |
| 1065 |
@@ -921,7 +924,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1066 |
tracedir) |
| 1067 |
|
| 1068 |
tracestat.add_stat(prefix + 'vfs_lock', |
| 1069 |
- long(m.group(17)), 'events', |
| 1070 |
+ int(m.group(17)), 'events', |
| 1071 |
'Count of lock calls', |
| 1072 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1073 |
None, |
| 1074 |
@@ -929,7 +932,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1075 |
tracedir) |
| 1076 |
|
| 1077 |
tracestat.add_stat(prefix + 'vfs_release', |
| 1078 |
- long(m.group(18)), 'events', |
| 1079 |
+ int(m.group(18)), 'events', |
| 1080 |
'Count of release calls', |
| 1081 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1082 |
None, |
| 1083 |
@@ -937,7 +940,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1084 |
tracedir) |
| 1085 |
|
| 1086 |
tracestat.add_stat(prefix + 'congestion_wait', |
| 1087 |
- long(m.group(19)), 'events', |
| 1088 |
+ int(m.group(19)), 'events', |
| 1089 |
'Count of congestion_wait', |
| 1090 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1091 |
None, |
| 1092 |
@@ -945,7 +948,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1093 |
tracedir) |
| 1094 |
|
| 1095 |
tracestat.add_stat(prefix + 'setattr_trunc', |
| 1096 |
- long(m.group(20)), 'events', |
| 1097 |
+ int(m.group(20)), 'events', |
| 1098 |
'Count of setattr_trunc', |
| 1099 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1100 |
None, |
| 1101 |
@@ -953,7 +956,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1102 |
tracedir) |
| 1103 |
|
| 1104 |
tracestat.add_stat(prefix + 'extend_write', |
| 1105 |
- long(m.group(21)), 'events', |
| 1106 |
+ int(m.group(21)), 'events', |
| 1107 |
'Count of extend_write', |
| 1108 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1109 |
None, |
| 1110 |
@@ -961,7 +964,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1111 |
tracedir) |
| 1112 |
|
| 1113 |
tracestat.add_stat(prefix + 'silly_rename', |
| 1114 |
- long(m.group(22)), 'events', |
| 1115 |
+ int(m.group(22)), 'events', |
| 1116 |
'Count of silly_rename', |
| 1117 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1118 |
None, |
| 1119 |
@@ -969,7 +972,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1120 |
tracedir) |
| 1121 |
|
| 1122 |
tracestat.add_stat(prefix + 'short_read', |
| 1123 |
- long(m.group(23)), 'events', |
| 1124 |
+ int(m.group(23)), 'events', |
| 1125 |
'Count of short_read', |
| 1126 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1127 |
None, |
| 1128 |
@@ -977,7 +980,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1129 |
tracedir) |
| 1130 |
|
| 1131 |
tracestat.add_stat(prefix + 'short_write', |
| 1132 |
- long(m.group(24)), 'events', |
| 1133 |
+ int(m.group(24)), 'events', |
| 1134 |
'Count of short_write', |
| 1135 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1136 |
None, |
| 1137 |
@@ -985,7 +988,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1138 |
tracedir) |
| 1139 |
|
| 1140 |
tracestat.add_stat(prefix + 'delay', |
| 1141 |
- long(m.group(25)), 'events', |
| 1142 |
+ int(m.group(25)), 'events', |
| 1143 |
'Count of delays (v3: JUKEBOX, v4: ERR_DELAY, grace period, key expired)', |
| 1144 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1145 |
None, |
| 1146 |
@@ -993,7 +996,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1147 |
tracedir) |
| 1148 |
|
| 1149 |
tracestat.add_stat(prefix + 'pnfs_read', |
| 1150 |
- long(m.group(26)), 'events', |
| 1151 |
+ int(m.group(26)), 'events', |
| 1152 |
'Count of pnfs_read calls', |
| 1153 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1154 |
None, |
| 1155 |
@@ -1001,7 +1004,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1156 |
tracedir) |
| 1157 |
|
| 1158 |
tracestat.add_stat(prefix + 'pnfs_write', |
| 1159 |
- long(m.group(27)), 'events', |
| 1160 |
+ int(m.group(27)), 'events', |
| 1161 |
'Count of pnfs_write calls', |
| 1162 |
BETTER_ALWAYS_LESS | BETTER_NO_VARIANCE, |
| 1163 |
None, |
| 1164 |
@@ -1016,7 +1019,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1165 |
if len(values) > 10: |
| 1166 |
# older mountstats don't have so many values |
| 1167 |
tracestat.add_stat(prefix + 'xprt_max_slots', |
| 1168 |
- long(values[10]), 'slots', |
| 1169 |
+ int(values[10]), 'slots', |
| 1170 |
'Max slots used by rpc transport', |
| 1171 |
BETTER_ALWAYS_LESS, |
| 1172 |
None, |
| 1173 |
@@ -1031,7 +1034,7 @@ def parse_proc_mountstats(tracestat, tra |
| 1174 |
if len(values) > 8: |
| 1175 |
# older mountstats don't have so many values |
| 1176 |
tracestat.add_stat(prefix + 'xprt_max_slots', |
| 1177 |
- long(values[8]), 'slots', |
| 1178 |
+ int(values[8]), 'slots', |
| 1179 |
'Max slots used by rpc transport', |
| 1180 |
BETTER_ALWAYS_LESS, |
| 1181 |
None, |
| 1182 |
@@ -1049,7 +1052,6 @@ def parse_iozone(tracestats, tracedir, a |
| 1183 |
filename = 'test.log' |
| 1184 |
|
| 1185 |
path = os.path.join(tracedir, filename) |
| 1186 |
- f = file(path) |
| 1187 |
|
| 1188 |
rpt_name = None |
| 1189 |
rpt_col_hdr = [] |
| 1190 |
@@ -1057,7 +1059,8 @@ def parse_iozone(tracestats, tracedir, a |
| 1191 |
# maps name -> (%u_%u) -> value |
| 1192 |
newkeys = [] |
| 1193 |
|
| 1194 |
- for line in f: |
| 1195 |
+ with open(path) as f: |
| 1196 |
+ for line in f: |
| 1197 |
line = line.strip() |
| 1198 |
if rpt_name: |
| 1199 |
if not line: |
| 1200 |
@@ -1097,7 +1100,7 @@ def parse_iozone(tracestats, tracedir, a |
| 1201 |
y = int(skey[-1]) |
| 1202 |
|
| 1203 |
tracestat.add_stat(prefix + key + ' iozone', |
| 1204 |
- long(value), 'KB/s', |
| 1205 |
+ int(value), 'KB/s', |
| 1206 |
'%s: size kb: %u, reclen: %u' % (report, x, y), |
| 1207 |
BETTER_ALWAYS_MORE, |
| 1208 |
(iozone_bucket_def, report + ' iozone'), |
| 1209 |
--- nfsometer-1.9.orig/nfsometerlib/report.py |
| 1210 |
+++ nfsometer-1.9/nfsometerlib/report.py |
| 1211 |
@@ -15,11 +15,11 @@ import os |
| 1212 |
from math import sqrt, pow |
| 1213 |
import time |
| 1214 |
|
| 1215 |
-import graph |
| 1216 |
-from collection import * |
| 1217 |
-from selector import Selector, SELECTOR_ORDER |
| 1218 |
-from config import * |
| 1219 |
-from workloads import * |
| 1220 |
+from . import graph |
| 1221 |
+from .collection import * |
| 1222 |
+from .selector import Selector, SELECTOR_ORDER |
| 1223 |
+from .config import * |
| 1224 |
+from .workloads import * |
| 1225 |
|
| 1226 |
ENABLE_PIE_GRAPHS=False |
| 1227 |
|
| 1228 |
@@ -238,6 +238,8 @@ class Table: |
| 1229 |
cell = val |
| 1230 |
elif isinstance(val, (Stat, Bucket)): |
| 1231 |
cell = html_fmt_value(val.mean(), val.std(), units=self.units) |
| 1232 |
+ elif type(val).__name__ == "Bucket" or type(val).__name__ == 'Stat': |
| 1233 |
+ cell = html_fmt_value(val.mean(), val.std(), units=self.units) |
| 1234 |
else: |
| 1235 |
assert val == None, "Not a string, Stat or Bucket: %r\ng = %s, k = %s" % (val, g, k) |
| 1236 |
|
| 1237 |
@@ -279,7 +281,7 @@ class WideTable: |
| 1238 |
cur = 0 |
| 1239 |
|
| 1240 |
for vers in NFS_VERSIONS: |
| 1241 |
- if not gmap.has_key(vers): |
| 1242 |
+ if vers not in gmap: |
| 1243 |
continue |
| 1244 |
|
| 1245 |
assert cur < num |
| 1246 |
@@ -392,7 +394,7 @@ class Dataset: |
| 1247 |
value_map[g] = {} |
| 1248 |
v = vals.get(g, {}).get(key, None) |
| 1249 |
if v != None: |
| 1250 |
- if isinstance(v, Bucket): |
| 1251 |
+ if isinstance(v, Bucket) or type(v).__name__ == 'Bucket': |
| 1252 |
self.all_buckets = True |
| 1253 |
for stat in v.foreach(): |
| 1254 |
value_map[g][stat.name] = stat.mean() |
| 1255 |
@@ -405,8 +407,9 @@ class Dataset: |
| 1256 |
self.bucket_pie = '' |
| 1257 |
|
| 1258 |
# does ordering matter here? |
| 1259 |
- bk_order = [ (k,v) for k, v in self.hatch_map.iteritems() ] |
| 1260 |
- bk_order.sort(lambda x,y: cmp(x[1], y[1])) |
| 1261 |
+ bk_order = [ (k,v) for k, v in self.hatch_map.items() ] |
| 1262 |
+ if bk_order: |
| 1263 |
+ bk_order.sort(key=lambda x: x[1]) |
| 1264 |
|
| 1265 |
table_values = {} |
| 1266 |
bucket_names = [] |
| 1267 |
@@ -483,7 +486,7 @@ class Dataset: |
| 1268 |
self.make_comparison_vals(vals, key, groups, select_order) |
| 1269 |
|
| 1270 |
self.gmap = groups_by_nfsvers(groups) |
| 1271 |
- self.nfs_versions = [ v for v in NFS_VERSIONS if self.gmap.has_key(v) ] |
| 1272 |
+ self.nfs_versions = [ v for v in NFS_VERSIONS if v in self.gmap ] |
| 1273 |
|
| 1274 |
# ensure the order of groups is in nfs_version order |
| 1275 |
groups = [] |
| 1276 |
@@ -549,7 +552,7 @@ class Dataset: |
| 1277 |
' style="display: none;">%s</div>' % (hits,) |
| 1278 |
|
| 1279 |
|
| 1280 |
- for compare, compvals in self.comparison_vals_map.iteritems(): |
| 1281 |
+ for compare, compvals in self.comparison_vals_map.items(): |
| 1282 |
if compvals: |
| 1283 |
c += '<div class="compare_%s" ' \ |
| 1284 |
'style="display: none;">' \ |
| 1285 |
@@ -563,7 +566,7 @@ class Dataset: |
| 1286 |
table_rows = [] |
| 1287 |
color_idx = COLORS.index(self.color_map[g]) |
| 1288 |
|
| 1289 |
- if isinstance(stat, Bucket): |
| 1290 |
+ if isinstance(stat, Bucket) or type(stat).__name__ == 'Bucket': |
| 1291 |
table_hdrs.append('run') |
| 1292 |
for x in stat.foreach(): |
| 1293 |
hidx = self.hatch_map[x.name] |
| 1294 |
@@ -585,7 +588,7 @@ class Dataset: |
| 1295 |
row = [] |
| 1296 |
row.append('<a href="%s">%s</a>' % (tracedir, run)) |
| 1297 |
|
| 1298 |
- if isinstance(stat, Bucket): |
| 1299 |
+ if isinstance(stat, Bucket) or type(stat).__name__ == 'Bucket': |
| 1300 |
for x in stat.foreach(): |
| 1301 |
row.append('<a href="%s/%s">%s</a>' % |
| 1302 |
(tracedir, stat.filename(), |
| 1303 |
@@ -619,26 +622,26 @@ class Dataset: |
| 1304 |
if stat == None: |
| 1305 |
continue |
| 1306 |
|
| 1307 |
- if isinstance(stat, Bucket): |
| 1308 |
+ if isinstance(stat, Bucket) or type(stat).__name__ == 'Bucket': |
| 1309 |
for sub in stat.foreach(): |
| 1310 |
- if not key2val.has_key(sub.name): |
| 1311 |
+ if sub.name not in key2val: |
| 1312 |
key2val[sub.name] = 0.0 |
| 1313 |
key2val[sub.name] += sub.mean() |
| 1314 |
total_val += sub.mean() |
| 1315 |
else: |
| 1316 |
# a basic Stat - makes hatch map with one entry |
| 1317 |
- if not key2val.has_key(stat.name): |
| 1318 |
+ if stat.name not in key2val: |
| 1319 |
key2val[stat.name] = 0.0 |
| 1320 |
key2val[stat.name] += stat.mean() |
| 1321 |
total_val += stat.mean() |
| 1322 |
|
| 1323 |
- ordered = [ (k, v) for k, v in key2val.iteritems() ] |
| 1324 |
- ordered.sort(lambda x,y: cmp(x[1], y[1])) |
| 1325 |
- ordered.reverse() |
| 1326 |
+ ordered = [ (k, v) for k, v in key2val.items() ] |
| 1327 |
+ if ordered: |
| 1328 |
+ ordered.sort(key=lambda x: x[1], reverse=True) |
| 1329 |
|
| 1330 |
k2h = {} |
| 1331 |
for i, kv in enumerate(ordered): |
| 1332 |
- assert not k2h.has_key(kv[0]) |
| 1333 |
+ assert kv[0] not in k2h |
| 1334 |
k2h[kv[0]] = i |
| 1335 |
|
| 1336 |
return k2h, key2val, total_val |
| 1337 |
@@ -656,7 +659,7 @@ class Dataset: |
| 1338 |
for g in groups: |
| 1339 |
idx = None |
| 1340 |
for i, cg in enumerate(compare_groups): |
| 1341 |
- if g.compare_order(cg[0], select_order) == 0: |
| 1342 |
+ if g.match_order(cg[0], select_order): |
| 1343 |
# found a group! |
| 1344 |
idx = i |
| 1345 |
break |
| 1346 |
@@ -671,7 +674,7 @@ class Dataset: |
| 1347 |
ref_val = None |
| 1348 |
ref_g = None |
| 1349 |
for g in cg: |
| 1350 |
- if not newvals.has_key(g): |
| 1351 |
+ if g not in newvals: |
| 1352 |
newvals[g] = {} |
| 1353 |
|
| 1354 |
# handle no data |
| 1355 |
@@ -727,9 +730,9 @@ class Dataset: |
| 1356 |
|
| 1357 |
def fmt_cell_hits(self, value): |
| 1358 |
classes = ('hatch_hit',) |
| 1359 |
- if isinstance(value, Bucket): |
| 1360 |
+ if isinstance(value, Bucket) or type(value).__name__ == 'Bucket': |
| 1361 |
stat_list = [ x for x in value.foreach() ] |
| 1362 |
- stat_list.sort(lambda x,y: -1 * cmp(x.mean(), y.mean())) |
| 1363 |
+ stat_list.sort(key=lambda x: x.mean(), reverse=True) |
| 1364 |
|
| 1365 |
units = self.report.collection.stat_units(value.name) |
| 1366 |
|
| 1367 |
@@ -1045,8 +1048,9 @@ class BucketWidget(Widget): |
| 1368 |
bucket_def=self.bucket_def, |
| 1369 |
units=units) |
| 1370 |
|
| 1371 |
- bucket_info = [ (k, v) for k, v in bucket_totals.iteritems() ] |
| 1372 |
- bucket_info.sort(lambda x, y: cmp(x[1], y[1]) * -1) |
| 1373 |
+ bucket_info = [ (k, v) for k, v in bucket_totals.items() ] |
| 1374 |
+ if bucket_info: |
| 1375 |
+ bucket_info.sort(key=lambda x: x[1], reverse=True) |
| 1376 |
|
| 1377 |
bucket_info = [ x for x in bucket_info if x[1] ] |
| 1378 |
|
| 1379 |
@@ -1166,12 +1170,18 @@ class Info: |
| 1380 |
|
| 1381 |
for wsel in topsel.foreach('workload'): |
| 1382 |
workload_name = wsel.fmt('workload') |
| 1383 |
+ workload_command = '' |
| 1384 |
+ workload_description = '' |
| 1385 |
|
| 1386 |
# XXX 0? |
| 1387 |
- workload_command = \ |
| 1388 |
- self.collection.get_attr(wsel, 'workload_command')[0] |
| 1389 |
- workload_description = \ |
| 1390 |
- self.collection.get_attr(wsel, 'workload_description')[0] |
| 1391 |
+ col = self.collection |
| 1392 |
+ atr = col.get_attr(wsel, 'workload_command') |
| 1393 |
+ if atr: |
| 1394 |
+ workload_command = atr[0] |
| 1395 |
+ |
| 1396 |
+ atr = col.get_attr(wsel, 'workload_description') |
| 1397 |
+ if atr: |
| 1398 |
+ workload_description = atr[0] |
| 1399 |
|
| 1400 |
wdesc = '<span class="workload_name">%s</span>' \ |
| 1401 |
'<span class="workload_description">%s</span>' % \ |
| 1402 |
@@ -1228,7 +1238,7 @@ class Info: |
| 1403 |
if not mdt in seen_mdts: |
| 1404 |
seen_mdts.append(mdt) |
| 1405 |
|
| 1406 |
- if not mount_options.has_key(mdt): |
| 1407 |
+ if mdt not in mount_options: |
| 1408 |
mount_options[mdt] = set() |
| 1409 |
mount_options[mdt] = \ |
| 1410 |
mount_options[mdt].union(real_info['mount_options']) |
| 1411 |
@@ -1236,7 +1246,7 @@ class Info: |
| 1412 |
# lowlite (opposite of hilite) values same as prev row. |
| 1413 |
info = {} |
| 1414 |
ignore = ('runs',) |
| 1415 |
- for k in real_info.keys(): |
| 1416 |
+ for k in list(real_info.keys()): |
| 1417 |
if not k in ignore and last_info and \ |
| 1418 |
real_info[k] == last_info[k]: |
| 1419 |
info[k] = '<span class="lowlite">%s</span>' % \ |
| 1420 |
@@ -1425,14 +1435,14 @@ class ReportSet: |
| 1421 |
|
| 1422 |
def _write_report(self, r): |
| 1423 |
abs_path = os.path.join(self.reportdir, r.path) |
| 1424 |
- file(abs_path, 'w+').write(r.html()) |
| 1425 |
- print " %s" % r.path |
| 1426 |
+ with open(abs_path, 'w+') as f: |
| 1427 |
+ f.write(r.html()) |
| 1428 |
|
| 1429 |
def _write_index(self): |
| 1430 |
path = 'index.html' |
| 1431 |
abs_path = os.path.join(self.reportdir, path) |
| 1432 |
- file(abs_path, 'w+').write(self.html_index()) |
| 1433 |
- print " %s" % path |
| 1434 |
+ with open(abs_path, 'w+') as f: |
| 1435 |
+ f.write(self.html_index()) |
| 1436 |
|
| 1437 |
def _step_through_reports(self, cb_f): |
| 1438 |
for x in self.collection.selection.foreach('workload'): |
| 1439 |
--- nfsometer-1.9.orig/nfsometerlib/selector.py |
| 1440 |
+++ nfsometer-1.9/nfsometerlib/selector.py |
| 1441 |
@@ -11,7 +11,7 @@ ANY WARRANTY; without even the implied w |
| 1442 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 1443 |
""" |
| 1444 |
|
| 1445 |
-from config import * |
| 1446 |
+from .config import * |
| 1447 |
|
| 1448 |
SELECTOR_ORDER=( |
| 1449 |
'workload', |
| 1450 |
@@ -70,19 +70,29 @@ class Selector(object): |
| 1451 |
|
| 1452 |
return hash(tuple(args)) |
| 1453 |
|
| 1454 |
- def __cmp__(self, other): |
| 1455 |
+ def __eq__(self, other): |
| 1456 |
for name in SELECTOR_ORDER: |
| 1457 |
- r = cmp(getattr(self, name + 's'), getattr(other, name + 's')) |
| 1458 |
- if r: |
| 1459 |
- return r |
| 1460 |
- return 0 |
| 1461 |
+ if getattr(self, name + 's') != getattr(other, name + 's'): |
| 1462 |
+ return False |
| 1463 |
+ return True |
| 1464 |
|
| 1465 |
- def compare_order(self, other, order): |
| 1466 |
+ def __lt__(self, other): |
| 1467 |
+ return NotImplemented |
| 1468 |
+ |
| 1469 |
+ def __le__(self, other): |
| 1470 |
+ return NotImplemented |
| 1471 |
+ |
| 1472 |
+ def __gt__(self, other): |
| 1473 |
+ return NotImplemented |
| 1474 |
+ |
| 1475 |
+ def __ge__(self, other): |
| 1476 |
+ return NotImplemented |
| 1477 |
+ |
| 1478 |
+ def match_order(self, other, order): |
| 1479 |
for name in order: |
| 1480 |
- r = cmp(getattr(self, name + 's'), getattr(other, name + 's')) |
| 1481 |
- if r != 0: |
| 1482 |
- return r |
| 1483 |
- return 0 |
| 1484 |
+ if getattr(self, name + 's') != getattr(other, name + 's'): |
| 1485 |
+ return False |
| 1486 |
+ return True |
| 1487 |
|
| 1488 |
def __repr__(self): |
| 1489 |
args = [] |
| 1490 |
@@ -102,7 +112,7 @@ class Selector(object): |
| 1491 |
elif hasattr(superself, attr): |
| 1492 |
return getattr(superself, attr) |
| 1493 |
else: |
| 1494 |
- raise AttributeError, "invalid attribute: %r" % attr |
| 1495 |
+ raise AttributeError("invalid attribute: %r" % attr) |
| 1496 |
|
| 1497 |
def __add__(self, other): |
| 1498 |
new = Selector() |
| 1499 |
--- nfsometer-1.9.orig/nfsometerlib/trace.py |
| 1500 |
+++ nfsometer-1.9/nfsometerlib/trace.py |
| 1501 |
@@ -22,10 +22,10 @@ import random |
| 1502 |
import atexit |
| 1503 |
import pwd |
| 1504 |
|
| 1505 |
-from cmd import * |
| 1506 |
-from config import * |
| 1507 |
-from workloads import * |
| 1508 |
-import selector |
| 1509 |
+from .cmd import * |
| 1510 |
+from .config import * |
| 1511 |
+from .workloads import * |
| 1512 |
+from . import selector |
| 1513 |
|
| 1514 |
_server_path_v4 = re.compile('([^:]+):(\S+)') |
| 1515 |
_server_path_v6 = re.compile('(\[\S+\]):(\S+)') |
| 1516 |
@@ -70,8 +70,8 @@ class TraceAttrs: |
| 1517 |
|
| 1518 |
if not temp and not new: |
| 1519 |
try: |
| 1520 |
- f = file(self.__attrfile) |
| 1521 |
- except IOError, e: |
| 1522 |
+ f = open(self.__attrfile) |
| 1523 |
+ except IOError as e: |
| 1524 |
raise IOError('Attr file not found') |
| 1525 |
for line in f: |
| 1526 |
if line.strip(): |
| 1527 |
@@ -79,13 +79,13 @@ class TraceAttrs: |
| 1528 |
self.__attrs[name.strip()] = \ |
| 1529 |
val.strip().replace('\\n', '\n') |
| 1530 |
|
| 1531 |
- if not self.__attrs.has_key('tracedir'): |
| 1532 |
+ if 'tracedir' not in self.__attrs: |
| 1533 |
self.__attrs['tracedir'] = RUNNING_TRACE_DIR |
| 1534 |
|
| 1535 |
- if not self.__attrs.has_key('stoptime'): |
| 1536 |
+ if 'stoptime' not in self.__attrs: |
| 1537 |
self.__attrs['stoptime'] = 'ongoing' |
| 1538 |
|
| 1539 |
- if not self.__attrs.has_key('tracedir_version'): |
| 1540 |
+ if 'tracedir_version' not in self.__attrs: |
| 1541 |
if new or temp: |
| 1542 |
self.__attrs['tracedir_version'] = TRACE_DIR_VERSION |
| 1543 |
else: |
| 1544 |
@@ -101,7 +101,7 @@ class TraceAttrs: |
| 1545 |
if tracedir_vers == 1: |
| 1546 |
# move tags from separate attrs to one 'tags' attr |
| 1547 |
v1_tags = [ 'delegations_enabled', 'pnfs_enabled', 'remote' ] |
| 1548 |
- tag_names = [ x for x in self.__attrs.keys() if x in v1_tags ] |
| 1549 |
+ tag_names = [ x for x in list(self.__attrs.keys()) if x in v1_tags ] |
| 1550 |
|
| 1551 |
for name in tag_names: |
| 1552 |
assert int(self.__attrs[name]) == 1 |
| 1553 |
@@ -202,12 +202,12 @@ class TraceAttrs: |
| 1554 |
self.__attrs['tracedir_version'] = TRACE_DIR_VERSION |
| 1555 |
|
| 1556 |
def _sorted_names(self): |
| 1557 |
- names = self.__attrs.keys() |
| 1558 |
+ names = list(self.__attrs.keys()) |
| 1559 |
names.sort() |
| 1560 |
return names |
| 1561 |
|
| 1562 |
def get(self, name, *args): |
| 1563 |
- if self.__attrs.has_key(name): |
| 1564 |
+ if name in self.__attrs: |
| 1565 |
return self.__attrs[name] |
| 1566 |
|
| 1567 |
# handle optional default value |
| 1568 |
@@ -233,14 +233,14 @@ class TraceAttrs: |
| 1569 |
def write(self): |
| 1570 |
if self.__temp: |
| 1571 |
return |
| 1572 |
- f = file(self.__attrfile, 'w+') |
| 1573 |
- for k, v in self.__attrs.iteritems(): |
| 1574 |
+ with open(self.__attrfile, 'w+') as f: |
| 1575 |
+ for k, v in self.__attrs.items(): |
| 1576 |
f.write('%s = %s\n' % (k, str(v).replace('\n', '\\n'))) |
| 1577 |
|
| 1578 |
def _dir_create(): |
| 1579 |
try: |
| 1580 |
os.mkdir(RUNNING_TRACE_DIR) |
| 1581 |
- except OSError, e: |
| 1582 |
+ except OSError as e: |
| 1583 |
if e.errno == errno.EEXIST: |
| 1584 |
raise IOError('An NFS trace is already running') |
| 1585 |
raise |
| 1586 |
@@ -292,7 +292,7 @@ def _try_mount(attrs, quiet=False): |
| 1587 |
for old_syntax in (False, True): |
| 1588 |
try: |
| 1589 |
_mount(attrs, old_syntax=old_syntax) |
| 1590 |
- except Exception, e: |
| 1591 |
+ except Exception as e: |
| 1592 |
if not quiet: |
| 1593 |
sys.stdout.write('.') |
| 1594 |
sys.stdout.flush() |
| 1595 |
@@ -310,7 +310,7 @@ def _try_mount(attrs, quiet=False): |
| 1596 |
sys.stdout.flush() |
| 1597 |
|
| 1598 |
if err: |
| 1599 |
- raise e |
| 1600 |
+ raise err |
| 1601 |
|
| 1602 |
def _is_mounted(attrs): |
| 1603 |
try: |
| 1604 |
@@ -358,7 +358,7 @@ def _try_unmount(attrs, quiet=False, cle |
| 1605 |
for i in range(tries): |
| 1606 |
try: |
| 1607 |
_unmount(attrs) |
| 1608 |
- except Exception, e: |
| 1609 |
+ except Exception as e: |
| 1610 |
if not quiet: |
| 1611 |
sys.stdout.write('.') |
| 1612 |
sys.stdout.flush() |
| 1613 |
@@ -441,12 +441,12 @@ def _collect_stats(commands): |
| 1614 |
for c in commands: |
| 1615 |
stats.append(c['file']) |
| 1616 |
out = cmd(c['cmd']) |
| 1617 |
- f = file(os.path.join(RUNNING_TRACE_DIR, c['file']), 'w+') |
| 1618 |
- f.write('\n'.join(out[0])) |
| 1619 |
+ with open(os.path.join(RUNNING_TRACE_DIR, c['file']), 'w+') as f: |
| 1620 |
+ f.write('\n'.join(out[0])) |
| 1621 |
|
| 1622 |
def probe_detect(probe_trace_dir, mountopt): |
| 1623 |
lines = [ x.strip() |
| 1624 |
- for x in file(os.path.join(probe_trace_dir, |
| 1625 |
+ for x in open(os.path.join(probe_trace_dir, |
| 1626 |
'proc_mountstats.stop')) ] |
| 1627 |
|
| 1628 |
# find this mountpoint |
| 1629 |
@@ -519,7 +519,7 @@ def probe_detect(probe_trace_dir, mounto |
| 1630 |
return detect |
| 1631 |
|
| 1632 |
def _is_auth_gss(): |
| 1633 |
- lines = [ x.strip() for x in file('/proc/self/mountstats') ] |
| 1634 |
+ lines = [ x.strip() for x in open('/proc/self/mountstats') ] |
| 1635 |
mounted_on = ' mounted on %s with ' % MOUNTDIR |
| 1636 |
start = -1 |
| 1637 |
end = -1 |
| 1638 |
@@ -554,7 +554,7 @@ def _has_creds(): |
| 1639 |
|
| 1640 |
def _has_tkt(server): |
| 1641 |
princ = re.compile('nfs/' + server + '\S+$') |
| 1642 |
- lines = [ x.strip() for x in file(os.path.join(RUNNING_TRACE_DIR, |
| 1643 |
+ lines = [ x.strip() for x in open(os.path.join(RUNNING_TRACE_DIR, |
| 1644 |
'klist_user.start')) ] |
| 1645 |
for i, line in enumerate(lines): |
| 1646 |
if re.search(princ, line): |
| 1647 |
@@ -625,7 +625,7 @@ def start(mountopts, serverpath, workloa |
| 1648 |
attrs.set('server', server) |
| 1649 |
attrs.set('path', path) |
| 1650 |
attrs.set('localpath', MOUNTDIR) |
| 1651 |
- attrs.set('starttime', long(time.time())) |
| 1652 |
+ attrs.set('starttime', int(time.time())) |
| 1653 |
attrs.set('workload', workload) |
| 1654 |
attrs.set('workload_command', workload_command(workload, pretty=True)) |
| 1655 |
attrs.set('workload_description', workload_description(workload)) |
| 1656 |
@@ -655,8 +655,8 @@ def stop(resdir=None): |
| 1657 |
attrs.set('stoptime', time.time()) |
| 1658 |
attrs.write() |
| 1659 |
|
| 1660 |
- is_setup = long(attrs.get('is_setup', 0)) |
| 1661 |
- is_probe = long(attrs.get('is_probe', 0)) |
| 1662 |
+ is_setup = int(attrs.get('is_setup', 0)) |
| 1663 |
+ is_probe = int(attrs.get('is_probe', 0)) |
| 1664 |
|
| 1665 |
if not is_setup: |
| 1666 |
_save_stop_stats(attrs) |
| 1667 |
@@ -669,11 +669,11 @@ def stop(resdir=None): |
| 1668 |
if resdir != None: |
| 1669 |
cmd('mv %s %s' % (RUNNING_TRACE_DIR, resdir)) |
| 1670 |
if not is_probe: |
| 1671 |
- print 'Results copied to: %s' % (os.path.split(resdir)[-1],) |
| 1672 |
+ print('Results copied to: %s' % (os.path.split(resdir)[-1],)) |
| 1673 |
else: |
| 1674 |
cmd('rm -rf %s' % (RUNNING_TRACE_DIR)) |
| 1675 |
if not is_setup: |
| 1676 |
- print 'Results thrown away' |
| 1677 |
+ print('Results thrown away') |
| 1678 |
|
| 1679 |
def find_mounted_serverpath(mountdir): |
| 1680 |
try: |
| 1681 |
@@ -723,16 +723,16 @@ def get_trace_list(collection, resultdir |
| 1682 |
workloads[name] = obj |
| 1683 |
new.append(name) |
| 1684 |
except KeyError: |
| 1685 |
- print |
| 1686 |
+ print('') |
| 1687 |
warn('Invalid workload: "%s"' % w) |
| 1688 |
- print |
| 1689 |
- print "Available workloads:" |
| 1690 |
- print " %s" % '\n '.join(available_workloads()) |
| 1691 |
+ print('') |
| 1692 |
+ print("Available workloads:") |
| 1693 |
+ print(" %s" % '\n '.join(available_workloads())) |
| 1694 |
sys.exit(2) |
| 1695 |
workloads_requested = new |
| 1696 |
|
| 1697 |
else: |
| 1698 |
- for w, workload_obj in WORKLOADS.iteritems(): |
| 1699 |
+ for w, workload_obj in WORKLOADS.items(): |
| 1700 |
if not workload_obj.check(): |
| 1701 |
name = workload_obj.name() |
| 1702 |
workloads[name] = workload_obj |
| 1703 |
@@ -745,7 +745,7 @@ def get_trace_list(collection, resultdir |
| 1704 |
current_kernel = get_current_kernel() |
| 1705 |
client = get_current_hostname() |
| 1706 |
|
| 1707 |
- for w, workload_obj in workloads.iteritems(): |
| 1708 |
+ for w, workload_obj in workloads.items(): |
| 1709 |
for mountopt, detects, tags in mountopts_detects_tags: |
| 1710 |
sel = selector.Selector(w, current_kernel, mountopt, |
| 1711 |
detects, tags, |
| 1712 |
@@ -820,7 +820,7 @@ def probe_mounts(opts): |
| 1713 |
|
| 1714 |
try: |
| 1715 |
cmd('mkdir -p "%s"' % RUNROOT) |
| 1716 |
- except CmdErrorCode, e: |
| 1717 |
+ except CmdErrorCode as e: |
| 1718 |
msg = str.format('"mkdir -p {:s}" failed.', RUNROOT) |
| 1719 |
# try to hint why it failed |
| 1720 |
if e.code == errno.EPERM: |
| 1721 |
@@ -831,9 +831,8 @@ def probe_mounts(opts): |
| 1722 |
# and bail out right now |
| 1723 |
sys.exit(1) |
| 1724 |
|
| 1725 |
- f = file(fpath, 'w+') |
| 1726 |
- f.write('nfsometer probe to determine server features: %s' % m) |
| 1727 |
- f.close() |
| 1728 |
+ with open(fpath, 'w+') as f: |
| 1729 |
+ f.write('nfsometer probe to determine server features: %s' % m) |
| 1730 |
|
| 1731 |
# force delegation if supported |
| 1732 |
fd1 = os.open(fpath, os.O_RDWR) |
| 1733 |
@@ -869,14 +868,14 @@ def run_traces(collection, opts, fetch_o |
| 1734 |
mountopts_detects_tags, opts.num_runs, opts.server, |
| 1735 |
opts.path) |
| 1736 |
|
| 1737 |
- for w, workload_obj in workloads.iteritems(): |
| 1738 |
+ for w, workload_obj in workloads.items(): |
| 1739 |
workload_obj.fetch() |
| 1740 |
|
| 1741 |
if fetch_only: |
| 1742 |
return |
| 1743 |
|
| 1744 |
# check each workload to make sure we'll be able to run it |
| 1745 |
- for w, workload_obj in workloads.iteritems(): |
| 1746 |
+ for w, workload_obj in workloads.items(): |
| 1747 |
check_mesg = workload_obj.check() |
| 1748 |
|
| 1749 |
if check_mesg: |
| 1750 |
@@ -884,12 +883,12 @@ def run_traces(collection, opts, fetch_o |
| 1751 |
|
| 1752 |
this_trace = 0 |
| 1753 |
|
| 1754 |
- print |
| 1755 |
- print "Requested: %u workloads X %u options X %u runs = %u traces" % \ |
| 1756 |
- (len(workloads), len(mountopts_detects_tags), int(opts.num_runs), requested) |
| 1757 |
+ print('') |
| 1758 |
+ print("Requested: %u workloads X %u options X %u runs = %u traces" % \ |
| 1759 |
+ (len(workloads), len(mountopts_detects_tags), int(opts.num_runs), requested)) |
| 1760 |
if skipped: |
| 1761 |
- print "Results directory already has %u matching traces" % (skipped,) |
| 1762 |
- print "Need to run %u of %u requested traces" % (total, requested) |
| 1763 |
+ print("Results directory already has %u matching traces" % (skipped,)) |
| 1764 |
+ print("Need to run %u of %u requested traces" % (total, requested)) |
| 1765 |
|
| 1766 |
for workload_obj, mountopt, detects, tags, nruns in trace_list: |
| 1767 |
mdt = mountopt |
| 1768 |
@@ -897,8 +896,8 @@ def run_traces(collection, opts, fetch_o |
| 1769 |
mdt += ' ' + detects |
| 1770 |
if tags: |
| 1771 |
mdt += ' ' + tags |
| 1772 |
- print " %s - needs %u runs of %s" % (workload_obj.name(), nruns, mdt) |
| 1773 |
- print |
| 1774 |
+ print(" %s - needs %u runs of %s" % (workload_obj.name(), nruns, mdt)) |
| 1775 |
+ print('') |
| 1776 |
|
| 1777 |
dir_remove_old_asides() |
| 1778 |
|
| 1779 |
@@ -916,7 +915,7 @@ def run_traces(collection, opts, fetch_o |
| 1780 |
for run in range(nruns): |
| 1781 |
this_trace += 1 |
| 1782 |
|
| 1783 |
- print |
| 1784 |
+ print('') |
| 1785 |
mdt = mountopt |
| 1786 |
if detects: |
| 1787 |
mdt += ' ' + detects |
| 1788 |
@@ -925,7 +924,7 @@ def run_traces(collection, opts, fetch_o |
| 1789 |
|
| 1790 |
inform("Trace %u/%u: %u of %u for %s: %s" % |
| 1791 |
(this_trace, total, run+1, nruns, workload_obj.name(), mdt)) |
| 1792 |
- print |
| 1793 |
+ print('') |
| 1794 |
|
| 1795 |
sys.stdout.write("< SETUP WORKLOAD >\n") |
| 1796 |
sys.stdout.flush() |
| 1797 |
@@ -936,7 +935,7 @@ def run_traces(collection, opts, fetch_o |
| 1798 |
|
| 1799 |
stop() |
| 1800 |
|
| 1801 |
- print |
| 1802 |
+ print('') |
| 1803 |
|
| 1804 |
sys.stdout.write("< RUN WORKLOAD >\n") |
| 1805 |
sys.stdout.flush() |
| 1806 |
@@ -983,7 +982,7 @@ def _loadgen_pool_f(workload, num): |
| 1807 |
inform("loadgen %u: %s stop" % (num, workload)) |
| 1808 |
stop = True |
| 1809 |
|
| 1810 |
- except Exception, e: |
| 1811 |
+ except Exception as e: |
| 1812 |
warn("loadgen %u: %s error:\n%s" % (num, workload, e)) |
| 1813 |
time.sleep(1.0) |
| 1814 |
|
| 1815 |
@@ -1029,7 +1028,7 @@ def loadgen(opts): |
| 1816 |
workpool.terminate() |
| 1817 |
workpool.join() |
| 1818 |
|
| 1819 |
- except Exception, e: |
| 1820 |
+ except Exception as e: |
| 1821 |
workpool.terminate() |
| 1822 |
workpool.join() |
| 1823 |
raise e |
| 1824 |
--- nfsometer-1.9.orig/nfsometerlib/workloads.py |
| 1825 |
+++ nfsometer-1.9/nfsometerlib/workloads.py |
| 1826 |
@@ -14,15 +14,15 @@ import os |
| 1827 |
import errno |
| 1828 |
import re |
| 1829 |
|
| 1830 |
-from cmd import * |
| 1831 |
-from config import * |
| 1832 |
+from .cmd import * |
| 1833 |
+from .config import * |
| 1834 |
|
| 1835 |
_re_which = re.compile('[\s\S]*which: no (\S+) in \([\s\S]*') |
| 1836 |
|
| 1837 |
def _mkdir_quiet(path): |
| 1838 |
try: |
| 1839 |
os.mkdir(path) |
| 1840 |
- except OSError, e: |
| 1841 |
+ except OSError as e: |
| 1842 |
if e.errno != errno.EEXIST: |
| 1843 |
raise e |
| 1844 |
|
| 1845 |
@@ -94,15 +94,15 @@ class Workload: |
| 1846 |
|
| 1847 |
if not os.path.exists(url_out): |
| 1848 |
if url.startswith('git://'): |
| 1849 |
- print "Fetching git: %s" % url |
| 1850 |
+ print("Fetching git: %s" % url) |
| 1851 |
fetch_cmd = 'git clone "%s" "%s"' % (url, url_out) |
| 1852 |
else: |
| 1853 |
- print "Fetching url: %s" % url |
| 1854 |
+ print("Fetching url: %s" % url) |
| 1855 |
fetch_cmd = 'wget -O "%s" "%s"' % (url_out, url) |
| 1856 |
|
| 1857 |
try: |
| 1858 |
cmd(fetch_cmd, pass_output=True, raiseerrorout=True) |
| 1859 |
- except Exception, e: |
| 1860 |
+ except Exception as e: |
| 1861 |
cmd('rm -rf "%s"' % url_out) |
| 1862 |
finally: |
| 1863 |
if not os.path.exists(url_out): |
| 1864 |
@@ -115,7 +115,7 @@ class Workload: |
| 1865 |
assert not url and not url_out |
| 1866 |
|
| 1867 |
def check(self): |
| 1868 |
- if not self._cache.has_key('check'): |
| 1869 |
+ if not 'check' in self._cache: |
| 1870 |
res = cmd('%s check %s' % (self.script, self.defname)) |
| 1871 |
res = ', '.join([ x.strip() for x in res[0]]).strip() |
| 1872 |
self._cache['check'] = res |
| 1873 |
@@ -123,7 +123,7 @@ class Workload: |
| 1874 |
return self._cache['check'] |
| 1875 |
|
| 1876 |
def command(self): |
| 1877 |
- if not self._cache.has_key('command'): |
| 1878 |
+ if not 'command' in self._cache: |
| 1879 |
res = cmd('%s command %s' % (self.script, self.defname)) |
| 1880 |
res = '\n'.join(res[0]).strip() |
| 1881 |
assert not '\n' in res |
| 1882 |
@@ -132,7 +132,7 @@ class Workload: |
| 1883 |
return self._cache['command'] |
| 1884 |
|
| 1885 |
def description(self): |
| 1886 |
- if not self._cache.has_key('description'): |
| 1887 |
+ if not 'description' in self._cache: |
| 1888 |
res = cmd('%s description %s' % (self.script, self.defname)) |
| 1889 |
res = '\n'.join(res[0]).strip() |
| 1890 |
assert not '\n' in res |
| 1891 |
@@ -141,7 +141,7 @@ class Workload: |
| 1892 |
return self._cache['description'] |
| 1893 |
|
| 1894 |
def name(self): |
| 1895 |
- if not self._cache.has_key('name'): |
| 1896 |
+ if not 'name' in self._cache: |
| 1897 |
res = cmd('%s name %s' % (self.script, self.defname)) |
| 1898 |
res = '\n'.join(res[0]).strip() |
| 1899 |
assert not '\n' in res |
| 1900 |
@@ -150,7 +150,7 @@ class Workload: |
| 1901 |
return self._cache['name'] |
| 1902 |
|
| 1903 |
def url(self): |
| 1904 |
- if not self._cache.has_key('url'): |
| 1905 |
+ if not 'url' in self._cache: |
| 1906 |
res = cmd('%s url %s' % (self.script, self.defname)) |
| 1907 |
res = '\n'.join(res[0]).strip() |
| 1908 |
assert not '\n' in res |
| 1909 |
@@ -159,7 +159,7 @@ class Workload: |
| 1910 |
return self._cache['url'] |
| 1911 |
|
| 1912 |
def url_out(self): |
| 1913 |
- if not self._cache.has_key('url_out'): |
| 1914 |
+ if not 'url_out' in self._cache: |
| 1915 |
res = cmd('%s url_out %s' % (self.script, self.defname)) |
| 1916 |
res = '\n'.join(res[0]).strip() |
| 1917 |
assert not '\n' in res |
| 1918 |
@@ -174,14 +174,15 @@ class Workload: |
| 1919 |
|
| 1920 |
command = self.command() |
| 1921 |
|
| 1922 |
- print "Running command: %s" % command |
| 1923 |
+ print("Running command: %s" % command) |
| 1924 |
sys.stdout.flush() |
| 1925 |
|
| 1926 |
oldcwd = os.getcwd() |
| 1927 |
os.chdir(self.rundir) |
| 1928 |
|
| 1929 |
# write command to file |
| 1930 |
- file(cmdfile, 'w+').write(command) |
| 1931 |
+ with open(cmdfile, 'w+') as f: |
| 1932 |
+ f.write(command) |
| 1933 |
|
| 1934 |
sh_cmd = "sh %s > %s 2>&1" % (cmdfile, logfile) |
| 1935 |
wrapped_cmd = '( time ( %s ) ) 2> %s' % (sh_cmd, timefile) |
| 1936 |
@@ -193,7 +194,7 @@ class Workload: |
| 1937 |
# re-raise |
| 1938 |
raise KeyboardInterrupt |
| 1939 |
|
| 1940 |
- except Exception, e: |
| 1941 |
+ except Exception as e: |
| 1942 |
os.chdir(oldcwd) |
| 1943 |
# re-raise |
| 1944 |
raise e |
| 1945 |
@@ -207,14 +208,15 @@ class Workload: |
| 1946 |
cmdfile = os.path.join(self.rundir, 'command.sh') |
| 1947 |
command = self.command() |
| 1948 |
|
| 1949 |
- print "Running command without trace: %s" % command |
| 1950 |
+ print("Running command without trace: %s" % command) |
| 1951 |
sys.stdout.flush() |
| 1952 |
|
| 1953 |
oldcwd = os.getcwd() |
| 1954 |
os.chdir(self.rundir) |
| 1955 |
|
| 1956 |
# write command to file |
| 1957 |
- file(cmdfile, 'w+').write(command) |
| 1958 |
+ with open(cmdfile, 'w+') as f: |
| 1959 |
+ f.write(command) |
| 1960 |
|
| 1961 |
sh_cmd = "sh %s > %s 2>&1" % (cmdfile, logfile) |
| 1962 |
|
| 1963 |
@@ -226,7 +228,7 @@ class Workload: |
| 1964 |
# re-raise |
| 1965 |
raise KeyboardInterrupt |
| 1966 |
|
| 1967 |
- except Exception, e: |
| 1968 |
+ except Exception as e: |
| 1969 |
os.chdir(oldcwd) |
| 1970 |
# re-raise |
| 1971 |
raise e |
| 1972 |
@@ -245,7 +247,7 @@ for w in workloads: |
| 1973 |
WORKLOADS[w] = Workload(w) |
| 1974 |
|
| 1975 |
def workload_command(workload, pretty=False): |
| 1976 |
- if workload == posix.environ.get('NFSOMETER_NAME', None): |
| 1977 |
+ if workload == os.getenv('NFSOMETER_NAME', None): |
| 1978 |
workload = 'custom' |
| 1979 |
try: |
| 1980 |
obj = WORKLOADS[workload] |
| 1981 |
@@ -262,7 +264,7 @@ def workload_command(workload, pretty=Fa |
| 1982 |
return cmdstr |
| 1983 |
|
| 1984 |
def workload_description(workload): |
| 1985 |
- if workload == posix.environ.get('NFSOMETER_NAME', None): |
| 1986 |
+ if workload == os.getenv('NFSOMETER_NAME', None): |
| 1987 |
workload = 'custom' |
| 1988 |
try: |
| 1989 |
obj = WORKLOADS[workload] |
| 1990 |
@@ -273,8 +275,7 @@ def workload_description(workload): |
| 1991 |
|
| 1992 |
def available_workloads(): |
| 1993 |
o = [] |
| 1994 |
- defnames = WORKLOADS.keys() |
| 1995 |
- defnames.sort() |
| 1996 |
+ defnames = sorted( WORKLOADS.keys() ) |
| 1997 |
for defname in defnames: |
| 1998 |
check_mesg = WORKLOADS[defname].check() |
| 1999 |
|
| 2000 |
@@ -287,7 +288,7 @@ def unavailable_workloads(): |
| 2001 |
""" return a string containing a comma separated list of the available |
| 2002 |
workload """ |
| 2003 |
o = [] |
| 2004 |
- defnames = WORKLOADS.keys() |
| 2005 |
+ defnames = list(WORKLOADS.keys()) |
| 2006 |
defnames.sort() |
| 2007 |
for defname in defnames: |
| 2008 |
check_mesg = WORKLOADS[defname].check() |
| 2009 |
--- nfsometer-1.9.orig/setup.py |
| 2010 |
+++ nfsometer-1.9/setup.py |
| 2011 |
@@ -1,4 +1,4 @@ |
| 2012 |
-#!/usr/bin/env python |
| 2013 |
+#!/usr/bin/env python3 |
| 2014 |
""" |
| 2015 |
Copyright 2012 NetApp, Inc. All Rights Reserved, |
| 2016 |
contribution by Weston Andros Adamson <[email protected]> |
| 2017 |
@@ -21,7 +21,7 @@ import nfsometerlib.options |
| 2018 |
class sdist(_sdist): |
| 2019 |
def run(self): |
| 2020 |
if not self.dry_run: |
| 2021 |
- print "generating manpage %s" % NFSOMETER_MANPAGE |
| 2022 |
+ print("generating manpage %s" % NFSOMETER_MANPAGE) |
| 2023 |
o = nfsometerlib.options.Options() |
| 2024 |
o.generate_manpage(NFSOMETER_MANPAGE) |
| 2025 |
|
| 2026 |
@@ -37,7 +37,7 @@ class install(_install): |
| 2027 |
manpath = self.root + manpath |
| 2028 |
gzpath = self.root + gzpath |
| 2029 |
|
| 2030 |
- print "gzipping manpage %s" % (gzpath,) |
| 2031 |
+ print("gzipping manpage %s" % (gzpath,)) |
| 2032 |
os.system('mkdir -p %s' % manpath) |
| 2033 |
os.system('gzip -f --stdout "%s" > "%s"' % (manpage, gzpath)) |
| 2034 |
|
| 2035 |
@@ -52,7 +52,7 @@ class install(_install): |
| 2036 |
old = self.root + old |
| 2037 |
new = self.root + new |
| 2038 |
|
| 2039 |
- print "stripping .py from script %s" % (old,) |
| 2040 |
+ print("stripping .py from script %s" % (old,)) |
| 2041 |
os.rename(old, new) |
| 2042 |
|
| 2043 |
def run(self): |