Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
fix: no tkinter and cli interface on servers #88 #89
Browse files Browse the repository at this point in the history
  • Loading branch information
sibalzer committed Jun 9, 2021
2 parents b1c9988 + 19157e8 commit 8e6777f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions src/config_generator.py
@@ -1,12 +1,19 @@
""" generate a config if none found """
import tkinter as tk
import re
from tkinter import ttk
from tkcalendar import DateEntry

from common import NOTIFIERS, NOTIFIER_REGEX, ZIP_REGEX
from config_skeleton import SKELETON

try:
import tkinter as tk
from tkinter import ttk
from tkcalendar import DateEntry
run_gui = True
except ImportError:
# tk is missing -> run CLI config
run_gui = False


FIELDS = {
"EMAIL": {
"sender": "Absender",
Expand Down Expand Up @@ -49,12 +56,13 @@ def init_input(config_dict):

def start_config_generation(config_dict: dict = dict()):
""" entry point for config generation """
run_gui = True
try:
gui_window = tk.Tk()
except tk.TclError:
# most likely no display was found (i. e. running headless)
run_gui = False
global run_gui
if run_gui:
try:
gui_window = tk.Tk()
except tk.TclError:
# most likely no display was found (i. e. running headless)
run_gui = False

init_input(config_dict)
if run_gui:
Expand Down
2 changes: 1 addition & 1 deletion src/impfbot.py
Expand Up @@ -5,6 +5,7 @@
from alerts import alert
from api_wrapper import fetch_api, ShadowBanException, RequestConnectionError
from common import sleep, sleep_until, is_night, datetime2timestamp, YES, NO
from config_generator import start_config_generation
from log import log
from settings import load, settings, ParseExeption

Expand Down Expand Up @@ -85,7 +86,6 @@ def check_for_slot() -> None:
print("Do you want to use the interface to generate a config? yes/no")
result = input()
if result in YES:
from config_generator import start_config_generation
log.info("Starting config generator")
start_config_generation()
break
Expand Down

0 comments on commit 8e6777f

Please sign in to comment.