diff --git a/mainApp.py b/mainApp.py index af7cb5a..5b51b4b 100644 --- a/mainApp.py +++ b/mainApp.py @@ -334,9 +334,11 @@ def loadVfkButton_clicked(self): else: new_database_name = '{}_stav.db'.format(os.path.basename(self.__fileName[0]).split('.')[0]) - os.environ['OGR_VFK_DB_NAME'] = os.path.join( - os.path.dirname(os.path.dirname(self.__fileName[0])), new_database_name) - self.__mDataSourceName = self.__fileName[0] # os.environ['OGR_VFK_DB_NAME'] + gdal.SetConfigOption( + 'OGR_VFK_DB_NAME', + str(os.path.join(os.path.dirname(self.__fileName[0]), new_database_name)) + ) + self.__mDataSourceName = self.__fileName[0] QgsApplication.processEvents() @@ -376,7 +378,8 @@ def loadingLayersFinished(self): """ try: self.__openDatabase( - os.environ['OGR_VFK_DB_NAME']) # self.__mDataSourceName) + gdal.GetConfigOption('OGR_VFK_DB_NAME') + ) except VFKError as e: QMessageBox.critical( self, u'Chyba', u'{}'.format(e), QMessageBox.Ok) @@ -519,7 +522,7 @@ def loadVfkFile(self, fileName): if fileName == self.__fileName[0]: if self.overwriteCheckBox.isChecked(): QgsMessageLog.logMessage(u'(VFK) Database will be overwritten') - os.environ['OGR_VFK_DB_OVERWRITE'] = '1' + gdal.SetConfigOption('OGR_VFK_DB_OVERWRITE', 'YES') if self.__mOgrDataSource: self.__mOgrDataSource.Destroy() @@ -532,7 +535,6 @@ def loadVfkFile(self, fileName): QgsApplication.processEvents() - #os.environ['OGR_VFK_DB_READ_ALL_BLOCKS'] = 'NO' self.labelLoading.setText( u'Načítám soubor {} (může nějaký čas trvat...)'.format(label_text)) @@ -575,7 +577,7 @@ def loadVfkFile(self, fileName): self.labelLoading.setText( u'Soubor {} úspěšně načten.'.format(label_text)) - os.environ['OGR_VFK_DB_OVERWRITE'] = '0' + gdal.SetConfigOption('OGR_VFK_DB_OVERWRITE', 'NO') self.__mOgrDataSource.Destroy() self.__mOgrDataSource = None diff --git a/vfkTableModel.py b/vfkTableModel.py index b61612a..5e7e71d 100644 --- a/vfkTableModel.py +++ b/vfkTableModel.py @@ -968,8 +968,9 @@ def __evaluate(self, query): QgsMessageLog.logMessage("(VFK) Time elapsed: {} ms\n".format(t.elapsed())) if self.lastError().isValid(): - iface.messageBar().pushWarning(u'ERROR', - u'SQL: {}'.format(self.lastError().text()) + iface.messageBar().pushWarning( + u'ERROR', + u'SQL ({}): {}'.format(query, self.lastError().text()) ) return False