1
0
mirror of https://github.com/naruxde/revpipycontrol.git synced 2025-11-09 07:58:03 +01:00

4 Commits
0.2.6 ... 0.2.8

10 changed files with 279 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
include MANIFEST.in
include stdeb.cfg
recursive-include data *
recursive-include revpipycontrol *
global-exclude *.pyc

78
revpipycontrol.api Normal file
View File

@@ -0,0 +1,78 @@
revpicheckclient.RevPiCheckClient._autorw?5()
revpicheckclient.RevPiCheckClient._createiogroup?5(device, frame, iotype)
revpicheckclient.RevPiCheckClient._createwidgets?5()
revpicheckclient.RevPiCheckClient._readvaluesdev?5(device, iotype)
revpicheckclient.RevPiCheckClient._writevaluesdev?5(device)
revpicheckclient.RevPiCheckClient.myapp?7
revpicheckclient.RevPiCheckClient.onfrmconf?4(canvas)
revpicheckclient.RevPiCheckClient.readvalues?4()
revpicheckclient.RevPiCheckClient.root?7
revpicheckclient.RevPiCheckClient.toggleauto?4()
revpicheckclient.RevPiCheckClient.writevalues?4()
revpicheckclient.RevPiCheckClient?1(master, xmlcli)
revpilogfile.RevPiLogfile._createwidgets?5()
revpilogfile.RevPiLogfile.btn_clearapp?4()
revpilogfile.RevPiLogfile.btn_clearplc?4()
revpilogfile.RevPiLogfile.get_applines?4()
revpilogfile.RevPiLogfile.get_applog?4()
revpilogfile.RevPiLogfile.get_plclines?4()
revpilogfile.RevPiLogfile.get_plclog?4()
revpilogfile.RevPiLogfile?1(master, xmlcli)
revpioption.RevPiOption._createwidgets?5()
revpioption.RevPiOption._loadappdata?5()
revpioption.RevPiOption._setappdata?5()
revpioption.RevPiOption.askxmlon?4()
revpioption.RevPiOption.xmlmods?4()
revpioption.RevPiOption?1(master, xmlcli, xmlmode)
revpiplclist.RevPiPlcList._createwidgets?5()
revpiplclist.RevPiPlcList._loadappdata?5()
revpiplclist.RevPiPlcList._saveappdata?5()
revpiplclist.RevPiPlcList.build_listconn?4()
revpiplclist.RevPiPlcList.evt_btnadd?4()
revpiplclist.RevPiPlcList.evt_btnclose?4()
revpiplclist.RevPiPlcList.evt_btnnew?4()
revpiplclist.RevPiPlcList.evt_btnremove?4()
revpiplclist.RevPiPlcList.evt_btnsave?4()
revpiplclist.RevPiPlcList.evt_keypress?4(evt=None)
revpiplclist.RevPiPlcList.evt_listconn?4(evt=None)
revpiplclist.RevPiPlcList.myapp?7
revpiplclist.RevPiPlcList.root?7
revpiplclist.RevPiPlcList?1(master)
revpiplclist.get_connections?4()
revpiplclist.savefile?7
revpiprogram.RevPiProgram._createwidgets?5()
revpiprogram.RevPiProgram._evt_optdown?5(text="")
revpiprogram.RevPiProgram._evt_optup?5(text="")
revpiprogram.RevPiProgram._loaddefault?5(full=False)
revpiprogram.RevPiProgram._savedefaults?5()
revpiprogram.RevPiProgram.check_replacedir?4(rootdir)
revpiprogram.RevPiProgram.create_filelist?4(rootdir)
revpiprogram.RevPiProgram.getpictoryrsc?4()
revpiprogram.RevPiProgram.getprocimg?4()
revpiprogram.RevPiProgram.myapp?7
revpiprogram.RevPiProgram.plcdownload?4()
revpiprogram.RevPiProgram.plcupload?4()
revpiprogram.RevPiProgram.root?7
revpiprogram.RevPiProgram.setpictoryrsc?4(filename=None)
revpiprogram.RevPiProgram?1(master, xmlcli, xmlmode, revpi)
revpiprogram.savefile?7
revpipycontrol.RevPiPyControl._btnstate?5()
revpipycontrol.RevPiPyControl._closeall?5()
revpipycontrol.RevPiPyControl._createwidgets?5()
revpipycontrol.RevPiPyControl._fillconnbar?5()
revpipycontrol.RevPiPyControl._fillmbar?5()
revpipycontrol.RevPiPyControl._opt_conn?5(text)
revpipycontrol.RevPiPyControl.myapp?7
revpipycontrol.RevPiPyControl.plclist?4()
revpipycontrol.RevPiPyControl.plclogs?4()
revpipycontrol.RevPiPyControl.plcmonitor?4()
revpipycontrol.RevPiPyControl.plcoptions?4()
revpipycontrol.RevPiPyControl.plcprogram?4()
revpipycontrol.RevPiPyControl.plcrestart?4()
revpipycontrol.RevPiPyControl.plcstart?4()
revpipycontrol.RevPiPyControl.plcstop?4()
revpipycontrol.RevPiPyControl.root?7
revpipycontrol.RevPiPyControl.servererror?4()
revpipycontrol.RevPiPyControl.tmr_plcrunning?4()
revpipycontrol.RevPiPyControl?1(master=None)
revpipycontrol.addroot?4(filename)

