mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 23:23:52 +01:00
FileHandler sauber schließen
Procimg und pictory Konfiguraiton über Parameter übergebbar für Simulationen
This commit is contained in:
@@ -48,6 +48,14 @@ def configure():
|
|||||||
"-f", "--logfile", dest="logfile",
|
"-f", "--logfile", dest="logfile",
|
||||||
help="Save log entries to this file"
|
help="Save log entries to this file"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--procimg", dest="procimg",
|
||||||
|
help="Path to process image"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--pictory", dest="configrsc",
|
||||||
|
help="piCtory file to use"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v", "--verbose", action="count", dest="verbose",
|
"-v", "--verbose", action="count", dest="verbose",
|
||||||
help="Switch on verbose logging"
|
help="Switch on verbose logging"
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ class RevPiPlc(Thread):
|
|||||||
def _zeroprocimg(self):
|
def _zeroprocimg(self):
|
||||||
"""Setzt Prozessabbild auf NULL."""
|
"""Setzt Prozessabbild auf NULL."""
|
||||||
if os.path.exists("/dev/piControl0"):
|
if os.path.exists("/dev/piControl0"):
|
||||||
f = open("/dev/piControl0", "w+b", 0)
|
with open("/dev/piControl0", "w+b", 0) as f:
|
||||||
f.write(bytes(4096))
|
f.write(bytes(4096))
|
||||||
|
|
||||||
def newlogfile(self):
|
def newlogfile(self):
|
||||||
"""Konfiguriert die FileHandler auf neue Logdatei."""
|
"""Konfiguriert die FileHandler auf neue Logdatei."""
|
||||||
@@ -449,6 +449,7 @@ class RevPiPyLoad():
|
|||||||
|
|
||||||
# piCtory Konfiguration an bekannten Stellen prüfen
|
# piCtory Konfiguration an bekannten Stellen prüfen
|
||||||
global configrsc
|
global configrsc
|
||||||
|
configrsc = proginit.pargs.configrsc
|
||||||
lst_rsc = ["/etc/revpi/config.rsc", "/opt/KUNBUS/config.rsc"]
|
lst_rsc = ["/etc/revpi/config.rsc", "/opt/KUNBUS/config.rsc"]
|
||||||
for rscfile in lst_rsc:
|
for rscfile in lst_rsc:
|
||||||
if os.access(rscfile, os.F_OK | os.R_OK):
|
if os.access(rscfile, os.F_OK | os.R_OK):
|
||||||
@@ -460,6 +461,11 @@ class RevPiPyLoad():
|
|||||||
"".format(", ".join(lst_rsc))
|
"".format(", ".join(lst_rsc))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Alternatives Processabbild verwenden
|
||||||
|
if proginit.pargs.procimg is not None:
|
||||||
|
global procimg
|
||||||
|
procimg = proginit.pargs.procimg
|
||||||
|
|
||||||
# rap Katalog an bekannten Stellen prüfen und laden
|
# rap Katalog an bekannten Stellen prüfen und laden
|
||||||
global rapcatalog
|
global rapcatalog
|
||||||
lst_rap = [
|
lst_rap = [
|
||||||
@@ -851,9 +857,8 @@ class RevPiPyLoad():
|
|||||||
|
|
||||||
file = self.packapp(mode, pictory)
|
file = self.packapp(mode, pictory)
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
fh = open(file, "rb")
|
with open(file, "rb") as fh:
|
||||||
xmldata = Binary(fh.read())
|
xmldata = Binary(fh.read())
|
||||||
fh.close()
|
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
return xmldata
|
return xmldata
|
||||||
return Binary()
|
return Binary()
|
||||||
@@ -996,8 +1001,8 @@ class RevPiPyLoad():
|
|||||||
self.globalconfig.set("DEFAULT", key, str(dc[key]))
|
self.globalconfig.set("DEFAULT", key, str(dc[key]))
|
||||||
|
|
||||||
# conf-Datei schreiben
|
# conf-Datei schreiben
|
||||||
fh = open(proginit.globalconffile, "w")
|
with open(proginit.globalconffile, "w") as fh:
|
||||||
self.globalconfig.write(fh)
|
self.globalconfig.write(fh)
|
||||||
proginit.logger.info(
|
proginit.logger.info(
|
||||||
"got new config and wrote it to {}".format(proginit.globalconffile)
|
"got new config and wrote it to {}".format(proginit.globalconffile)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user