slackware-current/source/n/net-snmp/net-snmp-5.8-python3.patch
Patrick J Volkerding 374248fe50 Fri Nov 9 21:46:09 UTC 2018
a/udisks2-2.6.5-x86_64-3.txz:  Rebuilt.
  Recompiled against net-snmp-5.8.
ap/hplip-3.18.10-x86_64-2.txz:  Rebuilt.
  Recompiled against net-snmp-5.8.
d/bison-3.2.1-x86_64-1.txz:  Upgraded.
d/meson-0.48.2-x86_64-1.txz:  Upgraded.
l/pycairo-1.18.0-x86_64-1.txz:  Upgraded.
n/bridge-utils-1.6-x86_64-1.txz:  Upgraded.
n/net-snmp-5.8-x86_64-1.txz:  Upgraded.
  Shared library .so-version bump.
n/ntp-4.2.8p12-x86_64-2.txz:  Rebuilt.
  Recompiled against net-snmp-5.8.
n/php-7.2.12-x86_64-2.txz:  Rebuilt.
  Recompiled against net-snmp-5.8.
xap/blackbox-0.74-x86_64-2.txz:  Rebuilt.
  When building, don't install anything to the system. Thanks to Didier Spaier.
xap/sane-1.0.27-x86_64-4.txz:  Rebuilt.
  Recompiled against net-snmp-5.8.
extra/aspell-word-lists/aspell-ar-1.2_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-ast-0.01-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-ca-2.1.5_1-x86_64-1.txz:  Upgraded.
extra/aspell-word-lists/aspell-de_alt-2.1_1-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-fy-0.12_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-grc-0.02_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-hy-0.10.0_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-ky-0.01_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-ml-0.03_1-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-pt_PT-20070510_0-x86_64-1.txz:  Added.
extra/aspell-word-lists/aspell-tk-0.01_0-x86_64-1.txz:  Added.
2018-11-10 08:59:45 +01:00

720 lines
26 KiB
Diff

diff -urNp a/configure b/configure
--- a/configure 2018-07-18 17:11:53.178147565 +0200
+++ b/configure 2018-07-18 17:14:01.254774416 +0200
@@ -7742,8 +7742,8 @@ $as_echo "no" >&6; }
fi
-# Extract the first word of "python", so it can be a program name with args.
-set dummy python; ac_word=$2
+# Extract the first word of "python3", so it can be a program name with args.
+set dummy python3; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PYTHONPROG+:} false; then :
diff -urNp a/configure.d/config_os_progs b/configure.d/config_os_progs
--- a/configure.d/config_os_progs 2018-07-18 17:11:53.197147510 +0200
+++ b/configure.d/config_os_progs 2018-07-18 17:14:29.963690646 +0200
@@ -57,7 +57,7 @@ AC_PATH_PROG(AUTOCONF, autoconf, [:
AC_PATH_PROG(AUTOHEADER, autoheader, [:])
AC_PATH_PROG([PERLPROG], perl)
AC_PATH_PROG([PSPROG], ps)
-AC_PATH_PROG([PYTHONPROG],python)
+AC_PATH_PROG([PYTHONPROG],python3)
AC_PATH_PROG([UNAMEPROG], uname)
AC_DEFINE_UNQUOTED(UNAMEPROG,"$UNAMEPROG", [Where is the uname command])
diff -urNp a/Makefile.in b/Makefile.in
--- a/Makefile.in 2018-07-18 17:11:53.175147574 +0200
+++ b/Makefile.in 2018-07-18 17:16:21.331365317 +0200
@@ -226,7 +226,7 @@ perlcleanfeatures:
# python specific build rules
#
-PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
+PYMAKE=/usr/bin/python3 setup.py $(PYTHONARGS)
pythonmodules: subdirs
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
if test $$? != 0 ; then \
diff -urNp a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
--- a/python/netsnmp/client_intf.c 2018-07-18 17:11:53.262147321 +0200
+++ b/python/netsnmp/client_intf.c 2018-07-18 17:33:16.495712833 +0200
@@ -1,11 +1,5 @@
#include <Python.h>
-#if PY_VERSION_HEX < 0x02050000
-typedef int Py_ssize_t;
-#define PY_SSIZE_T_MAX INT_MAX
-#define PY_SSIZE_T_MIN INT_MIN
-#endif
-
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <sys/types.h>
@@ -852,8 +846,40 @@ py_netsnmp_attr_string(PyObject *obj, ch
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
+ *val = PyUnicode_AsUTF8AndSize(attr, len);
+ Py_DECREF(attr);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int
+py_netsnmp_attr_set_bytes(PyObject *obj, char *attr_name,
+ char *val, size_t len)
+{
+ int ret = -1;
+ if (obj && attr_name) {
+ PyObject* val_obj = (val ?
+ PyBytes_FromStringAndSize(val, len) :
+ Py_BuildValue(""));
+ ret = PyObject_SetAttrString(obj, attr_name, val_obj);
+ Py_DECREF(val_obj);
+ }
+ return ret;
+}
+
+static int
+py_netsnmp_attr_bytes(PyObject *obj, char * attr_name, char **val,
+ Py_ssize_t *len)
+{
+ *val = NULL;
+ if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
+ PyObject *attr = PyObject_GetAttrString(obj, attr_name);
+ if (attr) {
int retval;
- retval = PyString_AsStringAndSize(attr, val, len);
+ retval = PyBytes_AsStringAndSize(attr, val, len);
Py_DECREF(attr);
return retval;
}
@@ -870,7 +896,7 @@ py_netsnmp_attr_long(PyObject *obj, char
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
- val = PyInt_AsLong(attr);
+ val = PyLong_AsLong(attr);
Py_DECREF(attr);
}
}
@@ -955,13 +981,13 @@ __py_netsnmp_update_session_errors(PyObj
py_netsnmp_attr_set_string(session, "ErrorStr", err_str, STRLEN(err_str));
- tmp_for_conversion = PyInt_FromLong(err_num);
+ tmp_for_conversion = PyLong_FromLong(err_num);
if (!tmp_for_conversion)
return; /* nothing better to do? */
PyObject_SetAttrString(session, "ErrorNum", tmp_for_conversion);
Py_DECREF(tmp_for_conversion);
- tmp_for_conversion = PyInt_FromLong(err_ind);
+ tmp_for_conversion = PyLong_FromLong(err_ind);
if (!tmp_for_conversion)
return; /* nothing better to do? */
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
@@ -1323,7 +1349,7 @@ netsnmp_get(PyObject *self, PyObject *ar
ss = (SnmpSession *)py_netsnmp_attr_void_ptr(session, "sess_ptr");
- if (py_netsnmp_attr_string(session, "ErrorStr", &tmpstr, &tmplen) < 0) {
+ if (py_netsnmp_attr_bytes(session, "ErrorStr", &tmpstr, &tmplen) < 0) {
goto done;
}
@@ -2015,7 +2041,7 @@ netsnmp_walk(PyObject *self, PyObject *a
vars, tp, type, sprintval_flag);
str_buf[len] = '\0';
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf,
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf,
len);
/* push the varbind onto the return varbinds */
@@ -2266,7 +2292,7 @@ netsnmp_getbulk(PyObject *self, PyObject
__get_type_str(type, type_str);
- py_netsnmp_attr_set_string(varbind, "type", type_str,
+ py_netsnmp_attr_set_bytes(varbind, "type", type_str,
strlen(type_str));
len = __snprint_value((char **)&str_buf, &str_buf_len,
@@ -2409,7 +2435,7 @@ netsnmp_set(PyObject *self, PyObject *ar
}
}
- if (py_netsnmp_attr_string(varbind, "val", &val, &tmplen) < 0) {
+ if (py_netsnmp_attr_bytes(varbind, "val", &val, &tmplen) < 0) {
snmp_free_pdu(pdu);
goto done;
}
@@ -2467,7 +2493,6 @@ netsnmp_set(PyObject *self, PyObject *ar
return (ret ? ret : Py_BuildValue(""));
}
-
static PyMethodDef ClientMethods[] = {
{"session", netsnmp_create_session, METH_VARARGS,
"create a netsnmp session."},
@@ -2490,10 +2515,23 @@ static PyMethodDef ClientMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
+static struct PyModuleDef ModuleDefinition = {
+ PyModuleDef_HEAD_INIT,
+ "client_intf",
+ NULL,
+ -1,
+ ClientMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-initclient_intf(void)
+PyInit_client_intf(void)
{
- (void) Py_InitModule("client_intf", ClientMethods);
+ PyObject *module = PyModule_Create(&ModuleDefinition);
+ return module;
}
diff -urNp a/python/netsnmp/client.py b/python/netsnmp/client.py
--- a/python/netsnmp/client.py 2018-07-18 17:11:53.262147321 +0200
+++ b/python/netsnmp/client.py 2018-07-18 17:37:10.489221397 +0200
@@ -34,12 +34,12 @@ def _parse_session_args(kargs):
'TheirHostname':'',
'TrustCert':''
}
- keys = kargs.keys()
+ keys = list(kargs.keys())
for key in keys:
- if sessArgs.has_key(key):
+ if key in sessArgs:
sessArgs[key] = kargs[key]
else:
- print >>stderr, "ERROR: unknown key", key
+ print("ERROR: unknown key", key, file=stderr)
return sessArgs
def STR(obj):
@@ -55,7 +55,7 @@ class Varbind(object):
def __init__(self, tag=None, iid=None, val=None, type_arg=None):
self.tag = STR(tag)
self.iid = STR(iid)
- self.val = STR(val)
+ self.val = val
self.type = STR(type_arg)
# parse iid out of tag if needed
if iid is None and tag is not None:
@@ -65,7 +65,10 @@ class Varbind(object):
(self.tag, self.iid) = match.group(1, 2)
def __setattr__(self, name, val):
- self.__dict__[name] = STR(val)
+ if name == 'val':
+ self.__dict__[name] = val
+ else:
+ self.__dict__[name] = STR(val)
def __str__(self):
return obj_to_str(self)
@@ -132,7 +135,7 @@ class Session(object):
sess_args = _parse_session_args(args)
- for k, v in sess_args.items():
+ for k, v in list(sess_args.items()):
self.__dict__[k] = v
diff -urNp a/python/netsnmp/__init__.py b/python/netsnmp/__init__.py
--- a/python/netsnmp/__init__.py 2018-07-18 17:11:53.262147321 +0200
+++ b/python/netsnmp/__init__.py 2018-07-18 17:37:32.553172525 +0200
@@ -1 +1 @@
-from client import *
+from .client import *
diff -urNp a/python/netsnmp/tests/test.py b/python/netsnmp/tests/test.py
--- a/python/netsnmp/tests/test.py 2018-07-18 17:11:53.263147318 +0200
+++ b/python/netsnmp/tests/test.py 2018-07-18 17:38:21.272063355 +0200
@@ -12,7 +12,7 @@ def snmp_dest(**kwargs):
'DestHost': 'localhost:' + os.environ.get("SNMP_SNMPD_PORT", 161),
'Community': 'public',
}
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
dest[key] = value
return dest
@@ -62,107 +62,107 @@ class BasicTests(unittest.TestCase):
self.assertEqual(var.iid, '')
def test_v1_get(self):
- print "\n"
- print "---v1 GET tests -------------------------------------\n"
+ print("\n")
+ print("---v1 GET tests -------------------------------------\n")
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "v1 snmpget result: ", res, "\n"
+ print("v1 snmpget result: ", res, "\n")
self.assertEqual(len(res), 1)
- print "v1 get var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 get var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'sysDescr')
self.assertEqual(var.iid, '0')
self.assertEqual(var.val, res[0])
self.assertEqual(var.type, 'OCTETSTR')
def test_v1_getnext(self):
- print "\n"
- print "---v1 GETNEXT tests-------------------------------------\n"
+ print("\n")
+ print("---v1 GETNEXT tests-------------------------------------\n")
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1', '0')
res = netsnmp.snmpgetnext(var, **snmp_dest())
- print "v1 snmpgetnext result: ", res, "\n"
+ print("v1 snmpgetnext result: ", res, "\n")
self.assertEqual(len(res), 1)
- print "v1 getnext var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 getnext var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertTrue(var.tag is not None)
self.assertTrue(var.iid is not None)
self.assertTrue(var.val is not None)
self.assertTrue(var.type is not None)
def test_v1_set(self):
- print "\n"
- print "---v1 SET tests-------------------------------------\n"
+ print("\n")
+ print("---v1 SET tests-------------------------------------\n")
var = netsnmp.Varbind('sysLocation', '0', 'my new location')
res = netsnmp.snmpset(var, **snmp_dest())
- print "v1 snmpset result: ", res, "\n"
+ print("v1 snmpset result: ", res, "\n")
self.assertEqual(res, 1)
- print "v1 set var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 set var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'sysLocation')
self.assertEqual(var.iid, '0')
self.assertEqual(var.val, 'my new location')
self.assertTrue(var.type is None)
def test_v1_walk(self):
- print "\n"
- print "---v1 walk tests-------------------------------------\n"
+ print("\n")
+ print("---v1 walk tests-------------------------------------\n")
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
- print "v1 varlist walk in: "
+ print("v1 varlist walk in: ")
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
res = netsnmp.snmpwalk(varlist, **snmp_dest())
- print "v1 snmpwalk result: ", res, "\n"
+ print("v1 snmpwalk result: ", res, "\n")
self.assertTrue(len(res) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v1_walk_2(self):
- print "\n"
- print "---v1 walk 2-------------------------------------\n"
+ print("\n")
+ print("---v1 walk 2-------------------------------------\n")
- print "v1 varbind walk in: "
+ print("v1 varbind walk in: ")
var = netsnmp.Varbind('system')
self.assertEqual(var.tag, 'system')
self.assertEqual(var.iid, '')
self.assertEqual(var.val, None)
self.assertEqual(var.type, None)
res = netsnmp.snmpwalk(var, **snmp_dest())
- print "v1 snmpwalk result (should be = orig): ", res, "\n"
+ print("v1 snmpwalk result (should be = orig): ", res, "\n")
self.assertTrue(len(res) > 0)
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'system')
self.assertEqual(var.iid, '')
self.assertEqual(var.val, None)
self.assertEqual(var.type, None)
def test_v1_mv_get(self):
- print "\n"
- print "---v1 multi-varbind test-------------------------------------\n"
+ print("\n")
+ print("---v1 multi-varbind test-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(varlist)
- print "v1 sess.get result: ", vals, "\n"
+ print("v1 sess.get result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
vals = sess.getnext(varlist)
- print "v1 sess.getnext result: ", vals, "\n"
+ print("v1 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -171,71 +171,71 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v1 sess.getbulk result: ", vals, "\n"
+ print("v1 sess.getbulk result: ", vals, "\n")
self.assertEqual(vals, None) # GetBulk is not supported for v1
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v1_set_2(self):
- print "\n"
- print "---v1 set2-------------------------------------\n"
+ print("\n")
+ print("---v1 set2-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my newer location'))
res = sess.set(varlist)
- print "v1 sess.set result: ", res, "\n"
+ print("v1 sess.set result: ", res, "\n")
def test_v1_walk_3(self):
- print "\n"
- print "---v1 walk3-------------------------------------\n"
+ print("\n")
+ print("---v1 walk3-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v1 sess.walk result: ", vals, "\n"
+ print("v1 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v2c_get(self):
- print "\n"
- print "---v2c get-------------------------------------\n"
+ print("\n")
+ print("---v2c get-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(varlist)
- print "v2 sess.get result: ", vals, "\n"
+ print("v2 sess.get result: ", vals, "\n")
self.assertEqual(len(vals), 3)
def test_v2c_getnext(self):
- print "\n"
- print "---v2c getnext-------------------------------------\n"
+ print("\n")
+ print("---v2c getnext-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
vals = sess.getnext(varlist)
- print "v2 sess.getnext result: ", vals, "\n"
+ print("v2 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v2c_getbulk(self):
- print "\n"
- print "---v2c getbulk-------------------------------------\n"
+ print("\n")
+ print("---v2c getbulk-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
@@ -245,16 +245,16 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v2 sess.getbulk result: ", vals, "\n"
+ print("v2 sess.getbulk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v2c_set(self):
- print "\n"
- print "---v2c set-------------------------------------\n"
+ print("\n")
+ print("---v2c set-------------------------------------\n")
sess = setup_v2()
@@ -262,54 +262,54 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysLocation', '0', 'my even newer location'))
res = sess.set(varlist)
- print "v2 sess.set result: ", res, "\n"
+ print("v2 sess.set result: ", res, "\n")
self.assertEqual(res, 1)
def test_v2c_walk(self):
- print "\n"
- print "---v2c walk-------------------------------------\n"
+ print("\n")
+ print("---v2c walk-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v2 sess.walk result: ", vals, "\n"
+ print("v2 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v3_get(self):
- print "\n"
+ print("\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
- print "---v3 get-------------------------------------\n"
+ print("---v3 get-------------------------------------\n")
vals = sess.get(varlist)
- print "v3 sess.get result: ", vals, "\n"
+ print("v3 sess.get result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_getnext(self):
- print "\n"
- print "---v3 getnext-------------------------------------\n"
+ print("\n")
+ print("---v3 getnext-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.getnext(varlist)
- print "v3 sess.getnext result: ", vals, "\n"
+ print("v3 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_getbulk(self):
sess = setup_v3();
@@ -320,47 +320,47 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v3 sess.getbulk result: ", vals, "\n"
+ print("v3 sess.getbulk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_set(self):
- print "\n"
- print "---v3 set-------------------------------------\n"
+ print("\n")
+ print("---v3 set-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my final destination'))
res = sess.set(varlist)
- print "v3 sess.set result: ", res, "\n"
+ print("v3 sess.set result: ", res, "\n")
self.assertEqual(res, 1)
def test_v3_walk(self):
- print "\n"
- print "---v3 walk-------------------------------------\n"
+ print("\n")
+ print("---v3 walk-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v3 sess.walk result: ", vals, "\n"
+ print("v3 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
class SetTests(unittest.TestCase):
"""SNMP set tests for the Net-SNMP Python interface"""
def testFuncs(self):
"""Test code"""
- print "\n-------------- SET Test Start ----------------------------\n"
+ print("\n-------------- SET Test Start ----------------------------\n")
var = netsnmp.Varbind('sysUpTime', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
self.assertEqual(len(res), 1)
@@ -370,19 +370,19 @@ class SetTests(unittest.TestCase):
var = netsnmp.Varbind('sysUpTime', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
self.assertEqual(len(res), 1)
var = netsnmp.Varbind('nsCacheEntry')
res = netsnmp.snmpgetnext(var, **snmp_dest())
- print "var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(len(res), 1)
var.val = 65
res = netsnmp.snmpset(var, **snmp_dest())
self.assertEqual(res, 1)
res = netsnmp.snmpget(var, **snmp_dest())
- print "var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(len(res), 1)
self.assertEqual(res[0], '65');
@@ -394,7 +394,7 @@ class SetTests(unittest.TestCase):
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116', '', 4))
res = sess.set(varlist)
- print "res = ", res
+ print("res = ", res)
self.assertEqual(res, 1)
varlist = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
@@ -414,15 +414,15 @@ class SetTests(unittest.TestCase):
self.assertEqual(varlist[2].val, '3')
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
varlist = netsnmp.VarList(
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116', '', 6))
res = sess.set(varlist)
- print "res = ", res
+ print("res = ", res)
self.assertEqual(res, 1)
varlist = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
@@ -436,10 +436,10 @@ class SetTests(unittest.TestCase):
self.assertNotEqual(varlist[2].tag, 'snmpTargetAddrRowStatus')
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
- print "\n-------------- SET Test End ----------------------------\n"
+ print("\n-------------- SET Test End ----------------------------\n")
if __name__ == '__main__':
diff -urNp a/python/setup.py b/python/setup.py
--- a/python/setup.py 2018-07-18 17:11:53.262147321 +0200
+++ b/python/setup.py 2018-07-18 17:40:36.922751382 +0200
@@ -9,9 +9,9 @@ intree=0
args = sys.argv[:]
for arg in args:
- if string.find(arg,'--basedir=') == 0:
- basedir = string.split(arg,'=')[1]
- sys.argv.remove(arg)
+ if arg.find('--basedir=') == 0:
+ basedir = arg.split('=')[1]
+ sys.argv.remove(arg) #tabs
intree=1
if intree: