From b5671b92829bfd6eb0122d2e04ad2af6d66fe11f Mon Sep 17 00:00:00 2001 From: knoflook Date: Fri, 2 Dec 2022 11:34:32 +0100 Subject: [PATCH] define timeslots in config --- .gitignore | 2 ++ config.py | 3 ++- db.py | 18 ------------------ main.py | 3 +-- 4 files changed, 5 insertions(+), 21 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..271c775 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +bbbbs.sqlite diff --git a/config.py b/config.py index 9c4d20e..b1329a4 100644 --- a/config.py +++ b/config.py @@ -1 +1,2 @@ -version="0.0.1" +version="dev" +timeslots = ["09:00", "15:30", "20:45"] diff --git a/db.py b/db.py index add9327..f18a1cd 100755 --- a/db.py +++ b/db.py @@ -39,24 +39,6 @@ def create_transmissions_table(): else: log.debug('DB transmissions exists, not creating.') -def create_timeslots_table(): - scheme = """ - CREATE TABLE IF NOT EXISTS timeslots ( - timeslot INT NOT NULL, - time TEXT NOT NULL, - active BOOLEAN NOT NULL - ); - """ - if cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='timeslots';").fetchall() == []: - try: - cursor.execute(scheme) - log.info("Successfully created database transmissions") - except sqlite3.Error as error: - log.critical("Couldn't create timeslots table: ", error) - exit(1) - else: - log.debug('DB timeslots exists, not creating.') - def get_transmissions(date=None, timeslot=None): return cursor.execute("SELECT * FROM transmissions").fetchall() diff --git a/main.py b/main.py index 1b57cab..849daec 100755 --- a/main.py +++ b/main.py @@ -13,7 +13,6 @@ import db log = logging.getLogger("main") db.create_transmissions_table() -db.create_timeslots_table() class MainWindow(Gtk.Window): def __init__(self): @@ -96,7 +95,7 @@ class MainWindow(Gtk.Window): self.picked_date = "%i-%s-%s"%(year, month, day) self.timeslots = Gtk.ListBox() - for slot in ["09:00", "15:00", "21:00"]: + for slot in config.timeslots: row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) row.add(hbox)