6
revpipycontrol.bas Normal file
View File

@@ -0,0 +1,6 @@
RevPiCheckClient tkinter.Frame
RevPiLogfile tkinter.Frame
RevPiOption tkinter.Frame
RevPiPlcList tkinter.Frame
RevPiProgram tkinter.Frame
RevPiPyControl tkinter.Frame

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
<!-- eric project file for project revpipycontrol -->
<!-- Saved: 2017-03-16, 21:00:50 -->
<!-- Saved: 2017-03-23, 10:40:08 -->
<!-- Copyright (C) 2017 Sven Sager, akira@narux.de -->
<Project version="5.1">
<Language>en_US</Language>
@@ -9,7 +9,7 @@
<ProgLanguage mixed="0">Python3</ProgLanguage>
<ProjectType>Console</ProjectType>
<Description></Description>
<Version>0.2.6</Version>
<Version>0.2.8</Version>
<Author>Sven Sager</Author>
<Email>akira@narux.de</Email>
<Eol index="-1"/>
@@ -29,6 +29,7 @@
<Others>
<Other>data</Other>
<Other>doc</Other>
<Other>revpipycontrol.api</Other>
</Others>
<MainScript>revpipycontrol/revpipycontrol.py</MainScript>
<Vcs>
@@ -148,16 +149,79 @@
<DocumentationParams>
<dict>
<key>
<string>ERIC4DOC</string>
<string>ERIC4API</string>
</key>
<value>
<dict>
<key>
<string>ignoreDirectories</string>
</key>
<value>
<list>
<string>data</string>
<string>deb</string>
<string>dist</string>
<string>doc</string>
</list>
</value>
<key>
<string>ignoreFilePatterns</string>
</key>
<value>
<list>
<string></string>
<string>setup.py</string>
</list>
</value>
<key>
<string>includePrivate</string>
</key>
<value>
<bool>True</bool>
</value>
<key>
<string>languages</string>
</key>
<value>
<list>
<string>Python3</string>
</list>
</value>
<key>
<string>outputFile</string>
</key>
<value>
<string>revpipycontrol.api</string>
</value>
<key>
<string>useRecursion</string>
</key>
<value>
<bool>True</bool>
</value>
</dict>
</value>
<key>
<string>ERIC4DOC</string>
</key>
<value>
<dict>
<key>
<string>ignoreDirectories</string>
</key>
<value>
<list>
<string>data</string>
<string>deb</string>
<string>dist</string>
<string>doc</string>
</list>
</value>
<key>
<string>ignoreFilePatterns</string>
</key>
<value>
<list>
<string>setup.py</string>
</list>
</value>
<key>

View File

