mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-09 07:28:03 +01:00
Merge tag 'unstable/0.11.0_rc1' into pkg/debian_rc
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,7 +3,7 @@
|
|||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="ES6" />
|
||||||
</component>
|
</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">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
2
.idea/revpipyload.iml
generated
2
.idea/revpipyload.iml
generated
@@ -5,7 +5,7 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</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" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PackageRequirementsSettings">
|
<component name="PackageRequirementsSettings">
|
||||||
|
|||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -3,6 +3,8 @@
|
|||||||
<component name="CommitMessageInspectionProfile">
|
<component name="CommitMessageInspectionProfile">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<inspection_tool class="BodyLimit" enabled="true" level="WARNING" enabled_by_default="true" />
|
<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="SubjectBodySeparation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
|
|||||||
66
Makefile
66
Makefile
@@ -4,40 +4,74 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
|
|||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
PACKAGE = revpipyload
|
PACKAGE = revpipyload
|
||||||
|
APP_NAME = RevPiPyLoad
|
||||||
|
APP_IDENT = org.revpimodio.revpipyload
|
||||||
|
|
||||||
# If virtualenv exists, use it. If not, use PATH to find, except python3
|
# Set path to create the virtual environment with package name
|
||||||
SYSTEM_PYTHON = /usr/bin/python3
|
ifdef PYTHON3_VENV
|
||||||
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
|
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
|
.PHONY: all
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
|
venv-info:
|
||||||
|
@echo Environment for $(APP_NAME) $(APP_VERSION)
|
||||||
|
@echo Using path: "$(VENV_PATH)"
|
||||||
|
exit 0
|
||||||
|
|
||||||
venv:
|
venv:
|
||||||
$(SYSTEM_PYTHON) -m venv venv
|
# Start with empty environment
|
||||||
source venv/bin/activate && \
|
"$(SYSTEM_PYTHON)" -m venv "$(VENV_PATH)"
|
||||||
|
source "$(VENV_PATH)/bin/activate" && \
|
||||||
python3 -m pip install --upgrade pip && \
|
python3 -m pip install --upgrade pip && \
|
||||||
python3 -m pip install -r requirements.txt
|
python3 -m pip install -r requirements.txt
|
||||||
exit 0
|
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:
|
build:
|
||||||
$(PYTHON) -m setup sdist
|
"$(PYTHON)" -m setup sdist
|
||||||
$(PYTHON) -m setup bdist_wheel
|
"$(PYTHON)" -m setup bdist_wheel
|
||||||
|
|
||||||
install: build
|
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
|
||||||
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
|
distclean: clean
|
||||||
rm -R venv
|
# Virtual environment
|
||||||
|
rm -rf "$(VENV_PATH)"
|
||||||
|
|
||||||
.PHONY: clean clean-all
|
.PHONY: clean distclean
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ __author__ = "Sven Sager"
|
|||||||
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
||||||
__license__ = "GPLv2"
|
__license__ = "GPLv2"
|
||||||
__package__ = "revpipyload"
|
__package__ = "revpipyload"
|
||||||
__version__ = "0.10.0"
|
__version__ = "0.11.0rc1"
|
||||||
|
|||||||
@@ -17,14 +17,7 @@ if __package__ == "":
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) == 2 and "--version" in sys.argv:
|
# Use absolut import in the __main__ module
|
||||||
# Catch --version, if this is the only argument (sys.argv[0] is always the script name)
|
|
||||||
from revpipyload import __version__
|
|
||||||
|
|
||||||
print(__version__)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
else:
|
|
||||||
from revpipyload.revpipyload import main
|
from revpipyload.revpipyload import main
|
||||||
|
|
||||||
# Run the main application of this package
|
# Run the main application of this package
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import sys
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
|
||||||
|
from . import __version__
|
||||||
|
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
forked = False
|
forked = False
|
||||||
globalconffile = None
|
globalconffile = None
|
||||||
@@ -42,6 +44,11 @@ def configure():
|
|||||||
parser = ArgumentParser(
|
parser = ArgumentParser(
|
||||||
description="RevolutionPi Python Loader"
|
description="RevolutionPi Python Loader"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--version",
|
||||||
|
action="version",
|
||||||
|
version="%(prog)s {0}".format(__version__)
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-d", "--daemon", action="store_true", dest="daemon",
|
"-d", "--daemon", action="store_true", dest="daemon",
|
||||||
help="Run program as a daemon in background"
|
help="Run program as a daemon in background"
|
||||||
|
|||||||
@@ -477,6 +477,8 @@ class RevPiPyLoad:
|
|||||||
# XML Modus 4 Einstellungen ändern
|
# XML Modus 4 Einstellungen ändern
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
4, self.xml_setconfig, "set_config")
|
4, self.xml_setconfig, "set_config")
|
||||||
|
self.xsrv.register_function(
|
||||||
|
4, self.xml_setplcprogram, "set_plcprogram")
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
4, self.xml_setpictoryrsc, "set_pictoryrsc")
|
4, self.xml_setpictoryrsc, "set_pictoryrsc")
|
||||||
|
|
||||||
@@ -1294,6 +1296,7 @@ class RevPiPyLoad:
|
|||||||
("plcslaveport", "plcserverport"),
|
("plcslaveport", "plcserverport"),
|
||||||
("plcslavewatchdog", "plcserverwatchdog"),
|
("plcslavewatchdog", "plcserverwatchdog"),
|
||||||
):
|
):
|
||||||
|
if key_from in dc:
|
||||||
dc[key_to] = dc[key_from]
|
dc[key_to] = dc[key_from]
|
||||||
del dc[key_from]
|
del dc[key_from]
|
||||||
|
|
||||||
@@ -1358,11 +1361,39 @@ class RevPiPyLoad:
|
|||||||
"".format(self.xmlrpcacl.filename)
|
"".format(self.xmlrpcacl.filename)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if loadnow:
|
||||||
# RevPiPyLoad neu konfigurieren
|
# RevPiPyLoad neu konfigurieren
|
||||||
self.evt_loadconfig.set()
|
self.evt_loadconfig.set()
|
||||||
|
|
||||||
return True
|
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):
|
def xml_setpictoryrsc(self, filebytes, reset=False):
|
||||||
"""Schreibt die config.rsc Datei von piCotry.
|
"""Schreibt die config.rsc Datei von piCotry.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user