Code style

This commit is contained in:
2018-08-12 18:14:22 +02:00
parent 135076c953
commit c2f26bcc98
19 changed files with 177 additions and 134 deletions

View File

@@ -9,6 +9,8 @@ revpimodio2</h1>
<p> <p>
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung. Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
</p><p> </p><p>
Webpage: https://revpimodio.org/
</p><p>
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar

View File

@@ -9,6 +9,8 @@ revpimodio2.__init__</h1>
<p> <p>
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung. Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
</p><p> </p><p>
Webpage: https://revpimodio.org/
</p><p>
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar 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"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <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> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ Bildet die App Sektion von piCtory ab.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ Modul fuer die Verwaltung der Devices.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ RevPiModIO Helperklassen und Tools.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ RevPiModIO Modul fuer die Verwaltung der IOs.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer piControl0 Zugriff.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer Netzwerkzugriff.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <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> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -12,7 +12,7 @@ Bildet die Summary-Sektion von piCtory ab.
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Global Attributes</h3> Global Attributes</h3>
<table> <table>
<tr><td>None</td></tr> <tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Classes</h3> Classes</h3>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-5.1.dtd"> <!DOCTYPE Project SYSTEM "Project-5.1.dtd">
<!-- eric project file for project revpimodio2 --> <!-- 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 --> <!-- Copyright (C) 2018 Sven Sager, akira@narux.de -->
<Project version="5.1"> <Project version="5.1">
<Language>en_US</Language> <Language>en_US</Language>
@@ -14,40 +14,40 @@
<Email>akira@narux.de</Email> <Email>akira@narux.de</Email>
<Eol index="1"/> <Eol index="1"/>
<Sources> <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/__init__.py</Source>
<Source>revpimodio2/app.py</Source>
<Source>revpimodio2/device.py</Source> <Source>revpimodio2/device.py</Source>
<Source>revpimodio2/helper.py</Source> <Source>revpimodio2/helper.py</Source>
<Source>revpimodio2/io.py</Source>
<Source>revpimodio2/modio.py</Source>
<Source>revpimodio2/netio.py</Source> <Source>revpimodio2/netio.py</Source>
<Source>test/test_dio_while2.py</Source> <Source>revpimodio2/summary.py</Source>
<Source>test/test_dio_mainloop.py</Source> <Source>setup.py</Source>
<Source>test/test_dio_cycleloop.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/test_net_leistung.py</Source>
<Source>test/web_cycleloop.py</Source> <Source>test/test_netio_brett.py</Source>
<Source>test/web_mainloop.py</Source> <Source>test/test_unit.py</Source>
<Source>test/web_virtdevdriver.py</Source> <Source>test/test_unit_fh.py</Source>
<Source>test/test_unitnet.py</Source>
<Source>test/web_benniesrun.py</Source> <Source>test/web_benniesrun.py</Source>
<Source>test/web_benniesrunxxl.py</Source> <Source>test/web_benniesrunxxl.py</Source>
<Source>test/test_unit.py</Source> <Source>test/web_cycleloop.py</Source>
<Source>test/test_unitnet.py</Source> <Source>test/web_mainloop.py</Source>
<Source>test/test_netio_brett.py</Source>
<Source>test/web_startseite.py</Source>
<Source>test/web_rpidaten.py</Source> <Source>test/web_rpidaten.py</Source>
<Source>test/web_rpii2c.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> </Sources>
<Forms/> <Forms/>
<Translations/> <Translations/>
<Resources/> <Resources/>
<Interfaces/> <Interfaces/>
<Others> <Others>
<Other>doc</Other>
<Other>.hgignore</Other> <Other>.hgignore</Other>
<Other>MANIFEST.in</Other> <Other>MANIFEST.in</Other>
<Other>doc</Other>
<Other>eric-revpimodio2.api</Other> <Other>eric-revpimodio2.api</Other>
</Others> </Others>
<MainScript>test/test_unit.py</MainScript> <MainScript>test/test_unit.py</MainScript>
@@ -153,9 +153,6 @@
</value> </value>
</dict> </dict>
</VcsOptions> </VcsOptions>
<VcsOtherData>
<dict/>
</VcsOtherData>
</Vcs> </Vcs>
<FiletypeAssociations> <FiletypeAssociations>
<FiletypeAssociation pattern="*.idl" type="INTERFACES"/> <FiletypeAssociation pattern="*.idl" type="INTERFACES"/>
@@ -249,14 +246,6 @@
<value> <value>
<bool>False</bool> <bool>False</bool>
</value> </value>
<key>
<string>sourceExtensions</string>
</key>
<value>
<list>
<string></string>
</list>
</value>
<key> <key>
<string>useRecursion</string> <string>useRecursion</string>
</key> </key>
@@ -276,6 +265,41 @@
</key> </key>
<value> <value>
<dict> <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> <key>
<string>DocstringType</string> <string>DocstringType</string>
</key> </key>
@@ -286,13 +310,13 @@
<string>ExcludeFiles</string> <string>ExcludeFiles</string>
</key> </key>
<value> <value>
<string></string> <string>*/test/*</string>
</value> </value>
<key> <key>
<string>ExcludeMessages</string> <string>ExcludeMessages</string>
</key> </key>
<value> <value>
<string>E123,E226,E24</string> <string>E123,E226,E24,C101,E402,C111</string>
</value> </value>
<key> <key>
<string>FixCodes</string> <string>FixCodes</string>
@@ -306,6 +330,12 @@
<value> <value>
<bool>False</bool> <bool>False</bool>
</value> </value>
<key>
<string>FutureChecker</string>
</key>
<value>
<string></string>
</value>
<key> <key>
<string>HangClosing</string> <string>HangClosing</string>
</key> </key>
@@ -318,6 +348,24 @@
<value> <value>
<string></string> <string></string>
</value> </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> <key>
<string>MaxLineLength</string> <string>MaxLineLength</string>
</key> </key>
@@ -342,6 +390,12 @@
<value> <value>
<bool>False</bool> <bool>False</bool>
</value> </value>
<key>
<string>ValidEncodings</string>
</key>
<value>
<string>latin-1, utf-8</string>
</value>
</dict> </dict>
</value> </value>
</dict> </dict>

View File

@@ -1,12 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""Stellt alle Klassen fuer den RevolutionPi zur Verfuegung. """Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
Webpage: https://revpimodio.org/
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
@@ -23,8 +19,9 @@ __all__ = [
"RevPiNetIO", "RevPiNetIOSelected", "RevPiNetIODriver" "RevPiNetIO", "RevPiNetIOSelected", "RevPiNetIODriver"
] ]
__author__ = "Sven Sager <akira@revpimodio.org>" __author__ = "Sven Sager <akira@revpimodio.org>"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
__name__ = "revpimodio2" __name__ = "revpimodio2"
__package__ = "revpimodio2"
__version__ = "2.2.2" __version__ = "2.2.2"
# Global package values # Global package values
@@ -71,6 +68,7 @@ def consttostr(value):
else: else:
return "" return ""
# Benötigte Klassen importieren # Benötigte Klassen importieren
from .modio import RevPiModIO, RevPiModIOSelected, RevPiModIODriver from .modio import RevPiModIO, RevPiModIOSelected, RevPiModIODriver
from .netio import RevPiNetIO, RevPiNetIOSelected, RevPiNetIODriver from .netio import RevPiNetIO, RevPiNetIOSelected, RevPiNetIODriver

View File

@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""Bildet die App Sektion von piCtory ab.""" """Bildet die App Sektion von piCtory ab."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
class App(object): class App(object):

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""Modul fuer die Verwaltung der Devices.""" """Modul fuer die Verwaltung der Devices."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
from threading import Thread, Event, Lock from threading import Thread, Event, Lock
from .helper import ProcimgWriter from .helper import ProcimgWriter
@@ -65,7 +63,7 @@ class DeviceList(object):
@return Gefundenes <class 'Device'>-Objekt""" @return Gefundenes <class 'Device'>-Objekt"""
if type(key) == int: if type(key) == int:
if key not in self.__dict_position: 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] return self.__dict_position[key]
else: else:
return getattr(self, key) return getattr(self, key)

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""RevPiModIO Helperklassen und Tools.""" """RevPiModIO Helperklassen und Tools."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
import queue import queue
import warnings import warnings
from math import ceil from math import ceil
@@ -413,12 +411,12 @@ class ProcimgWriter(Thread):
self._ioerror += 1 self._ioerror += 1
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors: if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
raise RuntimeError( raise RuntimeError(
"reach max io error count {} on process image".format( "reach max io error count {0} on process image".format(
self._maxioerrors self._maxioerrors
) )
) )
warnings.warn( warnings.warn(
"count {} io errors on process image".format(self._ioerror), "count {0} io errors on process image".format(self._ioerror),
RuntimeWarning RuntimeWarning
) )
@@ -443,7 +441,7 @@ class ProcimgWriter(Thread):
# Lockobjekt holen und Fehler werfen, wenn nicht schnell genug # Lockobjekt holen und Fehler werfen, wenn nicht schnell genug
if not self.lck_refresh.acquire(timeout=self._adjwait): if not self.lck_refresh.acquire(timeout=self._adjwait):
warnings.warn( warnings.warn(
"cycle time of {} ms exceeded on lock".format( "cycle time of {0} ms exceeded on lock".format(
int(self._refresh * 1000) int(self._refresh * 1000)
), ),
RuntimeWarning RuntimeWarning
@@ -496,8 +494,8 @@ class ProcimgWriter(Thread):
# Verzögerte Events prüfen # Verzögerte Events prüfen
if self.__eventwork: if self.__eventwork:
for tup_fire in list(self.__dict_delay.keys()): for tup_fire in list(self.__dict_delay.keys()):
if tup_fire[0].overwrite \ if tup_fire[0].overwrite and \
and getattr(self._modio.io, tup_fire[1]).value != \ getattr(self._modio.io, tup_fire[1]).value != \
tup_fire[2]: tup_fire[2]:
del self.__dict_delay[tup_fire] del self.__dict_delay[tup_fire]
else: else:
@@ -518,7 +516,7 @@ class ProcimgWriter(Thread):
self._adjwait -= 0.001 self._adjwait -= 0.001
if self._adjwait < 0: if self._adjwait < 0:
warnings.warn( warnings.warn(
"cycle time of {} ms exceeded".format( "cycle time of {0} ms exceeded".format(
int(self._refresh * 1000) int(self._refresh * 1000)
), ),
RuntimeWarning RuntimeWarning

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""RevPiModIO Modul fuer die Verwaltung der IOs.""" """RevPiModIO Modul fuer die Verwaltung der IOs."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
import struct import struct
from re import match as rematch from re import match as rematch
from threading import Event from threading import Event
@@ -69,7 +67,7 @@ class IOList(object):
if key in self.__dict_iorefname: if key in self.__dict_iorefname:
return self.__dict_iorefname[key] return self.__dict_iorefname[key]
else: else:
raise AttributeError("can not find io '{}'".format(key)) raise AttributeError("can not find io '{0}'".format(key))
def __getitem__(self, key): def __getitem__(self, key):
"""Ruft angegebenen IO ab. """Ruft angegebenen IO ab.
@@ -86,7 +84,7 @@ class IOList(object):
""" """
if type(key) == int: if type(key) == int:
if key not in self.__dict_iobyte: 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] return self.__dict_iobyte[key]
elif type(key) == slice: elif type(key) == slice:
return [ return [
@@ -151,14 +149,14 @@ class IOList(object):
if oldio._bitaddress >= 0: if oldio._bitaddress >= 0:
if io._bitaddress == oldio._bitaddress: if io._bitaddress == oldio._bitaddress:
raise MemoryError( raise MemoryError(
"bit {} already assigned to '{}'".format( "bit {0} already assigned to '{1}'".format(
io._bitaddress, oldio._name io._bitaddress, oldio._name
) )
) )
else: else:
# Bereits überschriebene bytes sind ungültig # Bereits überschriebene bytes sind ungültig
raise MemoryError( raise MemoryError(
"new io '{}' overlaps memory of '{}'".format( "new io '{0}' overlaps memory of '{1}'".format(
io._name, oldio._name io._name, oldio._name
) )
) )
@@ -194,7 +192,7 @@ class IOList(object):
if isinstance(new_io, IOBase): if isinstance(new_io, IOBase):
if hasattr(self, new_io._name): if hasattr(self, new_io._name):
raise AttributeError( raise AttributeError(
"attribute {} already exists - can not set io".format( "attribute {0} already exists - can not set io".format(
new_io._name new_io._name
) )
) )
@@ -298,7 +296,7 @@ class IOBase(object):
else: else:
raise ValueError( raise ValueError(
"given bytes for default value must have a length " "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])) "".format(self._length, len(valuelist[1]))
) )
else: else:
@@ -312,7 +310,7 @@ class IOBase(object):
if len(buff) <= self._length: if len(buff) <= self._length:
self._defaultvalue = \ self._defaultvalue = \
buff + bytes(self._length - len(buff)) buff + bytes(self._length - len(buff))
except: except Exception:
pass pass
else: else:
@@ -328,7 +326,7 @@ class IOBase(object):
else: else:
try: try:
self._defaultvalue = bool(int(valuelist[1])) self._defaultvalue = bool(int(valuelist[1]))
except: except Exception:
self._defaultvalue = False self._defaultvalue = False
def __bool__(self): def __bool__(self):
@@ -367,7 +365,7 @@ class IOBase(object):
# Prüfen ob Funktion callable ist # Prüfen ob Funktion callable ist
if not callable(func): if not callable(func):
raise AttributeError( raise AttributeError(
"registered function '{}' is not callable".format(func) "registered function '{0}' is not callable".format(func)
) )
if type(delay) != int or delay < 0: if type(delay) != int or delay < 0:
raise AttributeError( raise AttributeError(
@@ -391,20 +389,21 @@ class IOBase(object):
if edge == BOTH or regfunc.edge == BOTH: if edge == BOTH or regfunc.edge == BOTH:
if self._bitaddress < 0: if self._bitaddress < 0:
raise AttributeError( raise AttributeError(
"io '{}' with function '{}' already in list." "io '{0}' with function '{1}' already in list."
"".format(self._name, func) "".format(self._name, func)
) )
else: else:
raise AttributeError( raise AttributeError(
"io '{}' with function '{}' already in list with " "io '{0}' with function '{1}' already in list "
"edge '{}' - edge '{}' not allowed anymore".format( "with edge '{2}' - edge '{3}' not allowed anymore"
"".format(
self._name, func, self._name, func,
consttostr(regfunc.edge), consttostr(edge) consttostr(regfunc.edge), consttostr(edge)
) )
) )
elif regfunc.edge == edge: elif regfunc.edge == edge:
raise AttributeError( raise AttributeError(
"io '{}' with function '{}' for given edge '{}' " "io '{0}' with function '{1}' for given edge '{2}' "
"already in list".format( "already in list".format(
self._name, func, consttostr(edge) self._name, func, consttostr(edge)
) )
@@ -584,31 +583,31 @@ class IOBase(object):
value value
else: else:
raise ValueError( raise ValueError(
"'{}' requires a <class 'bytes'> object of length " "'{0}' requires a <class 'bytes'> object of "
"{}, but {} was given".format( "length {1}, but {2} was given".format(
self._name, self._length, len(value) self._name, self._length, len(value)
) )
) )
else: else:
raise ValueError( raise ValueError(
"'{}' requires a <class 'bytes'> object, not {}" "'{0}' requires a <class 'bytes'> object, not {1}"
"".format(self._name, type(value)) "".format(self._name, type(value))
) )
elif self._iotype == INP: elif self._iotype == INP:
if self._parentdevice._modio._simulator: if self._parentdevice._modio._simulator:
raise AttributeError( raise AttributeError(
"can not write to output '{}' in simulator mode" "can not write to output '{0}' in simulator mode"
"".format(self._name) "".format(self._name)
) )
else: else:
raise AttributeError( raise AttributeError(
"can not write to input '{}'".format(self._name) "can not write to input '{0}'".format(self._name)
) )
elif self._iotype == MEM: elif self._iotype == MEM:
raise AttributeError( 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): def unreg_event(self, func=None, edge=None):
@@ -679,7 +678,7 @@ class IOBase(object):
# Prüfen ob Device in autorefresh ist # Prüfen ob Device in autorefresh ist
if not self._parentdevice._selfupdate: if not self._parentdevice._selfupdate:
raise RuntimeError( raise RuntimeError(
"autorefresh is not activated for device '{}|{}' - there " "autorefresh is not activated for device '{0}|{1}' - there "
"will never be new data".format( "will never be new data".format(
self._parentdevice._position, self._parentdevice._name self._parentdevice._position, self._parentdevice._name
) )
@@ -825,7 +824,7 @@ class IntIO(IOBase):
)) ))
else: else:
raise ValueError( 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)) "".format(self._name, type(value))
) )
@@ -873,7 +872,7 @@ class StructIO(IOBase):
max_bits = parentio._length * 8 max_bits = parentio._length * 8
if not (0 <= bitaddress < max_bits): if not (0 <= bitaddress < max_bits):
raise AttributeError( raise AttributeError(
"bitaddress must be a value between 0 and {}" "bitaddress must be a value between 0 and {0}"
"".format(max_bits - 1) "".format(max_bits - 1)
) )
bitlength = 1 bitlength = 1

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""RevPiModIO Hauptklasse fuer piControl0 Zugriff.""" """RevPiModIO Hauptklasse fuer piControl0 Zugriff."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
import warnings import warnings
from json import load as jload from json import load as jload
from os import access, F_OK, R_OK from os import access, F_OK, R_OK
@@ -187,7 +185,7 @@ class RevPiModIO(object):
else: else:
# Device-Type nicht gefunden # Device-Type nicht gefunden
warnings.warn( warnings.warn(
"device type '{}' unknown".format(device["type"]), "device type '{0}' unknown".format(device["type"]),
Warning Warning
) )
dev_new = None dev_new = None
@@ -298,12 +296,12 @@ class RevPiModIO(object):
self._ioerror += 1 self._ioerror += 1
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors: if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
raise RuntimeError( raise RuntimeError(
"reach max io error count {} on process image".format( "reach max io error count {0} on process image".format(
self._maxioerrors self._maxioerrors
) )
) )
warnings.warn( 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 action, self._ioerror
), ),
RuntimeWarning RuntimeWarning
@@ -385,7 +383,7 @@ class RevPiModIO(object):
# Prüfen ob Funktion callable ist # Prüfen ob Funktion callable ist
if not callable(func): if not callable(func):
raise RuntimeError( raise RuntimeError(
"registered function '{}' ist not callable".format(func) "registered function '{0}' ist not callable".format(func)
) )
# Zykluszeit übernehmen # Zykluszeit übernehmen
@@ -478,7 +476,7 @@ class RevPiModIO(object):
if self._configrsc is not None: if self._configrsc is not None:
if not access(self._configrsc, F_OK | R_OK): if not access(self._configrsc, F_OK | R_OK):
raise RuntimeError( raise RuntimeError(
"can not access pictory configuration at {}".format( "can not access pictory configuration at {0}".format(
self._configrsc)) self._configrsc))
else: else:
# piCtory Konfiguration an bekannten Stellen prüfen # piCtory Konfiguration an bekannten Stellen prüfen
@@ -489,7 +487,7 @@ class RevPiModIO(object):
break break
if self._configrsc is None: if self._configrsc is None:
raise RuntimeError( raise RuntimeError(
"can not access known pictory configurations at {} - " "can not access known pictory configurations at {0} - "
"use 'configrsc' parameter so specify location" "use 'configrsc' parameter so specify location"
"".format(", ".join(lst_rsc)) "".format(", ".join(lst_rsc))
) )
@@ -497,7 +495,7 @@ class RevPiModIO(object):
with open(self._configrsc, "r") as fhconfigrsc: with open(self._configrsc, "r") as fhconfigrsc:
try: try:
jdata = jload(fhconfigrsc) jdata = jload(fhconfigrsc)
except: except Exception:
raise RuntimeError( raise RuntimeError(
"can not read piCtory configuration - check your hardware " "can not read piCtory configuration - check your hardware "
"configuration http://revpi_ip/" "configuration http://revpi_ip/"
@@ -529,7 +527,8 @@ class RevPiModIO(object):
# Prüfen ob Funktion callable ist # Prüfen ob Funktion callable ist
if not (cleanupfunc is None or callable(cleanupfunc)): if not (cleanupfunc is None or callable(cleanupfunc)):
raise RuntimeError( raise RuntimeError(
"registered function '{}' ist not callable".format(cleanupfunc) "registered function '{0}' ist not callable"
"".format(cleanupfunc)
) )
self.__cleanupfunc = cleanupfunc self.__cleanupfunc = cleanupfunc
signal(SIGINT, self.__evt_exit) signal(SIGINT, self.__evt_exit)
@@ -628,7 +627,7 @@ class RevPiModIO(object):
if dev._selfupdate: if dev._selfupdate:
raise RuntimeError( 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) "is in autorefresh mode".format(dev._position, dev._name)
) )
mylist = [dev] mylist = [dev]
@@ -703,7 +702,7 @@ class RevPiModIO(object):
if dev._selfupdate: if dev._selfupdate:
raise RuntimeError( 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) "is in autorefresh mode".format(dev._position, dev._name)
) )
mylist = [dev] mylist = [dev]
@@ -746,7 +745,7 @@ class RevPiModIO(object):
if dev._selfupdate: if dev._selfupdate:
raise RuntimeError( 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) "is in autorefresh mode".format(dev._position, dev._name)
) )
mylist = [dev] mylist = [dev]

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""RevPiModIO Hauptklasse fuer Netzwerkzugriff.""" """RevPiModIO Hauptklasse fuer Netzwerkzugriff."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
import socket import socket
import warnings import warnings
from json import loads as jloads from json import loads as jloads
@@ -79,7 +77,7 @@ class NetFH(Thread):
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM) so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try: try:
so.connect(self._address) so.connect(self._address)
except: except Exception:
so.close() so.close()
else: else:
# Alten Socket trennen # Alten Socket trennen
@@ -141,7 +139,7 @@ class NetFH(Thread):
self._slavesock.send(_sysexit) self._slavesock.send(_sysexit)
else: else:
self._slavesock.shutdown(socket.SHUT_RDWR) self._slavesock.shutdown(socket.SHUT_RDWR)
except: except Exception:
pass pass
self._slavesock.close() self._slavesock.close()
@@ -178,7 +176,7 @@ class NetFH(Thread):
def get_name(self): def get_name(self):
"""Verbindugnsnamen zurueckgeben. """Verbindugnsnamen zurueckgeben.
@return <class 'str'> IP:PORT""" @return <class 'str'> IP:PORT"""
return "{}:{}".format(*self._address) return "{0}:{1}".format(*self._address)
def get_timeout(self): def get_timeout(self):
"""Gibt aktuellen Timeout zurueck. """Gibt aktuellen Timeout zurueck.
@@ -423,7 +421,7 @@ class RevPiNetIO(_RevPiModIO):
autorefresh, autorefresh,
monitoring, monitoring,
syncoutputs, syncoutputs,
"{}:{}".format(*self._address), "{0}:{1}".format(*self._address),
None, None,
simulator simulator
) )

View File

@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# python3-RevPiModIO
#
# Webpage: https://revpimodio.org/
# (c) Sven Sager, License: LGPLv3
#
"""Bildet die Summary-Sektion von piCtory ab.""" """Bildet die Summary-Sektion von piCtory ab."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
class Summary(object): class Summary(object):

View File

@@ -1,9 +1,10 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
# (c) Sven Sager, License: LGPLv3
#
"""Setupscript fuer python3-revpimodio.""" """Setupscript fuer python3-revpimodio."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
from distutils.core import setup from distutils.core import setup
setup( setup(