@@ -76,6 +76,7 @@ class RevPiOption(tkinter.Frame):
self.var_pythonver = tkinter.IntVar(prog)
self.var_startpy = tkinter.StringVar(prog)
self.var_startargs = tkinter.StringVar(prog)
self.var_slave = tkinter.BooleanVar(prog)
self.var_pythonver.set(3)
@@ -109,6 +110,14 @@ class RevPiOption(tkinter.Frame):
opt_startpy["state"] = self.xmlstate
opt_startpy.grid(columnspan=2, **cpadwe)
lbl = tkinter.Label(prog)
lbl["text"] = "Programm Argumente"
lbl.grid(columnspan=2, **cpadw)
txt = tkinter.Entry(prog)
txt["textvariable"] = self.var_startargs
txt.grid(columnspan=2, **cpadw)
ckb_slave = tkinter.Checkbutton(prog, justify="left")
ckb_slave["state"] = self.xmlstate
ckb_slave["text"] = "RevPi als PLC-Slave verwenden"
@@ -175,20 +184,21 @@ class RevPiOption(tkinter.Frame):
def _loadappdata(self):
dc = self.xmlcli.get_config()
self.var_start.set(dc["autostart"])
self.var_reload.set(dc["autoreload"])
self.var_zexit.set(dc["zeroonexit"])
self.var_zerr.set(dc["zeroonerror"])
self.var_start.set(dc.get("autostart", "1"))
self.var_reload.set(dc.get("autoreload", "1"))
self.var_zexit.set(dc.get("zeroonexit", "0"))
self.var_zerr.set(dc.get("zeroonerror", "0"))
self.var_startpy.set(dc["plcprogram"])
self.var_pythonver.set(dc["pythonversion"])
self.var_slave.set(dc["plcslave"])
self.var_startpy.set(dc.get("plcprogram", "none.py"))
self.var_startargs.set(dc.get("plcarguments", ""))
self.var_pythonver.set(dc.get("pythonversion", "3"))
self.var_slave.set(dc.get("plcslave", "0"))
self.var_xmlon.set(dc["xmlrpc"] >= 1)
self.var_xmlmod2.set(dc["xmlrpc"] >= 2)
self.var_xmlmod3.set(dc["xmlrpc"] >= 3)
self.var_xmlon.set(dc.get("xmlrpc", 0) >= 1)
self.var_xmlmod2.set(dc.get("xmlrpc", 0) >= 2)
self.var_xmlmod3.set(dc.get("xmlrpc", 0) >= 3)
self.var_xmlport.set(dc["xmlrpcport"])
self.var_xmlport.set(dc.get("xmlrpcport", "55123"))
def _setappdata(self):
dc = {}
@@ -198,6 +208,7 @@ class RevPiOption(tkinter.Frame):
dc["zeroonerror"] = int(self.var_zerr.get())
dc["plcprogram"] = self.var_startpy.get()
dc["plcarguments"] = self.var_startargs.get()
dc["pythonversion"] = self.var_pythonver.get()
dc["plcslave"] = int(self.var_slave.get())

View File

@@ -21,6 +21,7 @@ else:
savefile = os.path.join(homedir, ".revpipyplc", "connections.dat")
# Für andere Module zum Laden der Connections
def get_connections():
if os.path.exists(savefile):
fh = open(savefile, "rb")

View File

