net-snmp/net-snmp-5.7.3-python3.patch

642 lines
25 KiB
Diff
Raw Normal View History

2018-05-31 09:24:43 +00:00
diff -urNp old/configure new/configure
--- old/configure 2018-05-29 08:27:03.342448982 +0200
+++ new/configure 2018-05-29 08:27:15.317394863 +0200
2018-02-27 12:48:26 +00:00
@@ -6412,8 +6412,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="python3"
{ $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 :
2018-05-31 09:24:43 +00:00
diff -urNp old/configure.d/config_os_progs new/configure.d/config_os_progs
--- old/configure.d/config_os_progs 2018-05-29 08:27:03.368448865 +0200
+++ new/configure.d/config_os_progs 2018-05-29 08:27:15.341394754 +0200
2018-05-28 12:21:45 +00:00
@@ -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])
2018-05-31 09:24:43 +00:00
diff -urNp old/Makefile.in new/Makefile.in
--- old/Makefile.in 2018-05-29 08:27:03.340448991 +0200
+++ new/Makefile.in 2018-05-29 08:27:15.307394908 +0200
2018-02-27 12:48:26 +00:00
@@ -222,7 +222,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 \
2018-05-31 09:24:43 +00:00
diff -urNp old/python/netsnmp/client_intf.c new/python/netsnmp/client_intf.c
--- old/python/netsnmp/client_intf.c 2018-05-29 08:27:03.390448765 +0200
+++ new/python/netsnmp/client_intf.c 2018-05-31 10:28:43.202727021 +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>
@@ -978,8 +972,40 @@ py_netsnmp_attr_string(PyObject *obj, ch
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
2018-05-28 12:21:45 +00:00
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
2018-05-31 09:24:43 +00:00
+ *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) {
2018-05-28 12:21:45 +00:00
int retval;
- retval = PyString_AsStringAndSize(attr, val, len);
+ retval = PyBytes_AsStringAndSize(attr, val, len);
Py_DECREF(attr);
return retval;
}
2018-05-31 09:24:43 +00:00
@@ -996,7 +1022,7 @@ py_netsnmp_attr_long(PyObject *obj, char
2018-05-28 12:21:45 +00:00
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);
}
}
2018-05-31 09:24:43 +00:00
@@ -1079,11 +1105,11 @@ __py_netsnmp_update_session_errors(PyObj
2018-05-28 12:21:45 +00:00
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);
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);
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
Py_DECREF(tmp_for_conversion);
}
2018-05-31 09:24:43 +00:00
@@ -1588,7 +1614,7 @@ netsnmp_get(PyObject *self, PyObject *ar
len = __snprint_value((char *) str_buf, sizeof(str_buf),
vars, tp, type, sprintval_flag);
str_buf[len] = '\0';
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf, len);
/* save in return tuple as well */
if ((type == SNMP_ENDOFMIBVIEW) ||
@@ -1808,7 +1834,7 @@ netsnmp_getnext(PyObject *self, PyObject
vars, tp, type, sprintval_flag);
str_buf[len] = '\0';
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf, len);
/* save in return tuple as well */
if ((type == SNMP_ENDOFMIBVIEW) ||
@@ -2138,7 +2164,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 */
@@ -2386,7 +2412,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, sizeof(str_buf),
@@ -2527,7 +2553,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;
}
@@ -2607,10 +2633,23 @@ static PyMethodDef ClientMethods[] = {
2018-05-28 12:21:45 +00:00
{NULL, NULL, 0, NULL} /* Sentinel */
};
+static struct PyModuleDef ModuleDefinition = {
+ PyModuleDef_HEAD_INIT,
+ "client_intf",
+ NULL,
+ -1,
+ ClientMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
2018-05-31 09:24:43 +00:00
-initclient_intf(void)
+PyInit_client_intf(void)
2018-05-28 12:21:45 +00:00
{
- (void) Py_InitModule("client_intf", ClientMethods);
2018-05-31 09:24:43 +00:00
+ PyObject *module = PyModule_Create(&ModuleDefinition);
+ return module;
2018-05-28 12:21:45 +00:00
}
2018-05-31 09:24:43 +00:00
diff -urNp old/python/netsnmp/client.py new/python/netsnmp/client.py
--- old/python/netsnmp/client.py 2018-05-29 08:27:03.390448765 +0200
+++ new/python/netsnmp/client.py 2018-05-31 09:27:03.964289879 +0200
@@ -1,8 +1,8 @@
-import client_intf
import string
import re
import types
from sys import stderr
+from netsnmp import client_intf
# control verbosity of error output
verbose = 1
2018-05-28 12:21:45 +00:00
@@ -35,12 +35,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):
2018-05-31 09:24:43 +00:00
@@ -53,7 +53,7 @@ class Varbind(object):
def __init__(self, tag=None, iid=None, val=None, type=None):
self.tag = STR(tag)
self.iid = STR(iid)
- self.val = STR(val)
+ self.val = val
self.type = STR(type)
# parse iid out of tag if needed
if iid == None and tag != None:
@@ -63,7 +63,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 print_str(self):
return self.tag, self.iid, self.val, self.type
@@ -127,7 +130,7 @@ class Session(object):
2018-05-28 12:21:45 +00:00
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
2018-05-31 09:24:43 +00:00
diff -urNp old/python/netsnmp/__init__.py new/python/netsnmp/__init__.py
--- old/python/netsnmp/__init__.py 2018-05-29 08:27:03.390448765 +0200
+++ new/python/netsnmp/__init__.py 2018-05-29 08:27:15.362394659 +0200
2018-05-28 12:21:45 +00:00
@@ -1 +1 @@
-from client import *
+from .client import *
2018-05-31 09:24:43 +00:00
diff -urNp old/python/netsnmp/tests/test.py new/python/netsnmp/tests/test.py
--- old/python/netsnmp/tests/test.py 2018-05-29 08:27:03.390448765 +0200
+++ new/python/netsnmp/tests/test.py 2018-05-29 08:27:15.363394655 +0200
2018-02-27 12:48:26 +00:00
@@ -8,7 +8,7 @@ import time
class BasicTests(unittest.TestCase):
def testFuncs(self):
- print ""
+ print ("")
var = netsnmp.Varbind('sysDescr.0')
var = netsnmp.Varbind('sysDescr','0')
var = netsnmp.Varbind(
@@ -19,67 +19,67 @@ class BasicTests(unittest.TestCase):
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1','0')
- print "---v1 GET tests -------------------------------------\n"
+ print ("---v1 GET tests -------------------------------------\n")
res = netsnmp.snmpget(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpget result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 snmpget result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print(("v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 GETNEXT tests-------------------------------------\n"
+ print ("---v1 GETNEXT tests-------------------------------------\n")
res = netsnmp.snmpgetnext(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpgetnext result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 snmpgetnext result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print(("v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 SET tests-------------------------------------\n"
+ print ("---v1 SET tests-------------------------------------\n")
var = netsnmp.Varbind('sysLocation','0', 'my new location')
res = netsnmp.snmpset(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpset result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 snmpset result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print(("v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 walk tests-------------------------------------\n"
+ print ("---v1 walk tests-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
- print "v1 varlist walk in: "
+ print ("v1 varlist walk in: ")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((" ",var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
res = netsnmp.snmpwalk(vars,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 snmpwalk result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 walk 2-------------------------------------\n"
+ print ("---v1 walk 2-------------------------------------\n")
- print "v1 varbind walk in: "
+ print ("v1 varbind walk in: ")
var = netsnmp.Varbind('system')
res = netsnmp.snmpwalk(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result (should be = orig): ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 snmpwalk result (should be = orig): ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 multi-varbind test-------------------------------------\n"
+ print ("---v1 multi-varbind test-------------------------------------\n")
sess = netsnmp.Session(Version=1,
DestHost='localhost',
Community='public')
@@ -88,16 +88,16 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v1 sess.get result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 sess.get result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
vals = sess.getnext(vars)
- print "v1 sess.getnext result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 sess.getnext result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -106,28 +106,28 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v1 sess.getbulk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 sess.getbulk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v1 set2-------------------------------------\n"
+ print ("---v1 set2-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my newer location'))
res = sess.set(vars)
- print "v1 sess.set result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 sess.set result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "---v1 walk3-------------------------------------\n"
+ print ("---v1 walk3-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v1 sess.walk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v1 sess.walk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((" ",var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v2c get-------------------------------------\n"
+ print ("---v2c get-------------------------------------\n")
sess = netsnmp.Session(Version=2,
DestHost='localhost',
@@ -140,22 +140,22 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v2 sess.get result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v2 sess.get result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
- print "---v2c getnext-------------------------------------\n"
+ print ("---v2c getnext-------------------------------------\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
vals = sess.getnext(vars)
- print "v2 sess.getnext result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v2 sess.getnext result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
- print "---v2c getbulk-------------------------------------\n"
+ print ("---v2c getbulk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -164,30 +164,30 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v2 sess.getbulk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v2 sess.getbulk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
- print "---v2c set-------------------------------------\n"
+ print ("---v2c set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0','my even newer location'))
res = sess.set(vars)
- print "v2 sess.set result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v2 sess.set result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "---v2c walk-------------------------------------\n"
+ print ("---v2c walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v2 sess.walk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v2 sess.walk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((" ",var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
- print "---v3 setup-------------------------------------\n"
+ print ("---v3 setup-------------------------------------\n")
sess = netsnmp.Session(Version=3,
DestHost='localhost',
SecLevel='authPriv',
@@ -200,22 +200,22 @@ class BasicTests(unittest.TestCase):
vars = 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(vars)
- print "v3 sess.get result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v3 sess.get result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
- print "---v3 getnext-------------------------------------\n"
+ print ("---v3 getnext-------------------------------------\n")
vals = sess.getnext(vars)
- print "v3 sess.getnext result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v3 sess.getnext result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -224,37 +224,37 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v3 sess.getbulk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v3 sess.getbulk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
- print "---v3 set-------------------------------------\n"
+ print ("---v3 set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0', 'my final destination'))
res = sess.set(vars)
- print "v3 sess.set result: ", res, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v3 sess.set result: ", res, "\n"))
2018-02-27 12:48:26 +00:00
- print "---v3 walk-------------------------------------\n"
+ print ("---v3 walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v3 sess.walk result: ", vals, "\n"
2018-05-28 12:21:45 +00:00
+ print(("v3 sess.walk result: ", vals, "\n"))
2018-02-27 12:48:26 +00:00
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print((" ",var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
class SetTests(unittest.TestCase):
def testFuncs(self):
- print "\n-------------- SET Test Start ----------------------------\n"
+ print ("\n-------------- SET Test Start ----------------------------\n")
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
2018-05-28 12:21:45 +00:00
+ print(("uptime = ", res[0]))
2018-02-27 12:48:26 +00:00
var = netsnmp.Varbind('versionRestartAgent','0', 1)
@@ -264,19 +264,19 @@ class SetTests(unittest.TestCase):
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
2018-05-28 12:21:45 +00:00
+ print(("uptime = ", res[0]))
2018-02-27 12:48:26 +00:00
var = netsnmp.Varbind('nsCacheEntry')
res = netsnmp.snmpgetnext(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print(("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
var.val = 65
res = netsnmp.snmpset(var, Version = 1, DestHost='localhost',
Community='public')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
2018-05-28 12:21:45 +00:00
+ print(("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
sess = netsnmp.Session(Version = 1, DestHost='localhost',
Community='public')
@@ -286,7 +286,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(vars)
- print "res = ", res
2018-05-28 12:21:45 +00:00
+ print(("res = ", res))
2018-02-27 12:48:26 +00:00
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -295,14 +295,14 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
vars = netsnmp.VarList(netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116','', 6))
res = sess.set(vars)
- print "res = ", res
2018-05-28 12:21:45 +00:00
+ print(("res = ", res))
2018-02-27 12:48:26 +00:00
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -311,10 +311,10 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
2018-05-28 12:21:45 +00:00
+ print((var.tag, var.iid, "=", var.val, '(',var.type,')'))
2018-02-27 12:48:26 +00:00
+ print ("\n")
- print "\n-------------- SET Test End ----------------------------\n"
+ print ("\n-------------- SET Test End ----------------------------\n")
if __name__=='__main__':
2018-05-31 09:24:43 +00:00
diff -urNp old/python/setup.py new/python/setup.py
--- old/python/setup.py 2018-05-29 08:27:03.389448770 +0200
+++ new/python/setup.py 2018-05-29 08:27:15.362394659 +0200
2018-02-27 12:48:26 +00:00
@@ -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)
intree=1
if intree: