개정판 cc81e778
add db check
Change-Id: Ide50e296d4a7a7945f7ffdacfe9025f7df55c131
DTI_PID/DTI_PID/ProjectDialog.py | ||
---|---|---|
103 | 103 |
project.database.user = self.ui.lineEditUser.text() |
104 | 104 |
project.database.password = self.ui.lineEditPassword.text() |
105 | 105 |
project.database.file_path = project.name |
106 |
if not self.on_test_connection_clicked(True): |
|
107 |
QMessageBox.warning(self, self.tr('Error'), self.tr('DB connection failed')) |
|
108 |
return |
|
106 | 109 |
else: |
107 | 110 |
project.database.host = None |
108 | 111 |
project.database.user = None |
... | ... | |
232 | 235 |
self.ui.lineEditPassword.setEnabled(True) |
233 | 236 |
self.ui.pushButtonTestConnection.setEnabled(True) |
234 | 237 |
|
235 |
def on_test_connection_clicked(self): |
|
238 |
def on_test_connection_clicked(self, start=False):
|
|
236 | 239 |
from AppDatabase import AppDatabase |
237 | 240 |
|
238 | 241 |
index = self.ui.comboBox.currentIndex() |
... | ... | |
242 | 245 |
try: |
243 | 246 |
conn = database.connect() |
244 | 247 |
with conn: |
245 |
QMessageBox.information(self, self.tr('Information'), self.tr('Test connection is success')) |
|
248 |
if not start: |
|
249 |
QMessageBox.information(self, self.tr('Information'), self.tr('Test connection is success')) |
|
250 |
return True |
|
246 | 251 |
except Exception as ex: |
247 | 252 |
mb = QMessageBox() |
248 | 253 |
mb.setIcon(QMessageBox.Critical) |
249 | 254 |
mb.setWindowTitle(self.tr('Error')) |
250 | 255 |
mb.setText('{}'.format(ex)) |
251 | 256 |
mb.exec_() |
257 |
return False |
|
252 | 258 |
|
253 | 259 |
def insertProjectInfo(self, desc, prj_unit, dir): |
254 | 260 |
AppDocData.instance().insertProjectInfo(dir=dir, desc=desc, prj_unit=prj_unit) |
내보내기 Unified diff