@@ -7,16 +7,28 @@
# -*- coding: utf-8 -*-
import gzip
import os
import pickle
import tarfile
import tkinter
import tkinter.filedialog as tkfd
import tkinter.messagebox as tkmsg
import zipfile
from os import environ
from os import makedirs
from shutil import rmtree
from sys import platform
from tempfile import mktemp, mkdtemp
from xmlrpc.client import Binary
# Systemwerte
if platform == "linux":
homedir = environ["HOME"]
else:
homedir = environ["APPDATA"]
savefile = os.path.join(homedir, ".revpipyplc", "programpath.dat")
class RevPiProgram(tkinter.Frame):
def __init__(self, master, xmlcli, xmlmode, revpi):
@@ -33,6 +45,9 @@ class RevPiProgram(tkinter.Frame):
self.xmlmode = xmlmode
self.xmlstate = "normal" if xmlmode == 3 else "disabled"
# Letzte Einstellungen übernehmen
self.opt = self._loaddefault()
# Fenster bauen
self._createwidgets()
@@ -73,8 +88,10 @@ class RevPiProgram(tkinter.Frame):
self.lst_typedown = ["Dateien", "Zip Archiv", "TGZ Archiv"]
self.lst_typeup = ["Dateien", "Ordner", "Zip Archiv", "TGZ Archiv"]
self.var_typedown.set(self.lst_typedown[0])
self.var_typeup.set(self.lst_typeup[0])
self.var_picdown.set(self.opt.get("picdown", False))
self.var_picup.set(self.opt.get("picup", False))
self.var_typedown.set(self.opt.get("typedown", self.lst_typedown[0]))
self.var_typeup.set(self.opt.get("typeup", self.lst_typeup[0]))
r = 0
lbl = tkinter.Label(prog)
@@ -181,20 +198,35 @@ class RevPiProgram(tkinter.Frame):
else:
self.ckb_picup["state"] = "normal"
def _loaddefault(self):
# TODO: letzte Einstellungen laden
pass
def _loaddefault(self, full=False):
"""Uebernimmt fuer den Pi die letzen Pfade."""
if os.path.exists(savefile):
fh = open(savefile, "rb")
dict_all = pickle.load(fh)
if full:
return dict_all
else:
return dict_all.get(self.revpi, {})
return {}
def _savedefaults(self):
# TODO: Einstellungen sichern
pass
"""Schreibt fuer den Pi die letzen Pfade."""
try:
makedirs(os.path.dirname(savefile), exist_ok=True)
dict_all = self._loaddefault(full=True)
dict_all[self.revpi] = self.opt
fh = open(savefile, "wb")
pickle.dump(dict_all, fh)
self.changes = False
except:
return False
return True
def create_filelist(self, rootdir):
"""Erstellt eine Dateiliste von einem Verzeichnis.
@param rootdir: Verzeichnis fuer das eine Liste erstellt werden soll
@returns: Dateiliste"""
filelist = []
print(rootdir)
for tup_dir in os.walk(rootdir):
for fname in tup_dir[2]:
filelist.append(os.path.join(tup_dir[0], fname))
@@ -210,7 +242,6 @@ class RevPiProgram(tkinter.Frame):
"""
lst_dir = os.listdir(rootdir)
print(rootdir)
if len(lst_dir) == 1 and \
os.path.isdir(os.path.join(rootdir, lst_dir[0])):
return (os.path.join(rootdir, lst_dir[0]), None)
@@ -230,6 +261,7 @@ class RevPiProgram(tkinter.Frame):
mode="wb", parent=self.master,
confirmoverwrite=True,
title="Speichern als...",
initialdir=self.opt.get("getpictoryrsc_dir", ""),
initialfile=self.revpi + ".rsc",
filetypes=(("piCtory Config", "*.rsc"), ("All Files", "*.*"))
)
@@ -248,6 +280,9 @@ class RevPiProgram(tkinter.Frame):
message="Datei erfolgreich vom Revolution Pi geladen "
"und gespeichert.",
)
# Einstellungen speichern
self.opt["getpictoryrsc_dir"] = os.path.dirname(fh.name)
self._savedefaults()
finally:
fh.close()
@@ -256,6 +291,7 @@ class RevPiProgram(tkinter.Frame):
mode="wb", parent=self.master,
confirmoverwrite=True,
title="Speichern als...",
initialdir=self.opt.get("getprocimg_dir", ""),
initialfile=self.revpi + ".img",
filetypes=(("Imagefiles", "*.img"), ("All Files", "*.*"))
)
@@ -274,6 +310,9 @@ class RevPiProgram(tkinter.Frame):
message="Datei erfolgreich vom Revolution Pi geladen "
"und gespeichert.",
)
# Einstellungen speichern
self.opt["getprocimg_dir"] = os.path.dirname(fh.name)
self._savedefaults()
finally:
fh.close()
@@ -282,6 +321,7 @@ class RevPiProgram(tkinter.Frame):
fh = tkfd.askopenfile(
mode="rb", parent=self.master,
title="piCtory Datei öffnen...",
initialdir=self.opt.get("setpictoryrsc_dir", ""),
initialfile=self.revpi + ".rsc",
filetypes=(("piCtory Config", "*.rsc"), ("All Files", "*.*"))
)
@@ -309,6 +349,10 @@ class RevPiProgram(tkinter.Frame):
parent=self.master, title="Erfolgreich",
message="Die Übertragung der piCtory Konfiguration "
"wurde erfolgreich ausgeführt")
#Einstellungen speichern
self.opt["setpictoryrsc_dir"] = os.path.dirname(fh.name)
self._savedefaults()
elif ec < 0:
tkmsg.showerror(
parent=self.master, title="Fehler",
@@ -331,8 +375,11 @@ class RevPiProgram(tkinter.Frame):
if tdown == 0:
# Ordner
dirselect = tkfd.askdirectory(
parent=self.master, title="Verzeichnis zum Ablegen",
mustexist=False, initialdir=self.revpi)
parent=self.master,
title="Verzeichnis zum Ablegen",
mustexist=False,
initialdir=self.opt.get("plcdownload_dir", self.revpi)
)
if type(dirselect) == str and dirselect != "":
fh = open(mktemp(), "wb")
@@ -343,6 +390,7 @@ class RevPiProgram(tkinter.Frame):
mode="wb", parent=self.master,
confirmoverwrite=True,
title="Speichern als...",
initialdir=self.opt.get("plcdownload_file", ""),
initialfile=self.revpi + ".zip",
filetypes=(("Zip Archiv", "*.zip"), ("All Files", "*.*"))
)
@@ -353,6 +401,7 @@ class RevPiProgram(tkinter.Frame):
mode="wb", parent=self.master,
confirmoverwrite=True,
title="Speichern als...",
initialdir=self.opt.get("plcdownload_file", ""),
initialfile=self.revpi + ".tar.gz",
filetypes=(("Tar Archiv", "*.tar.gz"), ("All Files", "*.*"))
)
@@ -383,6 +432,11 @@ class RevPiProgram(tkinter.Frame):
fh_pack.extract(taritem, dirselect)
fh_pack.close()
self.opt["plcdownload_dir"] = dirselect
else:
self.opt["plcdownload_file"] = os.path.dirname(fh.name)
self.opt["typedown"] = self.var_typedown.get()
self.opt["picdown"] = self.var_picdown.get()
except:
raise
@@ -397,6 +451,9 @@ class RevPiProgram(tkinter.Frame):
message="Datei erfolgreich vom Revolution Pi geladen "
"und gespeichert.",
)
# Einstellungen speichern
self._savedefaults()
finally:
fh.close()
@@ -405,12 +462,15 @@ class RevPiProgram(tkinter.Frame):
dirselect = ""
dirtmp = None
filelist = []
fileselect = None
rscfile = None
if tup == 0:
# Datei
fileselect = tkfd.askopenfilenames(
parent=self.master, title="Python Programm übertragen...",
parent=self.master,
title="Python Programm übertragen...",
initialdir=self.opt.get("plcupload_dir", ""),
filetypes=(("Python", "*.py"), ("All Files", "*.*"))
)
if type(fileselect) == tuple and len(fileselect) > 0:
@@ -420,16 +480,20 @@ class RevPiProgram(tkinter.Frame):
elif tup == 1:
# Ordner
dirselect = tkfd.askdirectory(
parent=self.master, title="Verzeichnis zum Hochladen",
mustexist=True, initialdir=self.revpi)
parent=self.master,
title="Verzeichnis zum Hochladen",
mustexist=True,
initialdir=self.opt.get("plcupload_dir", self.revpi)
)
if type(dirselect) == str and dirselect != "":
filelist = self.create_filelist(dirselect)
elif tup == 2:
# Zip
fileselect = tkfd.askopenfilename(
parent=self.master, title="Zip-Archive übertragen...",
parent=self.master,
title="Zip-Archive übertragen...",
initialdir=self.opt.get("plcupload_file", ""),
initialfile=self.revpi + ".zip",
filetypes=(("Zip Archiv", "*.zip"), ("All Files", "*.*"))
)
@@ -453,7 +517,9 @@ class RevPiProgram(tkinter.Frame):
elif tup == 3:
# TarGz
fileselect = tkfd.askopenfilename(
parent=self.master, title="TarGz-Archiv übertragen...",
parent=self.master,
title="TarGz-Archiv übertragen...",
initialdir=self.opt.get("plcupload_file", ""),
initialfile=self.revpi + ".tar.gz",
filetypes=(("Tar Archiv", "*.tar.gz"), ("All Files", "*.*"))
)
@@ -531,6 +597,18 @@ class RevPiProgram(tkinter.Frame):
message="Es wurde im Archiv keine piCtory "
"Konfiguration gefunden")
# Einstellungen speichern
if tup == 0:
self.opt["plcupload_dir"] = os.path.dirname(fileselect[0])
elif tup == 1:
self.opt["plcupload_dir"] = dirselect
else:
self.opt["plcupload_file"] = os.path.dirname(fileselect)
self.opt["typeup"] = self.var_typeup.get()
self.opt["picup"] = self.var_picup.get()
self._savedefaults()
elif ec == -1:
tkmsg.showerror(
parent=self.master, title="Fehler",

View File

@@ -1,7 +1,7 @@
#!/usr/bin/python3
#
# RevPiPyControl
# Version: 0.2.6
# Version: 0.2.8
#
# Webpage: https://revpimodio.org/revpipyplc/
# (c) Sven Sager, License: LGPLv3
@@ -20,8 +20,6 @@ from os.path import dirname
from os.path import join as pathjoin
from xmlrpc.client import ServerProxy
socket.setdefaulttimeout(2)
def addroot(filename):
u"""Hängt root-dir der Anwendung vor Dateinamen.
@@ -143,6 +141,7 @@ class RevPiPyControl(tkinter.Frame):
)
def _opt_conn(self, text):
socket.setdefaulttimeout(2)
sp = ServerProxy(
"http://{}:{}".format(
self.dict_conn[text][0], int(self.dict_conn[text][1])

View File

@@ -23,7 +23,7 @@ globsetup = {
"author_email": "akira@narux.de",
"url": "https://revpimodio.org/revpipyplc/",
"license": "LGPLv3",
"version": "0.2.6",
"version": "0.2.8",
"name": "revpipycontrol",

5
stdeb.cfg Normal file
View File

@@ -0,0 +1,5 @@
[DEFAULT]
Debian-Version=1
Depends3=python3-tk
Section=universe/x11
Suite=stable