domoticz: update to 2023.2

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
David Woodhouse 2023-11-28 23:07:26 +00:00 committed by Rosen Penev
parent a0d7e40494
commit 5bc25c0cdc
8 changed files with 3 additions and 4892 deletions

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=domoticz
PKG_VERSION:=2022.1
PKG_RELEASE:=5
PKG_VERSION:=2023.2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/domoticz/domoticz/tar.gz/$(PKG_VERSION)?
PKG_HASH:=8282cb71c924b6ef92503976d50f966f2c785eab8f8cffa1136ac133f0241157
PKG_HASH:=32bcf49df8c80c470352e63004a82d9601b90ccf406096099656250a4515ac28
PKG_MAINTAINER:=David Woodhouse <dwmw2@infradead.org>
PKG_LICENSE:=GPL-3.0

View File

@ -1,29 +0,0 @@
From 2975b1113d9540f39b6bade3b6d459b61c2e5007 Mon Sep 17 00:00:00 2001
From: Arjen de Korte <build+github@de-korte.org>
Date: Sun, 15 May 2022 19:00:02 +0200
Subject: [PATCH] Fix compilation with GCC12
Building domoticz fails under GCC12 with the following error:
In file included from /usr/include/c++/12/utility:68,
from /home/abuild/rpmbuild/BUILD/domoticz-2022.1/main/LuaTable.cpp:10:
/usr/include/c++/12/bits/stl_relops.h:86:5: error: template with C linkage
86 | template <class _Tp>
| ^~~~~~~~
---
main/LuaTable.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/main/LuaTable.cpp
+++ b/main/LuaTable.cpp
@@ -6,9 +6,9 @@ extern "C" {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
+}
#include <utility>
-}
CLuaTable::CLuaTable(lua_State *lua_state, const std::string &Name)
{

View File

@ -1,41 +0,0 @@
From 3c23a7863c0b01273d4c36423769443ea7e4a7bb Mon Sep 17 00:00:00 2001
From: David Woodhouse <dwmw2@infradead.org>
Date: Fri, 5 Jun 2020 15:02:41 +0100
Subject: [PATCH 1/2] unzip: reduce file name size to 65535 to work with
external minizip
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The external minizip project has changed the unzGetCurrentFileInfo()
function to take a uint16_t as the filename size, instead of a uLong
as in the original version in zlib.
(Reported as https://github.com/nmoinvaz/minizip/issues/490 but it
was 3½ years ago and might be too late to fix it now, although changing
it back to a *larger* type is a lot safer than reducing the size, and
perhaps they should.)
This means that our 65536-byte buffer gets truncated to zero, as the
compiler tells us when we build agaisnt the external minizip:
domoticz/main/unzip_stream.h:140:50: warning: conversion from long unsigned int to uint16_t {aka short unsigned int} changes value from 65536 to 0 [-Woverflow]
140 | unzGetCurrentFileInfo(handler_, &info, path, sizeof(path), NULL, 0, NULL, 0);
| ^~~~~~~~~~~~
Reduce the buffer size to 65535 bytes instead.
---
main/unzip_stream.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/main/unzip_stream.h
+++ b/main/unzip_stream.h
@@ -143,7 +143,7 @@ namespace clx {
basic_unzip_stream& open(handler_type h) {
handler_ = h;
if (handler_) {
- char path[65536];
+ char path[65535];
unz_file_info info;
unzGetCurrentFileInfo(handler_, &info, path, sizeof(path), NULL, 0, NULL, 0);
path_ = path;

File diff suppressed because it is too large Load Diff

View File

@ -1,175 +0,0 @@
From a9df45497dc79023ed1864dd9b8e435935220171 Mon Sep 17 00:00:00 2001
From: dnpwwo <kendel.boul@gmail.com>
Date: Tue, 1 Mar 2022 13:09:01 +1100
Subject: [PATCH] BugFix: Linux crash when formating Python exceptions Other:
Continue code cleanup
---
hardware/plugins/Plugins.cpp | 45 +++++++++++-------------------------
hardware/plugins/Plugins.h | 3 ++-
main/EventsPythonModule.cpp | 6 ++---
3 files changed, 18 insertions(+), 36 deletions(-)
--- a/hardware/plugins/Plugins.cpp
+++ b/hardware/plugins/Plugins.cpp
@@ -724,13 +724,7 @@ namespace Plugins
}
else
{
- std::string sTypeText("Unknown");
- if (pExcept)
- {
- PyTypeObject* TypeName = (PyTypeObject*)pExcept;
- PyNewRef pName = PyObject_GetAttrString((PyObject*)TypeName, "__name__");
- sTypeText = (std::string)pName;
- }
+ std::string sTypeText("Unknown Error");
/* See if we can get a full traceback */
PyNewRef pModule = PyImport_ImportModule("traceback");
@@ -738,7 +732,7 @@ namespace Plugins
{
PyNewRef pFunc = PyObject_GetAttrString(pModule, "format_exception");
if (pFunc && PyCallable_Check(pFunc)) {
- PyNewRef pList = PyObject_CallFunctionObjArgs(pFunc, pExcept, pValue, pTraceback, NULL);
+ PyNewRef pList = PyObject_CallFunctionObjArgs(pFunc, (PyObject*)pExcept, (PyObject*)pValue, (PyObject*)pTraceback, NULL);
if (pList)
{
for (Py_ssize_t i = 0; i < PyList_Size(pList); i++)
@@ -756,16 +750,19 @@ namespace Plugins
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
Log(LOG_ERROR, "Exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
Log(LOG_ERROR, "'format_exception' lookup failed, exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
Log(LOG_ERROR, "'Traceback' module import failed, exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
@@ -1950,7 +1947,7 @@ namespace Plugins
}
}
- void CPlugin::Callback(PyObject *pTarget, const std::string &sHandler, PyObject *pParams)
+ void CPlugin::Callback(PyBorrowedRef& pTarget, const std::string &sHandler, PyObject *pParams)
{
try
{
@@ -1966,19 +1963,8 @@ namespace Plugins
PyNewRef pFunc = PyObject_GetAttrString(pTarget, sHandler.c_str());
if (pFunc && PyCallable_Check(pFunc))
{
- module_state *pModState = nullptr;
- PyBorrowedRef brModule = PyState_FindModule(&DomoticzModuleDef);
- if (!brModule)
- {
- brModule = PyState_FindModule(&DomoticzExModuleDef);
- }
-
- if (brModule)
- {
- pModState = ((struct module_state *)PyModule_GetState(brModule));
- }
-
// Store the callback object so the Dump function has context if invoked
+ module_state* pModState = FindModule();
if (pModState)
{
pModState->lastCallback = pTarget;
@@ -1986,14 +1972,12 @@ namespace Plugins
if (m_bDebug & PDM_QUEUE)
{
- PyNewRef pName = PyObject_GetAttrString((PyObject*)(pTarget->ob_type), "__name__");
- if (pName)
- Log(LOG_NORM, "Calling message handler '%s' on '%s' type object.", sHandler.c_str(), (std::string(pName).c_str()));
+ Log(LOG_NORM, "Calling message handler '%s' on '%s' type object.", sHandler.c_str(), pTarget.Type().c_str());
}
PyErr_Clear();
- // Invokde the callback function
+ // Invoke the callback function
PyNewRef pReturnValue = PyObject_CallObject(pFunc, pParams);
if (pModState)
@@ -2020,17 +2004,14 @@ namespace Plugins
std::string sAttrName = pItem;
if (sAttrName.substr(0, 2) != "__") // ignore system stuff
{
- if (PyObject_HasAttrString(pTarget, sAttrName.c_str()))
+ std::string strValue = pTarget.Attribute(sAttrName);
+ if (strValue.length())
{
PyNewRef pValue = PyObject_GetAttrString(pTarget, sAttrName.c_str());
if (!PyCallable_Check(pValue)) // Filter out methods
{
- std::string strValue = pValue;
- if (strValue.length())
- {
- std::string sBlank((sAttrName.length() < 20) ? 20 - sAttrName.length() : 0, ' ');
- Log(LOG_NORM, " ----> '%s'%s '%s'", sAttrName.c_str(), sBlank.c_str(), strValue.c_str());
- }
+ std::string sBlank((sAttrName.length() < 20) ? 20 - sAttrName.length() : 0, ' ');
+ Log(LOG_NORM, " ----> '%s'%s '%s'", sAttrName.c_str(), sBlank.c_str(), strValue.c_str());
}
}
}
--- a/hardware/plugins/Plugins.h
+++ b/hardware/plugins/Plugins.h
@@ -92,7 +92,7 @@ namespace Plugins {
void ConnectionWrite(CDirectiveBase *);
void ConnectionDisconnect(CDirectiveBase *);
void DisconnectEvent(CEventBase *);
- void Callback(PyObject* pTarget, const std::string &sHandler, PyObject *pParams);
+ void Callback(PyBorrowedRef& pTarget, const std::string &sHandler, PyObject *pParams);
void RestoreThread();
void ReleaseThread();
void Stop();
@@ -157,6 +157,7 @@ namespace Plugins {
m_pObject = pObject;
};
std::string Attribute(const char* name);
+ std::string Attribute(std::string& name) { return Attribute(name.c_str()); };
std::string Type();
bool IsDict() { return TypeCheck(Py_TPFLAGS_DICT_SUBCLASS); };
bool IsList() { return TypeCheck(Py_TPFLAGS_LIST_SUBCLASS); };
--- a/main/EventsPythonModule.cpp
+++ b/main/EventsPythonModule.cpp
@@ -297,7 +297,7 @@ namespace Plugins
PyBorrowedRef pModule = PythonEventsGetModule();
if (pModule)
{
- PyBorrowedRef pModuleDict = Plugins::PyModule_GetDict(pModule);
+ PyBorrowedRef pModuleDict = PyModule_GetDict(pModule);
if (!pModuleDict)
{
_log.Log(LOG_ERROR, "Python EventSystem: Failed to open module dictionary.");
@@ -312,7 +312,7 @@ namespace Plugins
return;
}
- PyNewRef pDeviceDict = Plugins::PyDict_New();
+ PyNewRef pDeviceDict = PyDict_New();
if (PyDict_SetItemString(pModuleDict, "Devices", pDeviceDict) == -1)
{
_log.Log(LOG_ERROR, "Python EventSystem: Failed to add Device dictionary.");
@@ -320,7 +320,7 @@ namespace Plugins
return;
}
- if (PyType_Ready((PyTypeObject*)Plugins::PDeviceType) < 0)
+ if (PyType_Ready((PyTypeObject*)PDeviceType) < 0)
{
_log.Log(LOG_ERROR, "Python EventSystem: Unable to ready DeviceType Object.");
PyEval_SaveThread();

View File

@ -1,224 +0,0 @@
From 90e683a16ec1f267d3efd1b3fd1bff0b9ac9691e Mon Sep 17 00:00:00 2001
From: dnpwwo <kendel.boul@gmail.com>
Date: Tue, 1 Mar 2022 22:01:14 +1100
Subject: [PATCH] BugFix: Prevent crash processing Python exceptions on Linux.
Uplift: Create Device objects using Python rather than C++
---
main/EventsPythonDevice.h | 2 +-
main/EventsPythonModule.cpp | 92 ++++++++++++++++---------------------
2 files changed, 40 insertions(+), 54 deletions(-)
--- a/main/EventsPythonDevice.h
+++ b/main/EventsPythonDevice.h
@@ -55,6 +55,6 @@
nullptr,
nullptr };
- static PyObject* PDeviceType;
+ static PyTypeObject* PDeviceType;
}
#endif
--- a/main/EventsPythonModule.cpp
+++ b/main/EventsPythonModule.cpp
@@ -16,11 +16,11 @@ namespace Plugins
{
#define GETSTATE(m) ((struct eventModule_state*)PyModule_GetState(m))
- void* m_PyInterpreter;
- bool ModuleInitialized = false;
+ PyThreadState* m_PyInterpreter;
+ bool m_ModuleInitialized = false;
struct eventModule_state {
- PyObject* error;
+ PyObject* error;
};
static PyMethodDef DomoticzEventsMethods[] = {
@@ -116,7 +116,7 @@ namespace Plugins
PyType_Spec PDeviceSpec = { "DomoticzEvents.PDevice", sizeof(PDevice), 0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, PDeviceSlots };
- PDeviceType = PyType_FromSpec(&PDeviceSpec);
+ PDeviceType = (PyTypeObject*)PyType_FromSpec(&PDeviceSpec);
PyModule_AddObject(pModule, "PDevice", (PyObject*)PDeviceType);
return pModule;
@@ -169,7 +169,7 @@ namespace Plugins
_log.Log(LOG_ERROR, "EventSystem - Python: Failed to initialize module.");
return false;
}
- ModuleInitialized = true;
+ m_ModuleInitialized = true;
return true;
}
@@ -232,12 +232,6 @@ namespace Plugins
else
{
std::string sTypeText("Unknown");
- if (pExcept)
- {
- PyTypeObject* TypeName = (PyTypeObject*)pExcept;
- PyNewRef pName = PyObject_GetAttrString((PyObject*)TypeName, "__name__");
- sTypeText = (std::string)pName;
- }
/* See if we can get a full traceback */
PyNewRef pModule = PyImport_ImportModule("traceback");
@@ -245,7 +239,7 @@ namespace Plugins
{
PyNewRef pFunc = PyObject_GetAttrString(pModule, "format_exception");
if (pFunc && PyCallable_Check(pFunc)) {
- PyNewRef pList = PyObject_CallFunctionObjArgs(pFunc, pExcept, pValue, pTraceback, NULL);
+ PyNewRef pList = PyObject_CallFunctionObjArgs(pFunc, (PyObject*)pExcept, (PyObject*)pValue, (PyObject*)pTraceback, NULL);
if (pList)
{
for (Py_ssize_t i = 0; i < PyList_Size(pList); i++)
@@ -263,16 +257,19 @@ namespace Plugins
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
_log.Log(LOG_ERROR, "Exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
_log.Log(LOG_ERROR, "'format_exception' lookup failed, exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
else
{
+ if (pExcept) sTypeText = pExcept.Attribute("__name__");
_log.Log(LOG_ERROR, "'Traceback' module import failed, exception: '%s'. No traceback available.", sTypeText.c_str());
}
}
@@ -280,11 +277,11 @@ namespace Plugins
}
void PythonEventsProcessPython(const std::string &reason, const std::string &filename, const std::string &PyString,
- const uint64_t DeviceID, std::map<uint64_t, CEventSystem::_tDeviceStatus> m_devicestates,
- std::map<uint64_t, CEventSystem::_tUserVariable> m_uservariables, int intSunRise, int intSunSet)
+ const uint64_t DeviceID, std::map<uint64_t, CEventSystem::_tDeviceStatus> deviceStates,
+ std::map<uint64_t, CEventSystem::_tUserVariable> userVariables, int intSunRise, int intSunSet)
{
- if (!ModuleInitialized)
+ if (!m_ModuleInitialized)
{
return;
}
@@ -292,7 +289,7 @@ namespace Plugins
if (Py_IsInitialized())
{
if (m_PyInterpreter)
- PyEval_RestoreThread((PyThreadState *)m_PyInterpreter);
+ PyEval_RestoreThread(m_PyInterpreter);
PyBorrowedRef pModule = PythonEventsGetModule();
if (pModule)
@@ -305,7 +302,7 @@ namespace Plugins
return;
}
- PyNewRef pStrVal = PyUnicode_FromString(m_devicestates[DeviceID].deviceName.c_str());
+ PyNewRef pStrVal = PyUnicode_FromString(deviceStates[DeviceID].deviceName.c_str());
if (PyDict_SetItemString(pModuleDict, "changed_device_name", pStrVal) == -1)
{
_log.Log(LOG_ERROR, "Python EventSystem: Failed to set changed_device_name.");
@@ -327,22 +324,34 @@ namespace Plugins
return;
}
- // Mutex
- // boost::shared_lock<boost::shared_mutex> devicestatesMutexLock1(m_devicestatesMutex);
-
- for (auto it_type = m_devicestates.begin(); it_type != m_devicestates.end(); ++it_type)
+ for (auto it_type = deviceStates.begin(); it_type != deviceStates.end(); ++it_type)
{
CEventSystem::_tDeviceStatus sitem = it_type->second;
- // object deviceStatus = domoticz_module.attr("Device")(sitem.ID, sitem.deviceName, sitem.devType,
- // sitem.subType, sitem.switchtype, sitem.nValue, sitem.nValueWording, sitem.sValue,
- // sitem.lastUpdate); devices[sitem.deviceName] = deviceStatus;
- PDevice *aDevice = (PDevice *)PDevice_new((PyTypeObject*)PDeviceType, (PyObject *)nullptr, (PyObject *)nullptr);
- PyNewRef pKey = PyUnicode_FromString(sitem.deviceName.c_str());
+ PyNewRef nrArgList = Py_BuildValue("(iOiiiOiOO)", static_cast<int>(sitem.ID),
+ PyUnicode_FromString(sitem.deviceName.c_str()),
+ sitem.devType,
+ sitem.subType,
+ sitem.switchtype,
+ PyUnicode_FromString(sitem.sValue.c_str()),
+ sitem.nValue,
+ PyUnicode_FromString(sitem.nValueWording.c_str()),
+ PyUnicode_FromString(sitem.lastUpdate.c_str()));
+ if (!nrArgList)
+ {
+ _log.Log(LOG_ERROR, "Python EventSystem: Building device argument list failed for key %s.", sitem.deviceName.c_str());
+ continue;
+ }
+ PyNewRef pDevice = PyObject_CallObject((PyObject*)PDeviceType, nrArgList);
+ if (!pDevice)
+ {
+ _log.Log(LOG_ERROR, "Python EventSystem: Event Device object creation failed for key %s.", sitem.deviceName.c_str());
+ continue;
+ }
if (sitem.ID == DeviceID)
{
- if (PyDict_SetItemString(pModuleDict, "changed_device", (PyObject *)aDevice) == -1)
+ if (PyDict_SetItemString(pModuleDict, "changed_device", (PyObject *)pDevice) == -1)
{
_log.Log(LOG_ERROR,
"Python EventSystem: Failed to add device '%s' as changed_device.",
@@ -350,36 +359,13 @@ namespace Plugins
}
}
- if (PyDict_SetItem(pDeviceDict, pKey, (PyObject *)aDevice) == -1)
+ PyNewRef pKey = PyUnicode_FromString(sitem.deviceName.c_str());
+ if (PyDict_SetItem(pDeviceDict, pKey, (PyObject *)pDevice) == -1)
{
_log.Log(LOG_ERROR, "Python EventSystem: Failed to add device '%s' to device dictionary.",
sitem.deviceName.c_str());
}
- else
- {
-
- // _log.Log(LOG_ERROR, "Python EventSystem: nValueWording '%s' - done. ",
- // sitem.nValueWording.c_str());
-
- std::string temp_n_value_string = sitem.nValueWording;
-
- // If nValueWording contains %, unicode fails?
-
- aDevice->id = static_cast<int>(sitem.ID);
- aDevice->name = PyUnicode_FromString(sitem.deviceName.c_str());
- aDevice->type = sitem.devType;
- aDevice->sub_type = sitem.subType;
- aDevice->switch_type = sitem.switchtype;
- aDevice->n_value = sitem.nValue;
- aDevice->n_value_string = PyUnicode_FromString(temp_n_value_string.c_str());
- aDevice->s_value = Plugins::PyUnicode_FromString(sitem.sValue.c_str());
- aDevice->last_update_string = PyUnicode_FromString(sitem.lastUpdate.c_str());
- // _log.Log(LOG_STATUS, "Python EventSystem: deviceName %s added to device dictionary",
- // sitem.deviceName.c_str());
- }
- Py_DECREF(aDevice);
}
- // devicestatesMutexLock1.unlock();
// Time related
@@ -440,7 +426,7 @@ namespace Plugins
return;
}
- for (auto it_var = m_uservariables.begin(); it_var != m_uservariables.end(); ++it_var)
+ for (auto it_var = userVariables.begin(); it_var != userVariables.end(); ++it_var)
{
CEventSystem::_tUserVariable uvitem = it_var->second;
PyDict_SetItemString(userVariablesDict, uvitem.variableName.c_str(),

View File

@ -1,23 +0,0 @@
From fff4bef553cfd75030d473b3296ade88b3150909 Mon Sep 17 00:00:00 2001
From: Rob Peters <Info@Domoticz.com>
Date: Thu, 10 Mar 2022 07:09:18 +0100
Subject: [PATCH] Fixed compile error when PYTHON was disabled (Fixes #5187)
---
hardware/plugins/DelayedLink.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/hardware/plugins/DelayedLink.h
+++ b/hardware/plugins/DelayedLink.h
@@ -1,5 +1,5 @@
#pragma once
-
+#ifdef ENABLE_PYTHON
#ifdef WIN32
# define MS_NO_COREDLL 1
#else
@@ -574,3 +574,4 @@ static inline void py3__Py_XDECREF(PyObj
#endif
#pragma pop_macro("_DEBUG")
} // namespace Plugins
+#endif //#ifdef ENABLE_PYTHON

View File

@ -1,33 +0,0 @@
From ca4578980e373543d0561564863718c879fa7743 Mon Sep 17 00:00:00 2001
From: Rob Peters <Info@Domoticz.com>
Date: Thu, 10 Mar 2022 12:32:29 +0100
Subject: [PATCH] Making sure code can be compiled without Python
---
hardware/plugins/Plugins.h | 4 ++++
hardware/plugins/PythonObjects.h | 1 +
2 files changed, 5 insertions(+)
--- a/hardware/plugins/Plugins.h
+++ b/hardware/plugins/Plugins.h
@@ -1,5 +1,7 @@
#pragma once
+#ifdef ENABLE_PYTHON
+
#include "../DomoticzHardware.h"
#include "../hardwaretypes.h"
#include "../../notifications/NotificationBase.h"
@@ -300,3 +302,5 @@ namespace Plugins {
};
} // namespace Plugins
+
+#endif //#ifdef ENABLE_PYTHON
--- a/hardware/plugins/PythonObjects.h
+++ b/hardware/plugins/PythonObjects.h
@@ -169,3 +169,4 @@ namespace Plugins {
};
} // namespace Plugins
+