Commit bb0dc430 authored by magho's avatar magho
Browse files

take argument for config file paths

parent 9afecd12
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
import os
import sys
import math
from PyQt5 import QtCore, QtGui, QtWidgets
@@ -18,13 +19,24 @@ class NeoKomp(QtWidgets.QMainWindow):
    Top level class for NeoKomp
    It Sets up each store frame
    """
    def __init__(self, parent=None):
    def __init__(self, config_path=None, parent=None):
        super().__init__(parent)
        self.parent = parent

        with open ("apikey.key", "r") as myfile:
        if config_path != None:
            config_file_path = "%s/" % config_path
        else:
            config_file_path = ""

        # Read in parameters
        with open ("%sapikey.key" % config_file_path, "r") as myfile:
            self.API_key = myfile.readline().rstrip("\n\r")

        # Read in device <-> seksjon mapping as a dict
        # device_mapping.txt must contain lines with <BLE Address> <Seksjon>
        with open('%sdevice_mapping.txt' % config_file_path) as f:
            self.device_mapping = dict(x.rstrip().split(None, 1) for x in f)

        # Window Title
        self.setWindowTitle("NeoKomp")

@@ -47,10 +59,6 @@ class NeoKomp(QtWidgets.QMainWindow):
        # Initial state
        self.central_widget.setCurrentWidget(self.frames['Guide'])

        # Read in device <-> seksjon mapping as a dict
        # device_mapping.txt must contain lines with <BLE Address> <Seksjon>
        with open('device_mapping.txt') as f:
            self.device_mapping = dict(x.rstrip().split(None, 1) for x in f)

        # Make RFID manager
        self.rfid_manager = rfid.RFIDManager(self)
+5 −1
Original line number Diff line number Diff line
import sys
from PyQt5 import QtCore, QtGui, QtWidgets

import NeoKomp

def main():
    app = QtWidgets.QApplication([])
    if (len(sys.argv) > 1):
        neokomp = NeoKomp.NeoKomp(config_path=sys.argv[1])
    else:
        neokomp = NeoKomp.NeoKomp()
    neokomp.setWindowTitle("NeoKomp")
    neokomp.show()