From 55a5220111422109d1c5091709c7be94f75322bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=96ScreamingOranges?= Date: Fri, 10 Sep 2021 20:37:50 -0400 Subject: [PATCH] Added Ability To Change/Update Pusher Credentials --- inputGUI.py | 12 ++++++++++-- main.py | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/inputGUI.py b/inputGUI.py index 7720040..1607638 100644 --- a/inputGUI.py +++ b/inputGUI.py @@ -3,28 +3,36 @@ import PyQt5.QtWidgets class inputGUI(PyQt5.QtWidgets.QDialog): - def __init__(self, parent = None): - super(inputGUI, self).__init__(parent) + def __init__(self, pusherCreds = None): + super(inputGUI, self).__init__(None) layout = PyQt5.QtWidgets.QFormLayout() self.btnAppID = PyQt5.QtWidgets.QPushButton("Enter app_id") self.btnAppID.clicked.connect(self.getAppID) self.leAppID = PyQt5.QtWidgets.QLabel() + if pusherCreds != None: + self.leAppID.setText(str(pusherCreds[0])) layout.addRow(self.btnAppID,self.leAppID) self.btnKey = PyQt5.QtWidgets.QPushButton("Enter key") self.btnKey.clicked.connect(self.getKey) self.leKey = PyQt5.QtWidgets.QLabel() + if pusherCreds != None: + self.leKey.setText(str(pusherCreds[1])) layout.addRow(self.btnKey,self.leKey) self.btnSecret = PyQt5.QtWidgets.QPushButton("Enter secret") self.btnSecret.clicked.connect(self.getSecret) self.leSecret = PyQt5.QtWidgets.QLabel() + if pusherCreds != None: + self.leSecret.setText(str(pusherCreds[2])) layout.addRow(self.btnSecret,self.leSecret) self.btnCluster = PyQt5.QtWidgets.QPushButton("Choose cluster") self.btnCluster.clicked.connect(self.chooseCluster) self.leCluster = PyQt5.QtWidgets.QLabel() + if pusherCreds != None: + self.leCluster.setText(str(pusherCreds[3])) layout.addRow(self.btnCluster,self.leCluster) self.btnAccept = PyQt5.QtWidgets.QPushButton("Submit") diff --git a/main.py b/main.py index 9eb0ef1..d16c4c2 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,21 @@ def checkJsonFile(): data = {"pusherAppID":pusherCreds[0],"pusherKey":pusherCreds[1],"pusherSecret":pusherCreds[2],"pusherCluster":pusherCreds[3]} with open('data.json', 'w') as outfile: json.dump(data, outfile) - + +def pusherCredentials(): + global pusherCreds + if os.path.exists("./data.json"): + with open('data.json', 'r') as openfile: + json_object = json.load(openfile) + pusherCreds = json_object["pusherAppID"], json_object["pusherKey"], json_object["pusherSecret"], json_object["pusherCluster"] + ex = inputGUI.inputGUI(pusherCreds) + ex.show() + if ex.exec_() == inputGUI.inputGUI.Accepted: + pusherCreds = ex.pCred + data = {"pusherAppID":pusherCreds[0],"pusherKey":pusherCreds[1],"pusherSecret":pusherCreds[2],"pusherCluster":pusherCreds[3]} + with open('data.json', 'w') as outfile: + json.dump(data, outfile) + def colorResetCall(): conn = icueConnect.icueConnect() conn.releaseControl() @@ -74,6 +88,10 @@ def main(): iCueSDK_Test = PyQt5.QtWidgets.QAction("Test") iCueSDK_Test.triggered.connect(iCueSDK_TestCall) menu.addAction(iCueSDK_Test) + # To change Pusher Creds + pusher_credentials = PyQt5.QtWidgets.QAction("Pusher Credentials") + pusher_credentials.triggered.connect(pusherCredentials) + menu.addAction(pusher_credentials) # To quit the app quit = PyQt5.QtWidgets.QAction("Quit") quit.triggered.connect(app.quit)