Skip to content

Commit

Permalink
fix environmental variables handling
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed Aug 19, 2018
1 parent e92ae9c commit c15c121
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 9 additions & 7 deletions mainApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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))

Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions vfkTableModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c15c121

Please sign in to comment.