Bug report #12800
Copy/paste a command line from the Processing history into the python console doesn't work if you have are using a layer in a database
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||20896|
Copy/paste a command line from the Processing history into the python console doesn't work if you have are using a layer in a database.
Some " are mixed with ' in the command line about the table name.
processing.runalg("routing:allocatingedges","/tmp/processing/af6bdbf3a6c546f083c20a2874a1403a/OUTPUT.shp","dbname='demacia' host=localhost port=5432 user='etienne' password='azerty' sslmode=disable key='tid' srid=4326 type=POINT table="public"."feti" (geom) sql=",None)
Same issue with PostGIS or Spatialite.
#2 Updated by Victor Olaya over 6 years ago
- Status changed from Open to Closed
This should be fixed now. It will work even if the database table is not open in QGIS as a layer
Notice that the log is storing your credentials in plain text. That will only happen if you have selected the "save user/saver password" check boxes when connecting to the db. Otherwise, they will not be included in the data source string, but that will cause the command to fail when running from the console if the layer is not loaded already in QGIS.
BTW, there is no need to copy from the history dialog. You can directly double click on the entry in the history and it will execute the algorithm with the provided parameters
#3 Updated by Etienne Trimaille over 6 years ago
However, I can't run any model from the processing dock now.
Launching a model from my plugin also :
Traceback (most recent call last): File "/home/etienne/.qgis2/python/plugins/inasafe/safe/routing/gui/routing_dialog.py", line 252, in accept file_name_network) File "/home/etienne/.qgis2/python/plugins/processing/tools/general.py", line 71, in runalg alg = Processing.runAlgorithm(algOrName, None, *args) File "/home/etienne/.qgis2/python/plugins/processing/core/Processing.py", line 330, in runAlgorithm msg = alg._checkParameterValuesBeforeExecuting() File "/home/etienne/.qgis2/python/plugins/processing/core/GeoAlgorithm.py", line 259, in _checkParameterValuesBeforeExecuting obj = dataobjects.getObjectFromUri(inputlayer) File "/home/etienne/.qgis2/python/plugins/processing/tools/dataobjects.py", line 231, in getObjectFromUri if normalizeLayerSource(layer.source()) == normalizeLayerSource(uri): File "/home/etienne/.qgis2/python/plugins/processing/tools/dataobjects.py", line 215, in normalizeLayerSource s = s.replace('"', "'") UnboundLocalError: local variable 's' referenced before assignment
I guess this error is raised by this ticket ?
I've opened a little PR : https://github.com/qgis/QGIS/pull/2164 to fix this.