Commit 3430cdf6 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

python2 -> python3

parent 9cd6dc01
......@@ -18,7 +18,9 @@ jobs:
git-core ccache gcc-c++ etersoft-build-utils catch-devel \
libcomedi-devel libmariadb-devel libpqxx-devel librrd-devel libsqlite3-devel \
libxml2-devel libsigc++2-devel libpoco-devel libev-devel libomniORB-devel libmosquitto-devel \
xsltproc python-devel python-module-distribute libomniORB-names libomniORB-idl libomniORB-utils swig
xsltproc python-base python3-dev libomniORB-names libomniORB-idl libomniORB-utils swig python-devel \
python-module-distribute
- uses: actions/checkout@v2
- name: configure
run: |
......@@ -26,7 +28,7 @@ jobs:
# due broken comedi
export CXXFLAGS="$CXXFLAGS -Wl,--unresolved-symbols=ignore-in-shared-libs"
autoreconf -fiv
./configure --disable-netdata
./configure --disable-netdata --disable-python
- name: make
run: make
- name: testsuite
......
......@@ -25,7 +25,7 @@
%define oname uniset2
Name: libuniset2
Version: 2.13.1
Version: 2.14.1
Release: alt1
Summary: UniSet - library for building distributed industrial control systems
......@@ -467,9 +467,9 @@ rm -f %buildroot%_docdir/%oname/html/*.md5
%if_enabled python
%files -n python-module-%oname
%python_sitelibdir/*
%python_sitelibdir_noarch/%oname/*
%dir %python_sitelibdir_noarch/%oname
%python3_sitelibdir/*
%python3_sitelibdir_noarch/%oname/*
%dir %python3_sitelibdir_noarch/%oname
%endif
%if_enabled netdata
......@@ -594,6 +594,9 @@ rm -f %buildroot%_docdir/%oname/html/*.md5
# history of current unpublished changes
%changelog
* Sun Aug 15 2021 Pavel Vainerman <pv@altlinux.ru> 2.14.1-alt1
- python2 -> python3
* Mon Jul 12 2021 Pavel Vainerman <pv@altlinux.ru> 2.13.1-alt1
- [unet]: zero-copy optimization
......
......@@ -3,10 +3,10 @@
# See doc: http://www.gnu.org/software/hello/manual/autoconf/Generic-Programs.html
# AC_PREREQ(2.59)
AC_INIT([uniset2], [2.13.1], pv@etersoft.ru)
AC_INIT([uniset2], [2.14.1], pv@etersoft.ru)
AM_INIT_AUTOMAKE([subdir-objects])
LIBVER=15:1:13
LIBVER=16:1:14
AC_SUBST(LIBVER)
# AC_CONFIG_MACRO_DIR([m4])
......@@ -283,9 +283,9 @@ AC_ARG_ENABLE(python, AC_HELP_STRING([--disable-python], [disable Python support
if test ${buildpython} = true; then
AC_MSG_RESULT([enabled])
AM_PATH_PYTHON(3.0)
dnl Python
AM_PATH_PYTHON(,,)
PKG_CHECK_MODULES(PYTHON,python-2.7,,exit)
PKG_CHECK_MODULES(PYTHON,python3,,exit)
# AC_CHECK_PROG(SWIG, swig, yes, exit)
AC_MSG_CHECKING([netdata python plugin])
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pyUConnector import *
......@@ -7,7 +7,7 @@ import sys
def is_id(str_id):
if isinstance(str_id, int) or isinstance(str_id, long):
if isinstance(str_id, int) or isinstance(str_id, int):
return True
if str_id.strip().isdigit():
......@@ -20,7 +20,7 @@ def to_int(s):
if s == None or s == "":
return 0
if isinstance(s, int) or isinstance(s, long):
if isinstance(s, int) or isinstance(s, int):
return s
if isinstance(s, float):
......@@ -109,7 +109,7 @@ def get_int_list(raw_str, sep='='):
if len(v) > 1:
slist.append([v[0], to_int(v[1])])
else:
print "(get_list:WARNING): (v=x) undefined value for " + str(s)
print("(get_list:WARNING): (v=x) undefined value for " + str(s))
slist.append([v[0], 0])
return slist
......@@ -137,7 +137,7 @@ def get_str_list(raw_str, sep='='):
if len(v) > 1:
slist.append([v[0], v[1]])
else:
print "(get_str_list:WARNING): (v=x) undefined value for " + str(s)
print("(get_str_list:WARNING): (v=x) undefined value for " + str(s))
slist.append([v[0], ""])
return slist
......@@ -155,7 +155,7 @@ def get_replace_list(raw_str):
val = to_str(v[1]).strip().strip("\n")
slist.append([key, val])
else:
print "(get_replace_list:WARNING): (v:x) undefined value for " + str(s)
print("(get_replace_list:WARNING): (v:x) undefined value for " + str(s))
key = to_str(v[0]).strip().strip("\n")
slist.append([key, 0])
......@@ -169,7 +169,7 @@ def get_mbslave_param(raw_str, sep=':'):
l = raw_str.split(sep)
if len(l) > 2:
print "(get_mbslave_param:WARNING): BAD FORMAT! string='%s'. Must be 'hostname:port'" % (raw_str)
print("(get_mbslave_param:WARNING): BAD FORMAT! string='%s'. Must be 'hostname:port'" % (raw_str))
return [None, None]
if len(l) == 2:
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......@@ -41,7 +41,7 @@ class UInterfaceModbus(UInterface):
return [True, ""]
except UException, e:
except UException as e:
return [False, "%s" % e.getError()]
def getValue(self, s_id):
......@@ -58,7 +58,7 @@ class UInterfaceModbus(UInterface):
return self.i.mbread(mbaddr, mbreg, mbfunc, vtype, nbit)
except UException, e:
except UException as e:
raise e
def setValue(self, s_id, s_val, supplier=DefaultSupplerID):
......@@ -77,7 +77,7 @@ class UInterfaceModbus(UInterface):
self.i.mbwrite(mbaddr, mbreg, to_int(s_val), mbfunc)
return
except UException, e:
except UException as e:
raise e
def getConfFileName(self):
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from UInterface import *
......@@ -26,7 +26,7 @@ class UInterfaceUniSet(UInterface):
return [True, ""]
except UException, e:
except UException as e:
return [False, "%s" % e.getError()]
def getValue(self, s_id):
......@@ -38,7 +38,7 @@ class UInterfaceUniSet(UInterface):
return self.i.getValue(s[0], s[1])
except UException, e:
except UException as e:
raise e
def setValue(self, s_id, s_val, supplier=DefaultSupplerID):
......@@ -50,7 +50,7 @@ class UInterfaceUniSet(UInterface):
self.i.setValue(s[0], s_val, s[1], supplier)
return
except UException, e:
except UException as e:
raise e
def getConfFileName(self):
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Pavel Vainerman <pv@etersoft.ru>
......@@ -16,8 +16,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
import urllib2
import urllib
import urllib.request, urllib.error, urllib.parse
import urllib.request, urllib.parse, urllib.error
UHTTP_API_VERSION = 'v0'
......@@ -50,14 +50,14 @@ class UniSetHTTPService:
url = self.settings.get('url') + "/api/" + self.apiver + query
headers = {}
if data is not None:
data = urllib.urlencode(data)
data = urllib.parse.urlencode(data)
try:
request = urllib2.Request(url, data, headers)
request = urllib.request.Request(url, data, headers)
request.get_method = lambda: method
resp = urllib2.urlopen(request)
resp = urllib.request.urlopen(request)
return json.loads(resp.read())
except urllib2.URLError, e:
except urllib.error.URLError as e:
if hasattr(e, 'reason'):
err = 'We failed to reach a server. Reason: %s' % e.reason
raise UHTTPError(err)
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......@@ -54,7 +54,7 @@ class UniXML():
libxml2.cleanupParser()
def callback(ctx, str):
print "%s %s" % (ctx, str)
print("%s %s" % (ctx, str))
def getDoc(self):
return self.doc
......@@ -69,14 +69,14 @@ class UniXML():
ret = self.findNode(node.children, nodestr, propstr)
if ret[0] != None:
return ret
node = node.next
node = node.__next__
return [None, None, None]
def findMyLevel(self, node, nodestr="", propstr=""):
while node != None:
if node.name == nodestr:
return [node, node.name, node.prop(propstr)]
node = node.next
node = node.__next__
return [None, None, None]
def findNode_byProp(self, node, propstr, valuestr):
......@@ -86,12 +86,12 @@ class UniXML():
ret = self.findNode_byProp (node.children, propstr, valuestr)
if ret[0] != None:
return ret
node = node.next
node = node.__next__
return [None, None, None]
def nextNode(self, node):
while node != None:
node = node.next
node = node.__next__
if node == None:
return node
if node.name != "text" and node.name != "comment":
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from UGlobal import *
......
......@@ -26,7 +26,7 @@ _pyUniSet_la_LDFLAGS = -module -avoid-version
_pyUniSet_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS)
UInterface_wrap.cxx: UInterface.i UProxyObject.i PyUInterface.h $(BUILD_SRCDIR)/UProxyObject.h
$(SWIG) -python -c++ -classic -outcurrentdir -I$(BUILD_SRCDIR) UInterface.i
$(SWIG) -python -py3 -c++ -outcurrentdir -I$(BUILD_SRCDIR) UInterface.i
#PyUObject_wrap.cxx: UObject.i PyUObject.h
# swig -python -c++ -classic UObject.i
......@@ -37,7 +37,7 @@ _pyUConnector_la_LDFLAGS = -module -avoid-version
_pyUConnector_la_LIBADD = $(UNISET_LIBS) $(PYTHON_LIBS)
UConnector_wrap.cxx: UConnector.i $(BUILD_SRCDIR)/UConnector.h
$(SWIG) -python -c++ -classic -outcurrentdir -I$(BUILD_SRCDIR) UConnector.i
$(SWIG) -python -py3 -c++ -outcurrentdir -I$(BUILD_SRCDIR) UConnector.i
_pyUModbus_la_SOURCES = UModbus.cc UModbus_wrap.cxx
_pyUModbus_la_CXXFLAGS = -I$(BUILD_SRCDIR) $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(POCO_CFLAGS) $(PYTHON_CFLAGS)
......@@ -45,7 +45,7 @@ _pyUModbus_la_LDFLAGS = -module -avoid-version
_pyUModbus_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(POCO_LIBS) $(PYTHON_LIBS)
UModbus_wrap.cxx: UInterface.i $(BUILD_SRCDIR)/UModbus.h
$(SWIG) -python -c++ -classic -outcurrentdir -I$(BUILD_SRCDIR) UModbus.i
$(SWIG) -python -py3 -c++ -outcurrentdir -I$(BUILD_SRCDIR) UModbus.i
_pyUExceptions_la_SOURCES = UExceptions_wrap.cxx
_pyUExceptions_la_CXXFLAGS = -I$(BUILD_SRCDIR) $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(PYTHON_CFLAGS)
......@@ -53,7 +53,7 @@ _pyUExceptions_la_LDFLAGS = -module -avoid-version
_pyUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS)
UExceptions_wrap.cxx: UExceptions.i $(BUILD_SRCDIR)/UExceptions.h
$(SWIG) -python -c++ -classic -outcurrentdir -I$(BUILD_SRCDIR) UExceptions.i
$(SWIG) -python -py3 -c++ -outcurrentdir -I$(BUILD_SRCDIR) UExceptions.i
# Специальное правило для удаления сгенерированного кода
# для дальнейшей перегенерации
......
......@@ -14,7 +14,6 @@
#endif
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#define SWIG_PYTHON_CLASSIC
#ifdef __cplusplus
......
......@@ -14,7 +14,6 @@
#endif
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#define SWIG_PYTHON_CLASSIC
#ifdef __cplusplus
......
......@@ -14,7 +14,6 @@
#endif
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#define SWIG_PYTHON_CLASSIC
#ifdef __cplusplus
......
......@@ -14,7 +14,6 @@
#endif
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#define SWIG_PYTHON_CLASSIC
#ifdef __cplusplus
......
......@@ -55,7 +55,10 @@ def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if method:
return method(self, value)
if (not static):
self.__dict__[name] = value
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
......@@ -80,7 +83,15 @@ def _swig_repr(self):
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class Params:
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
class Params(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Params, name, value)
__swig_getmethods__ = {}
......@@ -95,16 +106,23 @@ class Params:
except __builtin__.Exception:
self.this = this
def add(self, s):
def add(self, s: 'char *') -> "bool":
return _pyUConnector.Params_add(self, s)
def add_str(self, s):
def add_str(self, s: 'std::string const') -> "bool":
return _pyUConnector.Params_add_str(self, s)
__swig_setmethods__["argc"] = _pyUConnector.Params_argc_set
__swig_getmethods__["argc"] = _pyUConnector.Params_argc_get
if _newclass:
argc = property(_pyUConnector.Params_argc_get, _pyUConnector.Params_argc_set)
__swig_setmethods__["argv"] = _pyUConnector.Params_argv_set
__swig_getmethods__["argv"] = _pyUConnector.Params_argv_get
inst = _pyUConnector.Params_inst
if _newclass:
argv = property(_pyUConnector.Params_argv_get, _pyUConnector.Params_argv_set)
if _newclass:
inst = staticmethod(_pyUConnector.Params_inst)
else:
inst = _pyUConnector.Params_inst
__swig_destroy__ = _pyUConnector.delete_Params
__del__ = lambda self: None
Params_swigregister = _pyUConnector.Params_swigregister
......@@ -113,11 +131,11 @@ cvar = _pyUConnector.cvar
DefaultID = cvar.DefaultID
DefaultSupplerID = cvar.DefaultSupplerID
def Params_inst():
def Params_inst() -> "UTypes::Params":
return _pyUConnector.Params_inst()
Params_inst = _pyUConnector.Params_inst
class ShortIOInfo:
class ShortIOInfo(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, ShortIOInfo, name, value)
__swig_getmethods__ = {}
......@@ -125,14 +143,24 @@ class ShortIOInfo:
__repr__ = _swig_repr
__swig_setmethods__["value"] = _pyUConnector.ShortIOInfo_value_set
__swig_getmethods__["value"] = _pyUConnector.ShortIOInfo_value_get
if _newclass:
value = property(_pyUConnector.ShortIOInfo_value_get, _pyUConnector.ShortIOInfo_value_set)
__swig_setmethods__["tv_sec"] = _pyUConnector.ShortIOInfo_tv_sec_set
__swig_getmethods__["tv_sec"] = _pyUConnector.ShortIOInfo_tv_sec_get
if _newclass:
tv_sec = property(_pyUConnector.ShortIOInfo_tv_sec_get, _pyUConnector.ShortIOInfo_tv_sec_set)
__swig_setmethods__["tv_nsec"] = _pyUConnector.ShortIOInfo_tv_nsec_set
__swig_getmethods__["tv_nsec"] = _pyUConnector.ShortIOInfo_tv_nsec_get
if _newclass:
tv_nsec = property(_pyUConnector.ShortIOInfo_tv_nsec_get, _pyUConnector.ShortIOInfo_tv_nsec_set)
__swig_setmethods__["supplier"] = _pyUConnector.ShortIOInfo_supplier_set
__swig_getmethods__["supplier"] = _pyUConnector.ShortIOInfo_supplier_get
if _newclass:
supplier = property(_pyUConnector.ShortIOInfo_supplier_get, _pyUConnector.ShortIOInfo_supplier_set)
__swig_setmethods__["supplier_node"] = _pyUConnector.ShortIOInfo_supplier_node_set
__swig_getmethods__["supplier_node"] = _pyUConnector.ShortIOInfo_supplier_node_get
if _newclass:
supplier_node = property(_pyUConnector.ShortIOInfo_supplier_node_get, _pyUConnector.ShortIOInfo_supplier_node_set)
def __init__(self):
this = _pyUConnector.new_ShortIOInfo()
......@@ -145,7 +173,7 @@ class ShortIOInfo:
ShortIOInfo_swigregister = _pyUConnector.ShortIOInfo_swigregister
ShortIOInfo_swigregister(ShortIOInfo)
class UConnector:
class UConnector(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UConnector, name, value)
__swig_getmethods__ = {}
......@@ -161,49 +189,50 @@ class UConnector:
__swig_destroy__ = _pyUConnector.delete_UConnector
__del__ = lambda self: None
def getUIType(self):
def getUIType(self) -> "std::string":
return _pyUConnector.UConnector_getUIType(self)
def getConfFileName(self):
def getConfFileName(self) -> "std::string":
return _pyUConnector.UConnector_getConfFileName(self)
def getValue(self, id, node):
def getValue(self, id: 'long', node: 'long') -> "long":
return _pyUConnector.UConnector_getValue(self, id, node)
def setValue(self, *args):
def setValue(self, *args) -> "void":
return _pyUConnector.UConnector_setValue(self, *args)
def getTimeChange(self, *args):
def getTimeChange(self, *args) -> "UTypes::ShortIOInfo":
return _pyUConnector.UConnector_getTimeChange(self, *args)
def getSensorID(self, name):
def getSensorID(self, name: 'std::string const &') -> "long":
return _pyUConnector.UConnector_getSensorID(self, name)
def getNodeID(self, name):
def getNodeID(self, name: 'std::string const &') -> "long":
return _pyUConnector.UConnector_getNodeID(self, name)
def getObjectID(self, name):
def getObjectID(self, name: 'std::string const &') -> "long":
return _pyUConnector.UConnector_getObjectID(self, name)
def getShortName(self, id):
def getShortName(self, id: 'long') -> "std::string":
return _pyUConnector.UConnector_getShortName(self, id)
def getName(self, id):
def getName(self, id: 'long') -> "std::string":
return _pyUConnector.UConnector_getName(self, id)
def getTextName(self, id):
def getTextName(self, id: 'long') -> "std::string":
return _pyUConnector.UConnector_getTextName(self, id)
def getObjectInfo(self, *args):
def getObjectInfo(self, *args) -> "std::string":
return _pyUConnector.UConnector_getObjectInfo(self, *args)
def apiRequest(self, *args):
def apiRequest(self, *args) -> "std::string":
return _pyUConnector.UConnector_apiRequest(self, *args)
def activate_objects(self):
def activate_objects(self) -> "void":
return _pyUConnector.UConnector_activate_objects(self)
UConnector_swigregister = _pyUConnector.UConnector_swigregister
UConnector_swigregister(UConnector)
# This file is compatible with both classic and new-style classes.
......@@ -55,7 +55,10 @@ def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if method:
return method(self, value)
if (not static):
self.__dict__[name] = value
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
......@@ -80,7 +83,15 @@ def _swig_repr(self):
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class UException:
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
class UException(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UException, name, value)
__swig_getmethods__ = {}
......@@ -96,10 +107,12 @@ class UException:
__swig_destroy__ = _pyUExceptions.delete_UException
__del__ = lambda self: None
def getError(self):
def getError(self) -> "std::string const":
return _pyUExceptions.UException_getError(self)
__swig_setmethods__["err"] = _pyUExceptions.UException_err_set
__swig_getmethods__["err"] = _pyUExceptions.UException_err_get
if _newclass:
err = property(_pyUExceptions.UException_err_get, _pyUExceptions.UException_err_set)
UException_swigregister = _pyUExceptions.UException_swigregister
UException_swigregister(UException)
......@@ -169,5 +182,6 @@ class UValidateError(UException):
UValidateError_swigregister = _pyUExceptions.UValidateError_swigregister
UValidateError_swigregister(UValidateError)
# This file is compatible with both classic and new-style classes.
......@@ -55,7 +55,10 @@ def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if method:
return method(self, value)
if (not static):
self.__dict__[name] = value
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
......@@ -80,7 +83,15 @@ def _swig_repr(self):
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class UModbus:
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
class UModbus(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UModbus, name, value)
__swig_getmethods__ = {}
......@@ -96,46 +107,47 @@ class UModbus:
__swig_destroy__ = _pyUModbus.delete_UModbus
__del__ = lambda self: None
def getUIType(self):
def getUIType(self) -> "std::string":
return _pyUModbus.UModbus_getUIType(self)
def isWriteFunction(self, mbfunc):
def isWriteFunction(self, mbfunc: 'int') -> "bool":
return _pyUModbus.UModbus_isWriteFunction(self, mbfunc)
def prepare(self, ip, port):
def prepare(self, ip: 'std::string const &', port: 'int') -> "void":
return _pyUModbus.UModbus_prepare(self, ip, port)
def connect(self, ip, port):
def connect(self, ip: 'std::string const &', port: 'int') -> "void":
return _pyUModbus.UModbus_connect(self, ip, port)
def conn_port(self):
def conn_port(self) -> "int":
return _pyUModbus.UModbus_conn_port(self)
def conn_ip(self):
def conn_ip(self) -> "std::string":
return _pyUModbus.UModbus_conn_ip(self)
def isConnection(self):
def isConnection(self) -> "bool":
return _pyUModbus.UModbus_isConnection(self)
def setTimeout(self, msec):
def setTimeout(self, msec: 'int') -> "void":
return _pyUModbus.UModbus_setTimeout(self, msec)
def mbread(self, *args):
def mbread(self, *args) -> "long":
return _pyUModbus.UModbus_mbread(self, *args)
def getWord(self, addr, mbreg, mbfunc=0x4):
def getWord(self, addr: 'int', mbreg: 'int', mbfunc: 'int'=0x4) -> "long":
return _pyUModbus.UModbus_getWord(self, addr, mbreg, mbfunc)
def getByte(self, addr, mbreg, mbfunc=0x4):
def getByte(self, addr: 'int', mbreg: 'int', mbfunc: 'int'=0x4) -> "long":
return _pyUModbus.UModbus_getByte(self, addr, mbreg, mbfunc)
def getBit(self, addr, mbreg, mbfunc=0x2):
def getBit(self, addr: 'int', mbreg: 'int', mbfunc: 'int'=0x2) -> "bool":
return _pyUModbus.UModbus_getBit(self, addr, mbreg, mbfunc)
def mbwrite(self, *args):
def mbwrite(self, *args) -> "void":
return _pyUModbus.UModbus_mbwrite(self, *args)
UModbus_swigregister = _pyUModbus.UModbus_swigregister
UModbus_swigregister(UModbus)
# This file is compatible with both classic and new-style classes.
......@@ -55,7 +55,10 @@ def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if method:
return method(self, value)
if (not static):
self.__dict__[name] = value
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
......@@ -80,51 +83,59 @@ def _swig_repr(self):
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
def uniset_init_params(p, xmlfile):
def uniset_init_params(p: 'Params', xmlfile: 'std::string const &') -> "void":
return _pyUniSet.uniset_init_params(p, xmlfile)
uniset_init_params = _pyUniSet.uniset_init_params
def uniset_init(argc, argv, xmlfile):
def uniset_init(argc: 'int', argv: 'char **', xmlfile: 'std::string const &') -> "void":
return _pyUniSet.uniset_init(argc, argv, xmlfile)
uniset_init = _pyUniSet.uniset_init
def uniset_activate_objects():
def uniset_activate_objects() -> "void":
return _pyUniSet.uniset_activate_objects()
uniset_activate_objects = _pyUniSet.uniset_activate_objects
def getValue(id):
def getValue(id: 'long') -> "long":
return _pyUniSet.getValue(id)
getValue = _pyUniSet.getValue
def setValue(*args):
def setValue(*args) -> "void":
return _pyUniSet.setValue(*args)
setValue = _pyUniSet.setValue
def getSensorID(name):
def getSensorID(name: 'std::string const &') -> "long":
return _pyUniSet.getSensorID(name)
getSensorID = _pyUniSet.getSensorID
def getObjectID(name):
def getObjectID(name: 'std::string const &') -> "long":
return _pyUniSet.getObjectID(name)
getObjectID = _pyUniSet.getObjectID
def getShortName(id):
def getShortName(id: 'long') -> "std::string":
return _pyUniSet.getShortName(id)
getShortName = _pyUniSet.getShortName
def getName(id):
def getName(id: 'long') -> "std::string":
return _pyUniSet.getName(id)
getName = _pyUniSet.getName
def getTextName(id):
def getTextName(id: 'long') -> "std::string":
return _pyUniSet.getTextName(id)
getTextName = _pyUniSet.getTextName
def getConfFileName():
def getConfFileName() -> "std::string":
return _pyUniSet.getConfFileName()
getConfFileName = _pyUniSet.getConfFileName
class Params:
class Params(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Params, name, value)
__swig_getmethods__ = {}
......@@ -139,16 +150,23 @@ class Params:
except __builtin__.Exception:
self.this = this
def add(self, s):
def add(self, s: 'char *') -> "bool":
return _pyUniSet.Params_add(self, s)
def add_str(self, s):
def add_str(self, s: 'std::string const') -> "bool":
return _pyUniSet.Params_add_str(self, s)
__swig_setmethods__["argc"] = _pyUniSet.Params_argc_set
__swig_getmethods__["argc"] = _pyUniSet.Params_argc_get
if _newclass:
argc = property(_pyUniSet.Params_argc_get, _pyUniSet.Params_argc_set)
__swig_setmethods__["argv"] = _pyUniSet.Params_argv_set
__swig_getmethods__["argv"] = _pyUniSet.Params_argv_get
inst = _pyUniSet.Params_inst
if _newclass:
argv = property(_pyUniSet.Params_argv_get, _pyUniSet.Params_argv_set)
if _newclass:
inst = staticmethod(_pyUniSet.Params_inst)
else:
inst = _pyUniSet.Params_inst
__swig_destroy__ = _pyUniSet.delete_Params
__del__ = lambda self: None
Params_swigregister = _pyUniSet.Params_swigregister
......@@ -157,11 +175,11 @@ cvar = _pyUniSet.cvar
DefaultID = cvar.DefaultID
DefaultSupplerID = cvar.DefaultSupplerID
def Params_inst():
def Params_inst() -> "UTypes::Params":
return _pyUniSet.Params_inst()
Params_inst = _pyUniSet.Params_inst
class ShortIOInfo:
class ShortIOInfo(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, ShortIOInfo, name, value)
__swig_getmethods__ = {}
......@@ -169,14 +187,24 @@ class ShortIOInfo:
__repr__ = _swig_repr
__swig_setmethods__["value"] = _pyUniSet.ShortIOInfo_value_set
__swig_getmethods__["value"] = _pyUniSet.ShortIOInfo_value_get
if _newclass:
value = property(_pyUniSet.ShortIOInfo_value_get, _pyUniSet.ShortIOInfo_value_set)
__swig_setmethods__["tv_sec"] = _pyUniSet.ShortIOInfo_tv_sec_set
__swig_getmethods__["tv_sec"] = _pyUniSet.ShortIOInfo_tv_sec_get
if _newclass:
tv_sec = property(_pyUniSet.ShortIOInfo_tv_sec_get, _pyUniSet.ShortIOInfo_tv_sec_set)
__swig_setmethods__["tv_nsec"] = _pyUniSet.ShortIOInfo_tv_nsec_set
__swig_getmethods__["tv_nsec"] = _pyUniSet.ShortIOInfo_tv_nsec_get
if _newclass:
tv_nsec = property(_pyUniSet.ShortIOInfo_tv_nsec_get, _pyUniSet.ShortIOInfo_tv_nsec_set)
__swig_setmethods__["supplier"] = _pyUniSet.ShortIOInfo_supplier_set
__swig_getmethods__["supplier"] = _pyUniSet.ShortIOInfo_supplier_get
if _newclass:
supplier = property(_pyUniSet.ShortIOInfo_supplier_get, _pyUniSet.ShortIOInfo_supplier_set)
__swig_setmethods__["supplier_node"] = _pyUniSet.ShortIOInfo_supplier_node_set
__swig_getmethods__["supplier_node"] = _pyUniSet.ShortIOInfo_supplier_node_get
if _newclass:
supplier_node = property(_pyUniSet.ShortIOInfo_supplier_node_get, _pyUniSet.ShortIOInfo_supplier_node_set)
def __init__(self):
this = _pyUniSet.new_ShortIOInfo()
......@@ -205,7 +233,7 @@ class UException(Exception):
__swig_destroy__ = _pyUniSet.delete_UException
__del__ = lambda self: None
def getError(self):
def getError(self) -> "std::string const":
return _pyUniSet.UException_getError(self)
__swig_setmethods__["err"] = _pyUniSet.UException_err_set
__swig_getmethods__["err"] = _pyUniSet.UException_err_get
......@@ -278,7 +306,7 @@ class UValidateError(UException):
UValidateError_swigregister = _pyUniSet.UValidateError_swigregister
UValidateError_swigregister(UValidateError)
class UProxyObject:
class UProxyObject(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UProxyObject, name, value)
__swig_getmethods__ = {}
......@@ -294,34 +322,35 @@ class UProxyObject:
__swig_destroy__ = _pyUniSet.delete_UProxyObject
__del__ = lambda self: None
def addToAsk(self, id):
def addToAsk(self, id: 'long') -> "void":
return _pyUniSet.UProxyObject_addToAsk(self, id)
def askSensor(self, id):
def askSensor(self, id: 'long') -> "void":
return _pyUniSet.UProxyObject_askSensor(self, id)
def getValue(self, id):
def getValue(self, id: 'long') -> "long":
return _pyUniSet.UProxyObject_getValue(self, id)
def getFloatValue(self, id):
def getFloatValue(self, id: 'long') -> "float":
return _pyUniSet.UProxyObject_getFloatValue(self, id)
def setValue(self, id, val):
def setValue(self, id: 'long', val: 'long') -> "void":
return _pyUniSet.UProxyObject_setValue(self, id, val)
def askIsOK(self):
def askIsOK(self) -> "bool":
return _pyUniSet.UProxyObject_askIsOK(self)
def reaskSensors(self):
def reaskSensors(self) -> "bool":
return _pyUniSet.UProxyObject_reaskSensors(self)
def updateValues(self):
def updateValues(self) -> "bool":
return _pyUniSet.UProxyObject_updateValues(self)
def smIsOK(self):
def smIsOK(self) -> "bool":
return _pyUniSet.UProxyObject_smIsOK(self)
UProxyObject_swigregister = _pyUniSet.UProxyObject_swigregister
UProxyObject_swigregister(UProxyObject)
# This file is compatible with both classic and new-style classes.
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------------------------------------
# Description: uniset netdata python.d module
......
#!/usr/bin/env python2.7
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......
#!/usr/bin/env python2.7
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment