small fixes, autstart points to venv now
This commit is contained in:
parent
e8c0341468
commit
10fbc62825
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
# import sys, shutil and osutil for file system access
|
# import sys, shutil and osutil for file system access
|
||||||
import sys
|
import sys
|
||||||
|
|
112
setup.py
112
setup.py
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -28,6 +28,15 @@ except:
|
||||||
modules.append('requests')
|
modules.append('requests')
|
||||||
|
|
||||||
master=None
|
master=None
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# import crontab
|
# import crontab
|
||||||
|
@ -47,7 +56,7 @@ Type=Application
|
||||||
Name=Green Signals Autostart
|
Name=Green Signals Autostart
|
||||||
Comment=Starten der Slideshow von Gruene Signale
|
Comment=Starten der Slideshow von Gruene Signale
|
||||||
NoDisplay=false
|
NoDisplay=false
|
||||||
Exec=sh -c 'cd %(path)s && /bin/python3 gruene_signale.py'
|
Exec=sh -c 'cd %(path)s && %(path)s/venv/bin/python3 gruene_signale.py'
|
||||||
"""
|
"""
|
||||||
if os.path.isfile(autostartfile) == False:
|
if os.path.isfile(autostartfile) == False:
|
||||||
if os.path.exists(os.path.dirname(autostartfile)) == False:
|
if os.path.exists(os.path.dirname(autostartfile)) == False:
|
||||||
|
@ -84,52 +93,6 @@ 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
|
|
||||||
|
|
||||||
class Popup(tk.Toplevel):
|
class Popup(tk.Toplevel):
|
||||||
"""modal window requires a master"""
|
"""modal window requires a master"""
|
||||||
def __init__(self, master, **kwargs):
|
def __init__(self, master, **kwargs):
|
||||||
|
@ -295,7 +258,6 @@ def writeConfig(configFile=None):
|
||||||
with open(configFile, 'w') as file:
|
with open(configFile, 'w') as file:
|
||||||
config.write(file)
|
config.write(file)
|
||||||
|
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
global isDirty,inited
|
global isDirty,inited
|
||||||
if isDirty == False:
|
if isDirty == False:
|
||||||
|
@ -435,10 +397,14 @@ def createVenv():
|
||||||
print( "Not running in a virtual environment" )
|
print( "Not running in a virtual environment" )
|
||||||
if not os.path.exists( "./venv/bin/python3" ):
|
if not os.path.exists( "./venv/bin/python3" ):
|
||||||
splash = tk.Tk()
|
splash = tk.Tk()
|
||||||
splash.geometry("800x450+560+300")
|
splash.geometry("440x120+660+400")
|
||||||
splash.title("einen Moment...")
|
# splash.title("Einstellungen: Gruene Signale")
|
||||||
|
splash.configure(bg="DarkSeaGreen1")
|
||||||
splash.overrideredirect(True)
|
splash.overrideredirect(True)
|
||||||
label = tk.Label(splash, text="Bitte ein wenig Geduld", font=("System", 32)).pack(pady=200)
|
label = tk.Label(splash, text="Bitte ein wenig Geduld", bg="DarkSeaGreen1", font=("System", 24))
|
||||||
|
label.pack(padx=4, pady=4, ipady=4)
|
||||||
|
label2 = tk.Label(splash, text="Es wird eine virtuelle Umgebung angelegt.", bg="DarkSeaGreen1", font=("System", 14))
|
||||||
|
label2.pack(padx=4, pady=0, ipady=4)
|
||||||
splash.update()
|
splash.update()
|
||||||
print( "Create a new virtual environment" )
|
print( "Create a new virtual environment" )
|
||||||
subprocess.check_call([sys.executable, "-m", "venv", "./venv"] )
|
subprocess.check_call([sys.executable, "-m", "venv", "./venv"] )
|
||||||
|
@ -452,10 +418,48 @@ def createVenv():
|
||||||
return
|
return
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global master, dx, dy
|
global master #, dx, dy
|
||||||
createVenv()
|
createVenv()
|
||||||
readConfig()
|
|
||||||
|
|
||||||
|
#init variables used in config file and some other places
|
||||||
|
global doAutostart, bild_dauer, DEBUG_PREVIEW, localPath, remoteURL, energyMode, energyStart, energyStop
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
readConfig()
|
||||||
master.minsize(600,300)
|
master.minsize(600,300)
|
||||||
master.geometry("800x450+560+300")
|
master.geometry("800x450+560+300")
|
||||||
master.title("Einstellungen: Gruene Signale")
|
master.title("Einstellungen: Gruene Signale")
|
||||||
|
|
Loading…
Reference in a new issue