Skip to content

Commit a670331

Browse files
committed
Python 3 support: Use print(foo) instead of print foo
1 parent 5122583 commit a670331

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

examples/simple_agent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"/SIMPLE-MIB.txt" ]
8282
)
8383
except netsnmpagent.netsnmpAgentException as e:
84-
print "{0}: {1}".format(prgname, e)
84+
print("{0}: {1}".format(prgname, e))
8585
sys.exit(1)
8686

8787
# Then we create all SNMP scalar variables we're willing to serve.
@@ -223,15 +223,15 @@
223223
try:
224224
agent.start()
225225
except netsnmpagent.netsnmpAgentException as e:
226-
print "{0}: {1}".format(prgname, e)
226+
print("{0}: {1}".format(prgname, e))
227227
sys.exit(1)
228228

229-
print "{0}: AgentX connection to snmpd established.".format(prgname)
229+
print("{0}: AgentX connection to snmpd established.".format(prgname))
230230

231231
# Helper function that dumps the state of all registered SNMP variables
232232
def DumpRegistered():
233233
for context in agent.getContexts():
234-
print "{0}: Registered SNMP objects in Context \"{1}\": ".format(prgname, context)
234+
print("{0}: Registered SNMP objects in Context \"{1}\": ".format(prgname, context))
235235
vars = agent.getRegistered(context)
236236
pprint.pprint(vars, width=columns)
237237
print
@@ -253,7 +253,7 @@ def HupHandler(signum, frame):
253253

254254
# The simple agent's main loop. We loop endlessly until our signal
255255
# handler above changes the "loop" variable.
256-
print "{0}: Serving SNMP requests, send SIGHUP to dump SNMP object state, press ^C to terminate...".format(prgname)
256+
print("{0}: Serving SNMP requests, send SIGHUP to dump SNMP object state, press ^C to terminate...".format(prgname))
257257

258258
loop = True
259259
while (loop):
@@ -271,5 +271,5 @@ def HupHandler(signum, frame):
271271
simpleCounter32Context2.increment() # By 1
272272
simpleCounter64Context2.increment(5) # By 5
273273

274-
print "{0}: Terminating.".format(prgname)
274+
print("{0}: Terminating.".format(prgname))
275275
agent.shutdown()

examples/threading_agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ def LogMsg(msg):
7373
global headerlogged
7474

7575
if headerlogged == 0:
76-
print "{0:<8} {1:<90} {2}".format(
76+
print("{0:<8} {1:<90} {2}".format(
7777
"Time",
7878
"MainThread",
7979
"UpdateSNMPObjsThread"
80-
)
81-
print "{0:-^120}".format("-")
80+
))
81+
print("{0:-^120}".format("-"))
8282
headerlogged = 1
8383

8484
threadname = threading.currentThread().name
@@ -101,7 +101,7 @@ def LogMsg(msg):
101101
time.strftime("%T", time.localtime(time.time())),
102102
"{0}: {1}".format(funcname, msg)
103103
)
104-
print logmsg
104+
print(logmsg)
105105

106106
def LogNetSnmpMsg(priority, msg):
107107
""" Log handler for log messages generated by net-snmp code. """
@@ -119,7 +119,7 @@ def LogNetSnmpMsg(priority, msg):
119119
LogHandler = LogNetSnmpMsg,
120120
)
121121
except netsnmpagent.netsnmpAgentException as e:
122-
print "{0}: {1}".format(prgname, e)
122+
print("{0}: {1}".format(prgname, e))
123123
sys.exit(1)
124124

125125
# Register the only SNMP object we server, a DisplayString

netsnmpagent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _py_log_handler(majorID, minorID, serverarg, clientarg):
190190
if self.LogHandler:
191191
self.LogHandler(msgprio, msgtext)
192192
else:
193-
print "[{0}] {1}".format(msgprio, msgtext)
193+
print("[{0}] {1}".format(msgprio, msgtext))
194194

195195
return 0
196196

python-netsnmpagent.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
1717
%if %{?suse_version: %{suse_version} > 1110} %{!?suse_version:1}
1818
BuildArch: noarch
1919
%else
20-
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
20+
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
2121
%endif
2222

2323
%description

tests/test_01_netsnmptestenv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def test_TmpdirRemoved():
101101
global tmpdir
102102

103103
# List the tempdir's name and its contents if the assert fails
104-
print tmpdir
104+
print(tmpdir)
105105
try:
106-
print os.listdir(tmpdir)
106+
print(os.listdir(tmpdir))
107107
except OSError:
108108
pass
109109
ok_(os.path.exists(tmpdir) == False)

tests/test_02_netsnmpagent_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def tearDown(self):
3333
def test_FirstGetFails():
3434
""" Instance not created yet, MIB unvailable """
3535

36-
print netsnmpTestEnv.snmpget("TEST-MIB::testUnsigned32NoInitval.0")
36+
print(netsnmpTestEnv.snmpget("TEST-MIB::testUnsigned32NoInitval.0"))
3737

3838
@timed(1)
3939
def test_Instantiation():
@@ -58,7 +58,7 @@ def NetSNMPLogHandler(msgprio, msgtext):
5858

5959
# Also print them out to stdout as the default log handler would, nose
6060
# will capture the output and display it if a test fails
61-
print "[{0}] {1}".format(msgprio, msgtext)
61+
print("[{0}] {1}".format(msgprio, msgtext))
6262

6363
# Create a new netsnmpAgent instance which
6464
# - connects to the net-snmp test environment's snmpd instance

tests/test_03_netsnmpagent_snmpobjs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def test_SET_Integer32_42_eq_42():
398398

399399
global testenv, settableInteger32
400400

401-
print testenv.snmpset("TEST-MIB::testInteger32NoInitval.0", 42, "i")
401+
print(testenv.snmpset("TEST-MIB::testInteger32NoInitval.0", 42, "i"))
402402

403403
eq_(settableInteger32.value(), 42)
404404

@@ -522,7 +522,7 @@ def test_SET_Unsigned32_42_eq_42():
522522

523523
global testenv, settableUnsigned32
524524

525-
print testenv.snmpset("TEST-MIB::testUnsigned32NoInitval.0", 42, "u")
525+
print(testenv.snmpset("TEST-MIB::testUnsigned32NoInitval.0", 42, "u"))
526526

527527
eq_(settableUnsigned32.value(), 42)
528528

@@ -822,7 +822,7 @@ def test_SET_TimeTicks_42_eq_42():
822822

823823
global testenv, settableTimeTicks
824824

825-
print testenv.snmpset("TEST-MIB::testTimeTicksNoInitval.0", 42, "t")
825+
print(testenv.snmpset("TEST-MIB::testTimeTicksNoInitval.0", 42, "t"))
826826

827827
eq_(settableTimeTicks.value(), 42)
828828

@@ -983,7 +983,7 @@ def test_SET_OctetStringWithoutInterval_abcdef_eq_abcdef():
983983

984984
global testenv, settableOctetString
985985

986-
print testenv.snmpset("TEST-MIB::testOctetStringNoInitval.0", "abcdef", "s")
986+
print(testenv.snmpset("TEST-MIB::testOctetStringNoInitval.0", "abcdef", "s"))
987987

988988
eq_(settableOctetString.value(), "abcdef")
989989

0 commit comments

Comments
 (0)