Merge tag 'unstable/0.11.0_rc1' into pkg/debian_rc

This commit is contained in:
2023-10-27 16:23:28 +02:00
8 changed files with 101 additions and 34 deletions

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (revpipyload)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (revpipyload)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>

2
.idea/revpipyload.iml generated
View File

@@ -5,7 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.8 (revpipyload)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.11 (revpipyload)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PackageRequirementsSettings">

2
.idea/vcs.xml generated
View File

@@ -3,6 +3,8 @@
<component name="CommitMessageInspectionProfile">
<profile version="1.0">
<inspection_tool class="BodyLimit" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SubjectBodySeparation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>

View File

@@ -4,40 +4,74 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
# Variables
PACKAGE = revpipyload
APP_NAME = RevPiPyLoad
APP_IDENT = org.revpimodio.revpipyload
# If virtualenv exists, use it. If not, use PATH to find, except python3
SYSTEM_PYTHON = /usr/bin/python3
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
# Set path to create the virtual environment with package name
ifdef PYTHON3_VENV
VENV_PATH = $(PYTHON3_VENV)/$(PACKAGE)
else
VENV_PATH = venv
endif
all: build
# If virtualenv exists, use it. If not, use PATH to find commands
SYSTEM_PYTHON = python3
PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
APP_VERSION = $(shell "$(PYTHON)" src/$(PACKAGE) --version | cut -d ' ' -f 2)
all: test build
.PHONY: all
## Environment
venv-info:
@echo Environment for $(APP_NAME) $(APP_VERSION)
@echo Using path: "$(VENV_PATH)"
exit 0
venv:
$(SYSTEM_PYTHON) -m venv venv
source venv/bin/activate && \
# Start with empty environment
"$(SYSTEM_PYTHON)" -m venv "$(VENV_PATH)"
source "$(VENV_PATH)/bin/activate" && \
python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt
exit 0
.PHONY: venv
venv-ssp:
# Include system installed site-packages and add just missing modules
"$(SYSTEM_PYTHON)" -m venv --system-site-packages "$(VENV_PATH)"
source "$(VENV_PATH)/bin/activate" && \
python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt
exit 0
## Build, install
.PHONY: venv-info venv venv-ssp
## Build steps
build:
$(PYTHON) -m setup sdist
$(PYTHON) -m setup bdist_wheel
"$(PYTHON)" -m setup sdist
"$(PYTHON)" -m setup bdist_wheel
install: build
$(PYTHON) -m pip install dist/$(PACKAGE)-*.whl
"$(PYTHON)" -m pip install dist/$(PACKAGE)-$(APP_VERSION)-*.whl
.PHONY: build install
uninstall:
"$(PYTHON)" -m pip uninstall --yes $(PACKAGE)
.PHONY: test build install uninstall
## Clean
clean:
rm -rf build dist src/*.egg-info *.spec
# PyTest caches
rm -rf .pytest_cache
# Build artifacts
rm -rf build dist src/*.egg-info
# PyInstaller created files
rm -rf *.spec
clean-all: clean
rm -R venv
distclean: clean
# Virtual environment
rm -rf "$(VENV_PATH)"
.PHONY: clean clean-all
.PHONY: clean distclean

View File

@@ -4,4 +4,4 @@ __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv2"
__package__ = "revpipyload"
__version__ = "0.10.0"
__version__ = "0.11.0rc1"

View File

@@ -17,15 +17,8 @@ if __package__ == "":
if __name__ == "__main__":
import sys
if len(sys.argv) == 2 and "--version" in sys.argv:
# Catch --version, if this is the only argument (sys.argv[0] is always the script name)
from revpipyload import __version__
# Use absolut import in the __main__ module
from revpipyload.revpipyload import main
print(__version__)
sys.exit(0)
else:
from revpipyload.revpipyload import main
# Run the main application of this package
sys.exit(main())
# Run the main application of this package
sys.exit(main())

View File

@@ -10,6 +10,8 @@ import sys
from argparse import ArgumentParser
from configparser import ConfigParser
from . import __version__
conf = ConfigParser()
forked = False
globalconffile = None
@@ -42,6 +44,11 @@ def configure():
parser = ArgumentParser(
description="RevolutionPi Python Loader"
)
parser.add_argument(
"--version",
action="version",
version="%(prog)s {0}".format(__version__)
)
parser.add_argument(
"-d", "--daemon", action="store_true", dest="daemon",
help="Run program as a daemon in background"

View File

@@ -477,6 +477,8 @@ class RevPiPyLoad:
# XML Modus 4 Einstellungen ändern
self.xsrv.register_function(
4, self.xml_setconfig, "set_config")
self.xsrv.register_function(
4, self.xml_setplcprogram, "set_plcprogram")
self.xsrv.register_function(
4, self.xml_setpictoryrsc, "set_pictoryrsc")
@@ -1294,8 +1296,9 @@ class RevPiPyLoad:
("plcslaveport", "plcserverport"),
("plcslavewatchdog", "plcserverwatchdog"),
):
dc[key_to] = dc[key_from]
del dc[key_from]
if key_from in dc:
dc[key_to] = dc[key_from]
del dc[key_from]
# Werte übernehmen, die eine Definition in key haben (andere nicht)
for sektion in keys:
@@ -1358,11 +1361,39 @@ class RevPiPyLoad:
"".format(self.xmlrpcacl.filename)
)
# RevPiPyLoad neu konfigurieren
self.evt_loadconfig.set()
if loadnow:
# RevPiPyLoad neu konfigurieren
self.evt_loadconfig.set()
return True
def xml_setplcprogram(self, plcprogram: str) -> int:
"""
Set new plc program, without restart services.
:returns: 0 Erfolgreich
-1 Programm lauft noch
-2 Datei nicht gefunden
"""
if type(plcprogram) is not str:
raise TypeError("The given plc program must be <class 'str'>")
if not plcprogram:
raise ValueError("Empty string not allowed for plc program")
stop_code = self.xml_plcstop()
# Set the new plc program setting to activ configuration
self.plcprogram = plcprogram
# Save the new value to config file without reload
self.xml_setconfig({"plcprogram": plcprogram}, False)
# Start the program, if it was running before change
if stop_code > -1:
return self.xml_plcstart()
return 0
def xml_setpictoryrsc(self, filebytes, reset=False):
"""Schreibt die config.rsc Datei von piCotry.