-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (54 loc) · 1.77 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import configparser
import os.path
import sys
from os.path import expanduser
from pathlib import Path
from PyQt5.QtWidgets import QDialog , QApplication
from ui.hobespenak import Ui_Dialog
home = expanduser("~")
SETTINGS_DIR = os.path.join(home , '.asuranzeturix/')
SETTINGS_FILE = os.path.join(home , '.asuranzeturix/config')
SETTINGS = {}
class MainWindow(QDialog , Ui_Dialog):
def __init__( self , parent = None ):
super(MainWindow , self).__init__(parent)
self.setupUi(self)
self.buttonBox.accepted.connect(self.gorde)
def gorde( self ):
print("gorde")
if not os.path.isfile(SETTINGS_FILE):
os.makedirs(SETTINGS_DIR)
Path(SETTINGS_FILE).touch()
server = self.txtZerbitzaria.text()
portua = self.txtPortua.text()
user = self.txtUsername.text()
passwd = self.txtPassword.text()
email = self.txtEmaila.text()
config = configparser.ConfigParser()
config['AMI'] = {
'zerbitzaria' : server ,
'portua' : portua ,
'erabiltzailea': user ,
'pasahitza' : passwd
}
config['USER'] = {
'email': email
}
with open(SETTINGS , 'w') as configfile:
config.write(configfile)
def read_config( ):
parser = configparser.ConfigParser()
parser.read(SETTINGS_FILE)
confdict = {section: dict(parser.items(section)) for section in parser.sections()}
return confdict
def main( ):
print("Yaml irakurtzen")
SETTINGS = read_config()
if __name__ == '__main__':
if not os.path.isfile(SETTINGS_FILE):
print("Ez da existitzen")
app = QApplication(sys.argv)
form = MainWindow()
form.show()
sys.exit(app.exec_())
main()