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