define timeslots in config
This commit is contained in:
parent
02ca1d543d
commit
b5671b9282
|
@ -0,0 +1,2 @@
|
|||
__pycache__/
|
||||
bbbbs.sqlite
|
|
@ -1 +1,2 @@
|
|||
version="0.0.1"
|
||||
version="dev"
|
||||
timeslots = ["09:00", "15:30", "20:45"]
|
||||
|
|
18
db.py
18
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()
|
||||
|
||||
|
|
3
main.py
3
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)
|
||||
|
|
Loading…
Reference in New Issue