catch Tcl errors, process commands without desktop environment
This commit is contained in:
parent
0827ba2c95
commit
91e290fe45
70
setup.py
70
setup.py
|
@ -8,9 +8,6 @@ import tkinter as tk
|
||||||
# imporrt the standard to read and write config files
|
# imporrt the standard to read and write config files
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
#the main window
|
|
||||||
master=tk.Tk()
|
|
||||||
|
|
||||||
#list of required modules
|
#list of required modules
|
||||||
modules=list()
|
modules=list()
|
||||||
try:
|
try:
|
||||||
|
@ -23,26 +20,6 @@ except:
|
||||||
# except:
|
# except:
|
||||||
# modules.append("python-crontab")
|
# modules.append("python-crontab")
|
||||||
|
|
||||||
#init variables used in config file and some other places
|
|
||||||
doAutostart=tk.IntVar()
|
|
||||||
bild_dauer=tk.IntVar()
|
|
||||||
DEBUG_PREVIEW=tk.IntVar()
|
|
||||||
localPath=tk.StringVar()
|
|
||||||
remoteURL=tk.StringVar()
|
|
||||||
energyMode=tk.IntVar()
|
|
||||||
energyStart=tk.StringVar()
|
|
||||||
energyStop=tk.StringVar()
|
|
||||||
|
|
||||||
|
|
||||||
#when setup can't find the conf file, inited is set to True
|
|
||||||
inited = False
|
|
||||||
#URL for the Intro-Screens, use as default, if conf is inited
|
|
||||||
introURL="https://wolke.netzbegruenung.de/s/2TPGWN5FtWYy2d8/download"
|
|
||||||
|
|
||||||
#set "dirty" flag to False
|
|
||||||
#any change should set it to True, so we can ask on quit to save data
|
|
||||||
isDirty=False
|
|
||||||
|
|
||||||
def createAutostart():
|
def createAutostart():
|
||||||
'''
|
'''
|
||||||
create the auto start file gruene_signale.desktop in $HOME/.config/autostart/
|
create the auto start file gruene_signale.desktop in $HOME/.config/autostart/
|
||||||
|
@ -92,6 +69,52 @@ def installModules():
|
||||||
failed.append(module)
|
failed.append(module)
|
||||||
modules=failed
|
modules=failed
|
||||||
|
|
||||||
|
#the main window
|
||||||
|
try:
|
||||||
|
master=tk.Tk()
|
||||||
|
except:
|
||||||
|
if len(sys.argv)>1:
|
||||||
|
# started from command line with arguments
|
||||||
|
if "modinst" in sys.argv:
|
||||||
|
installModules()
|
||||||
|
print("Die Module wurden erfolgreich installiert.")
|
||||||
|
if "autostart" in sys.argv:
|
||||||
|
createAutostart()
|
||||||
|
print("Das Autostart-Objekt wurde erstellt.")
|
||||||
|
if "noautostart" in sys.argv:
|
||||||
|
removeAutostart()
|
||||||
|
print("Das Autostart-Objekt wurde entfernt.")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Es ist ein Tcl-Fehler aufgetreten. Das Skript muss im Desktop-Modus gestartet werden.")
|
||||||
|
print("""Folgende Kommandos sind erlaubt:
|
||||||
|
modinst: wenn notwendig werden fehlende Python Module installiert
|
||||||
|
autostart: Das Autostart-Objekt wird geschrieben
|
||||||
|
noautostart: Das Autostart-Objekt wird entfernt
|
||||||
|
|
||||||
|
Die weiteren Enstellungen koennen in der Datei gruene-signal.conf angepasst werden.""")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
#init variables used in config file and some other places
|
||||||
|
doAutostart=tk.IntVar()
|
||||||
|
bild_dauer=tk.IntVar()
|
||||||
|
DEBUG_PREVIEW=tk.IntVar()
|
||||||
|
localPath=tk.StringVar()
|
||||||
|
remoteURL=tk.StringVar()
|
||||||
|
energyMode=tk.IntVar()
|
||||||
|
energyStart=tk.StringVar()
|
||||||
|
energyStop=tk.StringVar()
|
||||||
|
|
||||||
|
|
||||||
|
#when setup can't find the conf file, inited is set to True
|
||||||
|
inited = False
|
||||||
|
#URL for the Intro-Screens, use as default, if conf is inited
|
||||||
|
introURL="https://wolke.netzbegruenung.de/s/2TPGWN5FtWYy2d8/download"
|
||||||
|
|
||||||
|
#set "dirty" flag to False
|
||||||
|
#any change should set it to True, so we can ask on quit to save data
|
||||||
|
isDirty=False
|
||||||
|
|
||||||
def validateTimeFields(input,newchar,action,name):
|
def validateTimeFields(input,newchar,action,name):
|
||||||
if action == "focusout":
|
if action == "focusout":
|
||||||
if ":" in input:
|
if ":" in input:
|
||||||
|
@ -238,6 +261,7 @@ def buildGUI_1():
|
||||||
|
|
||||||
def buildGUI_2():
|
def buildGUI_2():
|
||||||
#add autostart checkbox
|
#add autostart checkbox
|
||||||
|
doAutostart.set(checkAutostartfile())
|
||||||
row=tk.Frame(master,bd=1,relief=tk.SUNKEN)
|
row=tk.Frame(master,bd=1,relief=tk.SUNKEN)
|
||||||
lab=tk.Label(row,text="Gruene Signale automatisch starten",width=30,anchor='w')
|
lab=tk.Label(row,text="Gruene Signale automatisch starten",width=30,anchor='w')
|
||||||
obj=tk.Checkbutton(row,text="aktiv",variable=doAutostart,command=setDirty)
|
obj=tk.Checkbutton(row,text="aktiv",variable=doAutostart,command=setDirty)
|
||||||
|
|
Loading…
Reference in a new issue