FirstStart angepasst
This commit is contained in:
@@ -6,6 +6,7 @@ from PySide6.QtCore import QObject, Slot
|
||||
from .Vermasseln import Vermasseln
|
||||
import shutil
|
||||
from urllib.parse import urlparse
|
||||
from .DB.DbManager import DbManager
|
||||
import os
|
||||
|
||||
class ConfigLoader(QObject):
|
||||
@@ -31,31 +32,57 @@ class ConfigLoader(QObject):
|
||||
confile = confile[1:]
|
||||
shutil.copyfile(confile, self.config_dir+ '/pyqcrm.toml')
|
||||
|
||||
@Slot(dict)
|
||||
@Slot(dict, result= bool)
|
||||
def addAdminUser(self, admin_config):
|
||||
print(admin_config)
|
||||
return True
|
||||
|
||||
@Slot(dict, result= bool)
|
||||
def setConfig(self, app_config):
|
||||
try:
|
||||
with open (self.config_dir + '/pyqcrm.toml', 'w') as f:
|
||||
config = Vermasseln().oscarVermasseln(toml.dumps(app_config))
|
||||
f.write(config)
|
||||
except FileNotFoundError:
|
||||
print("Konnte die Konfiguration nicht speichern.")
|
||||
|
||||
conf = self.__checkDbConnection(app_config)
|
||||
if conf:
|
||||
try:
|
||||
with open (self.config_dir + '/pyqcrm.toml', 'w') as f:
|
||||
config = Vermasseln().oscarVermasseln(toml.dumps(app_config))
|
||||
f.write(config)
|
||||
except FileNotFoundError:
|
||||
conf = False
|
||||
print("Konnte die Konfiguration nicht speichern.")
|
||||
conf = self.__checkAdminUser()
|
||||
|
||||
return conf
|
||||
|
||||
|
||||
def __configLoad(self):
|
||||
try:
|
||||
with open (self.config_dir + '/pyqcrm.toml', 'r') as f:
|
||||
config = f.read()
|
||||
|
||||
self.__config = toml.loads(Vermasseln().entschluesseln(config))
|
||||
except FileNotFoundError:
|
||||
print("Konnte die Konfiguration nicht laden.")
|
||||
|
||||
except TypeError:
|
||||
print("Invalid Configuration")
|
||||
# except Exception as e:
|
||||
# print(str(e))
|
||||
|
||||
|
||||
def getConfig(self):
|
||||
|
||||
return self.__config
|
||||
|
||||
def createConfig(self):
|
||||
def __createConfig(self):
|
||||
|
||||
with open(self.config_dir + '/pyqcrm.toml', "w") as datei:
|
||||
datei.write("[pyqcrm]")
|
||||
|
||||
def __checkDbConnection(self, db_config):
|
||||
con = DbManager(db_config['database']).getConnection()
|
||||
if con:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def __checkAdminUser(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user