Skip to content
Permalink
Browse files

[processing] fixed handling of None param values in ogr2ogrtopostgis.py

  • Loading branch information
volaya authored and strk committed Oct 17, 2016
1 parent 4953558 commit b94098543983b8b267f36c75756dcebd7c7db2a4
Showing with 25 additions and 17 deletions.
  1. +25 −17 python/plugins/processing/algs/gdal/ogr2ogrtopostgis.py
@@ -153,19 +153,35 @@ def defineCharacteristics(self):
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options'), '', optional=True))

def getConnectionString(self):
host = self.getParameterValue(self.HOST)
port = self.getParameterValue(self.PORT)
user = self.getParameterValue(self.USER)
dbname = self.getParameterValue(self.DBNAME)
password = self.getParameterValue(self.PASSWORD)
schema = self.getParameterValue(self.SCHEMA)
arguments = []
if host:
arguments.append('host=' + host)
if port:
arguments.append('port=' + str(port))
if dbname:
arguments.append('dbname=' + dbname)
if password:
arguments.append('password=' + password)
if schema:
arguments.append('active_schema=' + schema)
if user:
arguments.append('user=' + user)
return GdalUtils.escapeAndJoin(arguments)

def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = ogrConnectionString(inLayer)[1:-1]
shapeEncoding = self.getParameterValue(self.SHAPE_ENCODING)
ssrs = unicode(self.getParameterValue(self.S_SRS))
tsrs = unicode(self.getParameterValue(self.T_SRS))
asrs = unicode(self.getParameterValue(self.A_SRS))
host = unicode(self.getParameterValue(self.HOST))
port = unicode(self.getParameterValue(self.PORT))
user = unicode(self.getParameterValue(self.USER))
dbname = unicode(self.getParameterValue(self.DBNAME))
password = unicode(self.getParameterValue(self.PASSWORD))
schema = unicode(self.getParameterValue(self.SCHEMA))
table = unicode(self.getParameterValue(self.TABLE))
pk = unicode(self.getParameterValue(self.PK))
pkstring = "-lco FID=" + pk
@@ -202,17 +218,9 @@ def getConsoleCommands(self):
arguments.append('"' + shapeEncoding + '"')
arguments.append('-f')
arguments.append('PostgreSQL')
arguments.append('PG:"host=' + host)
arguments.append('port=' + port)
if len(dbname) > 0:
arguments.append('dbname=' + dbname)
if len(password) > 0:
arguments.append('password=' + password)
if len(schema) > 0:
arguments.append('active_schema=' + schema)
else:
arguments.append('active_schema=public')
arguments.append('user=' + user + '"')
arguments.append('PG:"')
arguments.append(self.getConsoleCommands())
arguments.append('"')
arguments.append(dimstring)
arguments.append(ogrLayer)
arguments.append(ogrLayerName(inLayer))

0 comments on commit b940985

Please sign in to comment.
You can’t perform that action at this time.