mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
Code style
This commit is contained in:
@@ -9,6 +9,8 @@ revpimodio2</h1>
|
||||
<p>
|
||||
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
</p><p>
|
||||
Webpage: https://revpimodio.org/
|
||||
</p><p>
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
|
||||
@@ -9,6 +9,8 @@ revpimodio2.__init__</h1>
|
||||
<p>
|
||||
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
</p><p>
|
||||
Webpage: https://revpimodio.org/
|
||||
</p><p>
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
@@ -20,7 +22,7 @@ fuehrt das Modul bei Datenaenderung aus.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>BOTH</td></tr><tr><td>FALLING</td></tr><tr><td>GREEN</td></tr><tr><td>INP</td></tr><tr><td>MEM</td></tr><tr><td>OFF</td></tr><tr><td>OUT</td></tr><tr><td>RED</td></tr><tr><td>RISING</td></tr><tr><td>__all__</td></tr><tr><td>__author__</td></tr><tr><td>__name__</td></tr><tr><td>__package__</td></tr><tr><td>__version__</td></tr>
|
||||
<tr><td>BOTH</td></tr><tr><td>FALLING</td></tr><tr><td>GREEN</td></tr><tr><td>INP</td></tr><tr><td>MEM</td></tr><tr><td>OFF</td></tr><tr><td>OUT</td></tr><tr><td>RED</td></tr><tr><td>RISING</td></tr><tr><td>__all__</td></tr><tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>__name__</td></tr><tr><td>__version__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ Bildet die App Sektion von piCtory ab.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ Modul fuer die Verwaltung der Devices.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Helperklassen und Tools.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Modul fuer die Verwaltung der IOs.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer piControl0 Zugriff.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer Netzwerkzugriff.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_syssync</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_syssync</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ Bildet die Summary-Sektion von piCtory ab.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
114
revpimodio2.e4p
114
revpimodio2.e4p
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
|
||||
<!-- eric project file for project revpimodio2 -->
|
||||
<!-- Saved: 2018-08-09, 08:14:06 -->
|
||||
<!-- Saved: 2018-08-12, 18:11:33 -->
|
||||
<!-- Copyright (C) 2018 Sven Sager, akira@narux.de -->
|
||||
<Project version="5.1">
|
||||
<Language>en_US</Language>
|
||||
@@ -14,40 +14,40 @@
|
||||
<Email>akira@narux.de</Email>
|
||||
<Eol index="1"/>
|
||||
<Sources>
|
||||
<Source>setup.py</Source>
|
||||
<Source>revpimodio2/modio.py</Source>
|
||||
<Source>revpimodio2/summary.py</Source>
|
||||
<Source>revpimodio2/app.py</Source>
|
||||
<Source>revpimodio2/io.py</Source>
|
||||
<Source>revpimodio2/__init__.py</Source>
|
||||
<Source>revpimodio2/app.py</Source>
|
||||
<Source>revpimodio2/device.py</Source>
|
||||
<Source>revpimodio2/helper.py</Source>
|
||||
<Source>revpimodio2/io.py</Source>
|
||||
<Source>revpimodio2/modio.py</Source>
|
||||
<Source>revpimodio2/netio.py</Source>
|
||||
<Source>test/test_dio_while2.py</Source>
|
||||
<Source>test/test_dio_mainloop.py</Source>
|
||||
<Source>revpimodio2/summary.py</Source>
|
||||
<Source>setup.py</Source>
|
||||
<Source>test/test_dio_cycleloop.py</Source>
|
||||
<Source>test/test_dio_mainloop.py</Source>
|
||||
<Source>test/test_dio_while2.py</Source>
|
||||
<Source>test/test_net_leistung.py</Source>
|
||||
<Source>test/web_cycleloop.py</Source>
|
||||
<Source>test/web_mainloop.py</Source>
|
||||
<Source>test/web_virtdevdriver.py</Source>
|
||||
<Source>test/test_netio_brett.py</Source>
|
||||
<Source>test/test_unit.py</Source>
|
||||
<Source>test/test_unit_fh.py</Source>
|
||||
<Source>test/test_unitnet.py</Source>
|
||||
<Source>test/web_benniesrun.py</Source>
|
||||
<Source>test/web_benniesrunxxl.py</Source>
|
||||
<Source>test/test_unit.py</Source>
|
||||
<Source>test/test_unitnet.py</Source>
|
||||
<Source>test/test_netio_brett.py</Source>
|
||||
<Source>test/web_startseite.py</Source>
|
||||
<Source>test/web_cycleloop.py</Source>
|
||||
<Source>test/web_mainloop.py</Source>
|
||||
<Source>test/web_rpidaten.py</Source>
|
||||
<Source>test/web_rpii2c.py</Source>
|
||||
<Source>test/test_unit_fh.py</Source>
|
||||
<Source>test/web_startseite.py</Source>
|
||||
<Source>test/web_virtdevdriver.py</Source>
|
||||
</Sources>
|
||||
<Forms/>
|
||||
<Translations/>
|
||||
<Resources/>
|
||||
<Interfaces/>
|
||||
<Others>
|
||||
<Other>doc</Other>
|
||||
<Other>.hgignore</Other>
|
||||
<Other>MANIFEST.in</Other>
|
||||
<Other>doc</Other>
|
||||
<Other>eric-revpimodio2.api</Other>
|
||||
</Others>
|
||||
<MainScript>test/test_unit.py</MainScript>
|
||||
@@ -153,9 +153,6 @@
|
||||
</value>
|
||||
</dict>
|
||||
</VcsOptions>
|
||||
<VcsOtherData>
|
||||
<dict/>
|
||||
</VcsOtherData>
|
||||
</Vcs>
|
||||
<FiletypeAssociations>
|
||||
<FiletypeAssociation pattern="*.idl" type="INTERFACES"/>
|
||||
@@ -249,14 +246,6 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>sourceExtensions</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string></string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
<string>useRecursion</string>
|
||||
</key>
|
||||
@@ -276,6 +265,41 @@
|
||||
</key>
|
||||
<value>
|
||||
<dict>
|
||||
<key>
|
||||
<string>BuiltinsChecker</string>
|
||||
</key>
|
||||
<value>
|
||||
<dict>
|
||||
<key>
|
||||
<string>chr</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string>unichr</string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
<string>str</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string>unicode</string>
|
||||
</list>
|
||||
</value>
|
||||
</dict>
|
||||
</value>
|
||||
<key>
|
||||
<string>CopyrightAuthor</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>CopyrightMinFileSize</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>0</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>DocstringType</string>
|
||||
</key>
|
||||
@@ -286,13 +310,13 @@
|
||||
<string>ExcludeFiles</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
<string>*/test/*</string>
|
||||
</value>
|
||||
<key>
|
||||
<string>ExcludeMessages</string>
|
||||
</key>
|
||||
<value>
|
||||
<string>E123,E226,E24</string>
|
||||
<string>E123,E226,E24,C101,E402,C111</string>
|
||||
</value>
|
||||
<key>
|
||||
<string>FixCodes</string>
|
||||
@@ -306,6 +330,12 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>FutureChecker</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>HangClosing</string>
|
||||
</key>
|
||||
@@ -318,6 +348,24 @@
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>LineComplexity</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>15</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>LineComplexityScore</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>10</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>MaxCodeComplexity</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>10</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>MaxLineLength</string>
|
||||
</key>
|
||||
@@ -342,6 +390,12 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>ValidEncodings</string>
|
||||
</key>
|
||||
<value>
|
||||
<string>latin-1, utf-8</string>
|
||||
</value>
|
||||
</dict>
|
||||
</value>
|
||||
</dict>
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
|
||||
Webpage: https://revpimodio.org/
|
||||
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
@@ -23,8 +19,9 @@ __all__ = [
|
||||
"RevPiNetIO", "RevPiNetIOSelected", "RevPiNetIODriver"
|
||||
]
|
||||
__author__ = "Sven Sager <akira@revpimodio.org>"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
__name__ = "revpimodio2"
|
||||
__package__ = "revpimodio2"
|
||||
__version__ = "2.2.2"
|
||||
|
||||
# Global package values
|
||||
@@ -71,6 +68,7 @@ def consttostr(value):
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
# Benötigte Klassen importieren
|
||||
from .modio import RevPiModIO, RevPiModIOSelected, RevPiModIODriver
|
||||
from .netio import RevPiNetIO, RevPiNetIOSelected, RevPiNetIODriver
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Bildet die App Sektion von piCtory ab."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
|
||||
class App(object):
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Modul fuer die Verwaltung der Devices."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
from threading import Thread, Event, Lock
|
||||
from .helper import ProcimgWriter
|
||||
|
||||
@@ -65,7 +63,7 @@ class DeviceList(object):
|
||||
@return Gefundenes <class 'Device'>-Objekt"""
|
||||
if type(key) == int:
|
||||
if key not in self.__dict_position:
|
||||
raise KeyError("no device on position {}".format(key))
|
||||
raise KeyError("no device on position {0}".format(key))
|
||||
return self.__dict_position[key]
|
||||
else:
|
||||
return getattr(self, key)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Helperklassen und Tools."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import queue
|
||||
import warnings
|
||||
from math import ceil
|
||||
@@ -413,12 +411,12 @@ class ProcimgWriter(Thread):
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
"reach max io error count {} on process image".format(
|
||||
"reach max io error count {0} on process image".format(
|
||||
self._maxioerrors
|
||||
)
|
||||
)
|
||||
warnings.warn(
|
||||
"count {} io errors on process image".format(self._ioerror),
|
||||
"count {0} io errors on process image".format(self._ioerror),
|
||||
RuntimeWarning
|
||||
)
|
||||
|
||||
@@ -443,7 +441,7 @@ class ProcimgWriter(Thread):
|
||||
# Lockobjekt holen und Fehler werfen, wenn nicht schnell genug
|
||||
if not self.lck_refresh.acquire(timeout=self._adjwait):
|
||||
warnings.warn(
|
||||
"cycle time of {} ms exceeded on lock".format(
|
||||
"cycle time of {0} ms exceeded on lock".format(
|
||||
int(self._refresh * 1000)
|
||||
),
|
||||
RuntimeWarning
|
||||
@@ -496,8 +494,8 @@ class ProcimgWriter(Thread):
|
||||
# Verzögerte Events prüfen
|
||||
if self.__eventwork:
|
||||
for tup_fire in list(self.__dict_delay.keys()):
|
||||
if tup_fire[0].overwrite \
|
||||
and getattr(self._modio.io, tup_fire[1]).value != \
|
||||
if tup_fire[0].overwrite and \
|
||||
getattr(self._modio.io, tup_fire[1]).value != \
|
||||
tup_fire[2]:
|
||||
del self.__dict_delay[tup_fire]
|
||||
else:
|
||||
@@ -518,7 +516,7 @@ class ProcimgWriter(Thread):
|
||||
self._adjwait -= 0.001
|
||||
if self._adjwait < 0:
|
||||
warnings.warn(
|
||||
"cycle time of {} ms exceeded".format(
|
||||
"cycle time of {0} ms exceeded".format(
|
||||
int(self._refresh * 1000)
|
||||
),
|
||||
RuntimeWarning
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Modul fuer die Verwaltung der IOs."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import struct
|
||||
from re import match as rematch
|
||||
from threading import Event
|
||||
@@ -69,7 +67,7 @@ class IOList(object):
|
||||
if key in self.__dict_iorefname:
|
||||
return self.__dict_iorefname[key]
|
||||
else:
|
||||
raise AttributeError("can not find io '{}'".format(key))
|
||||
raise AttributeError("can not find io '{0}'".format(key))
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""Ruft angegebenen IO ab.
|
||||
@@ -86,7 +84,7 @@ class IOList(object):
|
||||
"""
|
||||
if type(key) == int:
|
||||
if key not in self.__dict_iobyte:
|
||||
raise KeyError("byte '{}' does not exist".format(key))
|
||||
raise KeyError("byte '{0}' does not exist".format(key))
|
||||
return self.__dict_iobyte[key]
|
||||
elif type(key) == slice:
|
||||
return [
|
||||
@@ -151,14 +149,14 @@ class IOList(object):
|
||||
if oldio._bitaddress >= 0:
|
||||
if io._bitaddress == oldio._bitaddress:
|
||||
raise MemoryError(
|
||||
"bit {} already assigned to '{}'".format(
|
||||
"bit {0} already assigned to '{1}'".format(
|
||||
io._bitaddress, oldio._name
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Bereits überschriebene bytes sind ungültig
|
||||
raise MemoryError(
|
||||
"new io '{}' overlaps memory of '{}'".format(
|
||||
"new io '{0}' overlaps memory of '{1}'".format(
|
||||
io._name, oldio._name
|
||||
)
|
||||
)
|
||||
@@ -194,7 +192,7 @@ class IOList(object):
|
||||
if isinstance(new_io, IOBase):
|
||||
if hasattr(self, new_io._name):
|
||||
raise AttributeError(
|
||||
"attribute {} already exists - can not set io".format(
|
||||
"attribute {0} already exists - can not set io".format(
|
||||
new_io._name
|
||||
)
|
||||
)
|
||||
@@ -298,7 +296,7 @@ class IOBase(object):
|
||||
else:
|
||||
raise ValueError(
|
||||
"given bytes for default value must have a length "
|
||||
"of {} but {} was given"
|
||||
"of {0} but {1} was given"
|
||||
"".format(self._length, len(valuelist[1]))
|
||||
)
|
||||
else:
|
||||
@@ -312,7 +310,7 @@ class IOBase(object):
|
||||
if len(buff) <= self._length:
|
||||
self._defaultvalue = \
|
||||
buff + bytes(self._length - len(buff))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
else:
|
||||
@@ -328,7 +326,7 @@ class IOBase(object):
|
||||
else:
|
||||
try:
|
||||
self._defaultvalue = bool(int(valuelist[1]))
|
||||
except:
|
||||
except Exception:
|
||||
self._defaultvalue = False
|
||||
|
||||
def __bool__(self):
|
||||
@@ -367,7 +365,7 @@ class IOBase(object):
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not callable(func):
|
||||
raise AttributeError(
|
||||
"registered function '{}' is not callable".format(func)
|
||||
"registered function '{0}' is not callable".format(func)
|
||||
)
|
||||
if type(delay) != int or delay < 0:
|
||||
raise AttributeError(
|
||||
@@ -391,20 +389,21 @@ class IOBase(object):
|
||||
if edge == BOTH or regfunc.edge == BOTH:
|
||||
if self._bitaddress < 0:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' already in list."
|
||||
"io '{0}' with function '{1}' already in list."
|
||||
"".format(self._name, func)
|
||||
)
|
||||
else:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' already in list with "
|
||||
"edge '{}' - edge '{}' not allowed anymore".format(
|
||||
"io '{0}' with function '{1}' already in list "
|
||||
"with edge '{2}' - edge '{3}' not allowed anymore"
|
||||
"".format(
|
||||
self._name, func,
|
||||
consttostr(regfunc.edge), consttostr(edge)
|
||||
)
|
||||
)
|
||||
elif regfunc.edge == edge:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' for given edge '{}' "
|
||||
"io '{0}' with function '{1}' for given edge '{2}' "
|
||||
"already in list".format(
|
||||
self._name, func, consttostr(edge)
|
||||
)
|
||||
@@ -584,31 +583,31 @@ class IOBase(object):
|
||||
value
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' requires a <class 'bytes'> object of length "
|
||||
"{}, but {} was given".format(
|
||||
"'{0}' requires a <class 'bytes'> object of "
|
||||
"length {1}, but {2} was given".format(
|
||||
self._name, self._length, len(value)
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' requires a <class 'bytes'> object, not {}"
|
||||
"'{0}' requires a <class 'bytes'> object, not {1}"
|
||||
"".format(self._name, type(value))
|
||||
)
|
||||
|
||||
elif self._iotype == INP:
|
||||
if self._parentdevice._modio._simulator:
|
||||
raise AttributeError(
|
||||
"can not write to output '{}' in simulator mode"
|
||||
"can not write to output '{0}' in simulator mode"
|
||||
"".format(self._name)
|
||||
)
|
||||
else:
|
||||
raise AttributeError(
|
||||
"can not write to input '{}'".format(self._name)
|
||||
"can not write to input '{0}'".format(self._name)
|
||||
)
|
||||
|
||||
elif self._iotype == MEM:
|
||||
raise AttributeError(
|
||||
"can not write to memory '{}'".format(self._name)
|
||||
"can not write to memory '{0}'".format(self._name)
|
||||
)
|
||||
|
||||
def unreg_event(self, func=None, edge=None):
|
||||
@@ -679,7 +678,7 @@ class IOBase(object):
|
||||
# Prüfen ob Device in autorefresh ist
|
||||
if not self._parentdevice._selfupdate:
|
||||
raise RuntimeError(
|
||||
"autorefresh is not activated for device '{}|{}' - there "
|
||||
"autorefresh is not activated for device '{0}|{1}' - there "
|
||||
"will never be new data".format(
|
||||
self._parentdevice._position, self._parentdevice._name
|
||||
)
|
||||
@@ -825,7 +824,7 @@ class IntIO(IOBase):
|
||||
))
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' need a <class 'int'> value, but {} was given"
|
||||
"'{0}' need a <class 'int'> value, but {1} was given"
|
||||
"".format(self._name, type(value))
|
||||
)
|
||||
|
||||
@@ -873,7 +872,7 @@ class StructIO(IOBase):
|
||||
max_bits = parentio._length * 8
|
||||
if not (0 <= bitaddress < max_bits):
|
||||
raise AttributeError(
|
||||
"bitaddress must be a value between 0 and {}"
|
||||
"bitaddress must be a value between 0 and {0}"
|
||||
"".format(max_bits - 1)
|
||||
)
|
||||
bitlength = 1
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Hauptklasse fuer piControl0 Zugriff."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import warnings
|
||||
from json import load as jload
|
||||
from os import access, F_OK, R_OK
|
||||
@@ -187,7 +185,7 @@ class RevPiModIO(object):
|
||||
else:
|
||||
# Device-Type nicht gefunden
|
||||
warnings.warn(
|
||||
"device type '{}' unknown".format(device["type"]),
|
||||
"device type '{0}' unknown".format(device["type"]),
|
||||
Warning
|
||||
)
|
||||
dev_new = None
|
||||
@@ -298,12 +296,12 @@ class RevPiModIO(object):
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
"reach max io error count {} on process image".format(
|
||||
"reach max io error count {0} on process image".format(
|
||||
self._maxioerrors
|
||||
)
|
||||
)
|
||||
warnings.warn(
|
||||
"got io error during {} and count {} errors now".format(
|
||||
"got io error during {0} and count {1} errors now".format(
|
||||
action, self._ioerror
|
||||
),
|
||||
RuntimeWarning
|
||||
@@ -385,7 +383,7 @@ class RevPiModIO(object):
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not callable(func):
|
||||
raise RuntimeError(
|
||||
"registered function '{}' ist not callable".format(func)
|
||||
"registered function '{0}' ist not callable".format(func)
|
||||
)
|
||||
|
||||
# Zykluszeit übernehmen
|
||||
@@ -478,7 +476,7 @@ class RevPiModIO(object):
|
||||
if self._configrsc is not None:
|
||||
if not access(self._configrsc, F_OK | R_OK):
|
||||
raise RuntimeError(
|
||||
"can not access pictory configuration at {}".format(
|
||||
"can not access pictory configuration at {0}".format(
|
||||
self._configrsc))
|
||||
else:
|
||||
# piCtory Konfiguration an bekannten Stellen prüfen
|
||||
@@ -489,7 +487,7 @@ class RevPiModIO(object):
|
||||
break
|
||||
if self._configrsc is None:
|
||||
raise RuntimeError(
|
||||
"can not access known pictory configurations at {} - "
|
||||
"can not access known pictory configurations at {0} - "
|
||||
"use 'configrsc' parameter so specify location"
|
||||
"".format(", ".join(lst_rsc))
|
||||
)
|
||||
@@ -497,7 +495,7 @@ class RevPiModIO(object):
|
||||
with open(self._configrsc, "r") as fhconfigrsc:
|
||||
try:
|
||||
jdata = jload(fhconfigrsc)
|
||||
except:
|
||||
except Exception:
|
||||
raise RuntimeError(
|
||||
"can not read piCtory configuration - check your hardware "
|
||||
"configuration http://revpi_ip/"
|
||||
@@ -529,7 +527,8 @@ class RevPiModIO(object):
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not (cleanupfunc is None or callable(cleanupfunc)):
|
||||
raise RuntimeError(
|
||||
"registered function '{}' ist not callable".format(cleanupfunc)
|
||||
"registered function '{0}' ist not callable"
|
||||
"".format(cleanupfunc)
|
||||
)
|
||||
self.__cleanupfunc = cleanupfunc
|
||||
signal(SIGINT, self.__evt_exit)
|
||||
@@ -628,7 +627,7 @@ class RevPiModIO(object):
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not read process image, while device '{}|{}'"
|
||||
"can not read process image, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
@@ -703,7 +702,7 @@ class RevPiModIO(object):
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not sync outputs, while device '{}|{}'"
|
||||
"can not sync outputs, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
@@ -746,7 +745,7 @@ class RevPiModIO(object):
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not write process image, while device '{}|{}'"
|
||||
"can not write process image, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Hauptklasse fuer Netzwerkzugriff."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import socket
|
||||
import warnings
|
||||
from json import loads as jloads
|
||||
@@ -79,7 +77,7 @@ class NetFH(Thread):
|
||||
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
so.connect(self._address)
|
||||
except:
|
||||
except Exception:
|
||||
so.close()
|
||||
else:
|
||||
# Alten Socket trennen
|
||||
@@ -141,7 +139,7 @@ class NetFH(Thread):
|
||||
self._slavesock.send(_sysexit)
|
||||
else:
|
||||
self._slavesock.shutdown(socket.SHUT_RDWR)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._slavesock.close()
|
||||
|
||||
@@ -178,7 +176,7 @@ class NetFH(Thread):
|
||||
def get_name(self):
|
||||
"""Verbindugnsnamen zurueckgeben.
|
||||
@return <class 'str'> IP:PORT"""
|
||||
return "{}:{}".format(*self._address)
|
||||
return "{0}:{1}".format(*self._address)
|
||||
|
||||
def get_timeout(self):
|
||||
"""Gibt aktuellen Timeout zurueck.
|
||||
@@ -423,7 +421,7 @@ class RevPiNetIO(_RevPiModIO):
|
||||
autorefresh,
|
||||
monitoring,
|
||||
syncoutputs,
|
||||
"{}:{}".format(*self._address),
|
||||
"{0}:{1}".format(*self._address),
|
||||
None,
|
||||
simulator
|
||||
)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Bildet die Summary-Sektion von piCtory ab."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
|
||||
class Summary(object):
|
||||
|
||||
7
setup.py
7
setup.py
@@ -1,9 +1,10 @@
|
||||
#! /usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Setupscript fuer python3-revpimodio."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
|
||||
Reference in New Issue
Block a user