[QGIS-Developer] QGIS-Documentation fails to build
Hi devs, QGIS-Documentation build test is failing due to "WARNING: py:meth reference target not found: qgis.core.QgsVectorLayer.setDataSource" [0] It looks like the QgsVectorLayer.setDataSource method is no longer available in master. Anyone knows what is the replacement? Thanks, Harrissou [0] https://github.com/qgis/QGIS-Documentation/runs/2672228415?check_suite_focus=true#step:5:622 ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] Build issue and SIP_CONCAT_PARTS
Hi devs, I'm working on a new QGIS feature and wanted to add a new API in core module. I get a strange error when building, on a class not related to what I am adding. /home/julien/work/QGIS/build_debug/python/core/sip_corepart11.cpp:272:67: error: no type named 'QgsOptionalQgsExpressionBase' in the global namespace; did you mean 'QgsOptionalExpression'? ::QgsOptionalQgsExpressionBase *sipCpp = reinterpret_cast< ::QgsOptionalQgsExpressionBase *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QgsOptionalQgsExpressionBase)); It said that QgsOptionalExpressionBase is not defined in sip_corepart_11.cpp, but the typedef is actually in sip_corepart_10.cpp, at the end of the file. >From what I understand, CMakeList variable SIP_CONCAT_PARTS allows to split the SIP generated cpp code in several module, but in this case it looks like split happens on a bad location (typedef on one side, part of the code on the other side). If I set SIP_CONCAT_PARTS to 1, it works. Has anyone already facing this kind of issue? Is there some sort of instruction that I should be aware of to solve this? I'm on master, Debian Bullseye, SIP 4.19.25 Kind regards, Julien ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS-Documentation fails to build
It has been moved to the parent class QgsMapLayer On Wed, May 26, 2021 at 3:32 PM DelazJ wrote: > Hi devs, > > QGIS-Documentation build test is failing due to "WARNING: py:meth > reference target not found: qgis.core.QgsVectorLayer.setDataSource" [0] > It looks like the QgsVectorLayer.setDataSource method is no longer > available in master. Anyone knows what is the replacement? > > Thanks, > Harrissou > > [0] > https://github.com/qgis/QGIS-Documentation/runs/2672228415?check_suite_focus=true#step:5:622 > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > -- Alessandro Pasotti QCooperative: www.qcooperative.net ItOpen: www.itopen.it ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS standalone script examples (and Oracle)
Hi, I think I've worked it out. The initialisation of the authentication manager needs to be done before the project read command. I had the logic near where I was adding a layer (i.e. after the opening of the project) but it needs to be initialised before the project is read. The result is that the original layers are now still valid. I knew it would be obvious when I worked it out. The only outstanding question is why the authenticationDatabasePath() Returns a path in the AppData\Roaming\python Folder instead of AppData\Roaming\QGIS despite my specifying the correct path in the .init() function? Thank you again for all your help on this as I think I should be able to get it working now even if I do have to copy the relevant *.db files to the python folder. Best Regards, Paul -Original Message- From: Richard Duivenvoorde Sent: 26 May 2021 10:13 To: Paul Wittle Cc: qgis-dev Subject: Re: [QGIS-Developer] QGIS standalone script examples (and Oracle) On 5/26/21 9:19 AM, Paul Wittle wrote: > The result is that the existing PostGIS layer is still broken but the second > instance (the new layer added by the script) is working. Very curious; > perhaps I need to put in a loop that scans the layer list looking for > database layers and explicitly resets the data source. > > I will also double check because the only other possibility may be that it is > linked to the existing layers using the Authentication manager rather than a > typed username and password in the project file. > > Can anyone else replicate this issue or is it just me? Hi Paul, IF you use the authentication manager, is it possible that your script cannot find the authentication db (or does not provide a valid password/wallet to open it?)? https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/authentication.html I tested by adding a db layer in my 'template' project. 1 one with basic auth username/password 2 one using the authentication manager Although I do not wreck my testoutput project (it still loads all layers after running test.py), I do see the following (I'm using a debug build of QGIS) running my test script: ../src/providers/postgres/qgspostgresconn.cpp:1063 : (postgisVersion) [250ms] geos:3.9.0-CAPI-1.16.2 proj:7.2.1 static bool LibSecretKeyring::findPassword(const QString&, const QString&, QKeychain::JobPrivate*) ../src/core/auth/qgsauthmanager.cpp:1005 : (configAuthMethod) [53ms] No config auth method found in database for authcfg: 7t8kl0t ../src/core/qgsdatasourceuri.cpp:526 : (connectionInfo) [0ms] Data source URI FAILED to update via loading configuration ID '7t8kl0t' ../src/core/qgsmessagelog.cpp:29 : (logMessage) [1ms] 2021-05-26T11:04:11 PostGIS[1] Connection to database failed fe_sendauth: no password supplied ../src/core/vector/qgsvectorlayer.cpp:1565 : (readXml) [0ms] Could not set data provider for layer dbname='gis' host=localhost port=5432 sslmode=disable authcfg=7t8kl0t key='id' srid=28992 type=MultiPolygon checkPrimaryKeyUnicity='0' table="public"."prov" (geom) ../src/core/project/qgsproject.cpp:1233 : (addLayer) [0ms] Unable to load vector layer ../src/core/project/qgsproject.cpp:1578 : (readProjectFile) [39ms] Unable to get map layers from project file. ../src/core/project/qgsproject.cpp:1582 : (readProjectFile) [0ms] there are 1 broken layers ../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2021-05-26T11:04:11 [1] 1 unavailable layers found: ../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2021-05-26T11:04:11 [1] * dbname='gis' host=localhost port=5432 sslmode=disable authcfg=7t8kl0t key='id' srid=28992 type=MultiPolygon checkPrimaryKeyUnicity='0' table="public"."prov" (geom) ../src/providers/postgres/qgspostgresconn.cpp:1063 : (postgisVersion) [62ms] geos:3.9.0-CAPI-1.16.2 proj:7.2.1 As said: my newly (written) project is still valid, are you overwriting the old qgs file? Richard This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. It may contain unclassified but sensitive or protectively marked material and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All traffic may be subject to recording and/or monitoring in accordance with relevant legislation. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Dorset Council. Dorset Council does not accept service of documents by fax or other electronic means. Virus checking: Whilst all reasonable steps have been taken to ensure that this electronic communication and its attachments whether encoded, encrypted or otherwise supp lied are free from computer viruses, Dorset Council accepts no
[QGIS-Developer] QgsProcessingFeedback setProgressText method
Hi all, while developing a Processing plugin, within a loop I'm using the 2 "standard" methods to set the % of progress bar (feedback.setProgress()) and to update accordingly the progress text (feedback.setProgressText()). In the latter case I noticed that the text is also written in the Log panel. Is this the standard behavior? Cheers and thanks! Matteo ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS standalone script examples (and Oracle)
On 5/26/21 9:19 AM, Paul Wittle wrote: > The result is that the existing PostGIS layer is still broken but the second > instance (the new layer added by the script) is working. Very curious; > perhaps I need to put in a loop that scans the layer list looking for > database layers and explicitly resets the data source. > > I will also double check because the only other possibility may be that it is > linked to the existing layers using the Authentication manager rather than a > typed username and password in the project file. > > Can anyone else replicate this issue or is it just me? Hi Paul, IF you use the authentication manager, is it possible that your script cannot find the authentication db (or does not provide a valid password/wallet to open it?)? https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/authentication.html I tested by adding a db layer in my 'template' project. 1 one with basic auth username/password 2 one using the authentication manager Although I do not wreck my testoutput project (it still loads all layers after running test.py), I do see the following (I'm using a debug build of QGIS) running my test script: ../src/providers/postgres/qgspostgresconn.cpp:1063 : (postgisVersion) [250ms] geos:3.9.0-CAPI-1.16.2 proj:7.2.1 static bool LibSecretKeyring::findPassword(const QString&, const QString&, QKeychain::JobPrivate*) ../src/core/auth/qgsauthmanager.cpp:1005 : (configAuthMethod) [53ms] No config auth method found in database for authcfg: 7t8kl0t ../src/core/qgsdatasourceuri.cpp:526 : (connectionInfo) [0ms] Data source URI FAILED to update via loading configuration ID '7t8kl0t' ../src/core/qgsmessagelog.cpp:29 : (logMessage) [1ms] 2021-05-26T11:04:11 PostGIS[1] Connection to database failed fe_sendauth: no password supplied ../src/core/vector/qgsvectorlayer.cpp:1565 : (readXml) [0ms] Could not set data provider for layer dbname='gis' host=localhost port=5432 sslmode=disable authcfg=7t8kl0t key='id' srid=28992 type=MultiPolygon checkPrimaryKeyUnicity='0' table="public"."prov" (geom) ../src/core/project/qgsproject.cpp:1233 : (addLayer) [0ms] Unable to load vector layer ../src/core/project/qgsproject.cpp:1578 : (readProjectFile) [39ms] Unable to get map layers from project file. ../src/core/project/qgsproject.cpp:1582 : (readProjectFile) [0ms] there are 1 broken layers ../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2021-05-26T11:04:11 [1] 1 unavailable layers found: ../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2021-05-26T11:04:11 [1] * dbname='gis' host=localhost port=5432 sslmode=disable authcfg=7t8kl0t key='id' srid=28992 type=MultiPolygon checkPrimaryKeyUnicity='0' table="public"."prov" (geom) ../src/providers/postgres/qgspostgresconn.cpp:1063 : (postgisVersion) [62ms] geos:3.9.0-CAPI-1.16.2 proj:7.2.1 As said: my newly (written) project is still valid, are you overwriting the old qgs file? Richard ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS standalone script examples (and Oracle)
Hi, I've now done a test adding a PostGIS layer as well; in fact the same layer as the existing one in the project. The result is that the existing PostGIS layer is still broken but the second instance (the new layer added by the script) is working. Very curious; perhaps I need to put in a loop that scans the layer list looking for database layers and explicitly resets the data source. I will also double check because the only other possibility may be that it is linked to the existing layers using the Authentication manager rather than a typed username and password in the project file. Can anyone else replicate this issue or is it just me? Thanks, Paul -Original Message- From: Paul Wittle Sent: 26 May 2021 07:40 To: rdmaili...@duif.net Cc: qgis-dev Subject: RE: [QGIS-Developer] QGIS standalone script examples (and Oracle) Hi, Sorry another slight miscommunication I think; I didn't add the PostGIS layer via the Python code. I'm saying the project I'm using already contained a PostGIS layer. It is the existing layers that are being corrupted by the save process not the ones you add. Everything I 'do' as it were works fine it is the things that break that shouldn't be touched that I'm trying to understand. Have you tried it with a PostGIS layer already in your project before you start? The method to replicate; if that is even possible as it might be the way I'm running it rather than general, is: 1) Create a project with a few layers in QGIS (ensure one is a database layer) 2) Open and write the project file via a standalone script (you can add a layer if you like but you don't have to and thus far I've only tried adding GeoPackage layers) 3) Re-open the project in QGIS and look to see if all the original layers are still working. I hope that clarifies but I will now have a go at adding a second PostGIS layer via the script to see if the existing layer is then okay. If we consider your earlier comment about initialising the Oracle driver it seems possible that adding a PostGIS layer in the standalone script will require the correct drivers to exist so perhaps that will protect the existing layers? I'll give it a shot. Thanks, Paul -Original Message- From: Richard Duivenvoorde Sent: 25 May 2021 20:32 To: Paul Wittle Cc: qgis-dev Subject: Re: [QGIS-Developer] QGIS standalone script examples (and Oracle) Hi Paul, Adding the following to my earlier test script resulted in a valid Postgis layer in QGIS: ``` uri = QgsDataSourceUri() uri.setConnection("localhost", "5432", "gis", "user", "password") uri.setDataSource("public", "plaatsen", "geom") # schema, table, geom column dblayer = QgsVectorLayer(uri.uri(), "plaatsen", "postgres") # uri, layername, provider if dblayer.isValid(): project_instance.addMapLayer(dblayer,False) else: print("Postgres layer NOT valid !") group_entry.insertChildNode(2,QgsLayerTreeLayer(dblayer)) ``` Note that the 'uri' info you can retrieve from the python console, by loading the layer via QGIS, make it active and then in console: iface.mapCanvas().currentLayer().dataProvider().uri() which for me resulted in something like: # dbname='gis' host=localhost port=5432 user='user' password='password' sslmode=disable key='id' srid=0 type=Point checkPrimaryKeyUnicity='0' table="public"."plaatsen" (geom) HTH, Richard Duivenvoorde On 5/25/21 4:04 PM, Paul Wittle wrote: > Hi, > > I've now done a test using a PostGIS table instead of Oracle and I get a > similar result. > > It doesn't ask for security credentials or bring up a handle bad layers > dialog but the PostGIS table which is working before you run the script > appears as an entry in the layers list but doesn't draw. > > The > expanded="1" legend_split_behavior="0" name="TEST_PARISHES" > checked="Qt::Checked" > id="TEST_PARISHES_0724930d_e27b_4279_ad0d_e0f6f7bf5973" > patch_size="-1,-1" providerKey="postgres"> > > Converts to: > name="TEST_PARISHES" legend_exp="" > id="TEST_PARISHES_0724930d_e27b_4279_ad0d_e0f6f7bf5973" expanded="1" > checked="Qt::Checked"> > > I think the way I'm calling the standalone script must just not work...but > I'm not sure why. > > Thanks again for all your help on this. > Paul > > -Original Message- > From: Paul Wittle > Sent: 25 May 2021 08:41 > To: rdmaili...@duif.net > Cc: qgis-dev > Subject: RE: [QGIS-Developer] QGIS standalone script examples (and > Oracle) > > Ah, I see your point. > > I will setup a project with a PostGIS table and a couple of WMS layers and > see how that fairs. > > I terms of the error I get... When I open the project all the layers are > there with datasource entries but the Layer name column is blank as is the > provider column. > > So and entry reads: > > Layer name = null Type = vector provider = null Auth config = Edit > Datasource = datasource (no errors there) > > I therefore assume it is deleting something in the canvas settings that is > needed for QGIS to realise the
Re: [QGIS-Developer] QGIS standalone script examples (and Oracle)
Hi, Sorry another slight miscommunication I think; I didn't add the PostGIS layer via the Python code. I'm saying the project I'm using already contained a PostGIS layer. It is the existing layers that are being corrupted by the save process not the ones you add. Everything I 'do' as it were works fine it is the things that break that shouldn't be touched that I'm trying to understand. Have you tried it with a PostGIS layer already in your project before you start? The method to replicate; if that is even possible as it might be the way I'm running it rather than general, is: 1) Create a project with a few layers in QGIS (ensure one is a database layer) 2) Open and write the project file via a standalone script (you can add a layer if you like but you don't have to and thus far I've only tried adding GeoPackage layers) 3) Re-open the project in QGIS and look to see if all the original layers are still working. I hope that clarifies but I will now have a go at adding a second PostGIS layer via the script to see if the existing layer is then okay. If we consider your earlier comment about initialising the Oracle driver it seems possible that adding a PostGIS layer in the standalone script will require the correct drivers to exist so perhaps that will protect the existing layers? I'll give it a shot. Thanks, Paul -Original Message- From: Richard Duivenvoorde Sent: 25 May 2021 20:32 To: Paul Wittle Cc: qgis-dev Subject: Re: [QGIS-Developer] QGIS standalone script examples (and Oracle) Hi Paul, Adding the following to my earlier test script resulted in a valid Postgis layer in QGIS: ``` uri = QgsDataSourceUri() uri.setConnection("localhost", "5432", "gis", "user", "password") uri.setDataSource("public", "plaatsen", "geom") # schema, table, geom column dblayer = QgsVectorLayer(uri.uri(), "plaatsen", "postgres") # uri, layername, provider if dblayer.isValid(): project_instance.addMapLayer(dblayer,False) else: print("Postgres layer NOT valid !") group_entry.insertChildNode(2,QgsLayerTreeLayer(dblayer)) ``` Note that the 'uri' info you can retrieve from the python console, by loading the layer via QGIS, make it active and then in console: iface.mapCanvas().currentLayer().dataProvider().uri() which for me resulted in something like: # dbname='gis' host=localhost port=5432 user='user' password='password' sslmode=disable key='id' srid=0 type=Point checkPrimaryKeyUnicity='0' table="public"."plaatsen" (geom) HTH, Richard Duivenvoorde On 5/25/21 4:04 PM, Paul Wittle wrote: > Hi, > > I've now done a test using a PostGIS table instead of Oracle and I get a > similar result. > > It doesn't ask for security credentials or bring up a handle bad layers > dialog but the PostGIS table which is working before you run the script > appears as an entry in the layers list but doesn't draw. > > The > expanded="1" legend_split_behavior="0" name="TEST_PARISHES" > checked="Qt::Checked" > id="TEST_PARISHES_0724930d_e27b_4279_ad0d_e0f6f7bf5973" > patch_size="-1,-1" providerKey="postgres"> > > Converts to: > name="TEST_PARISHES" legend_exp="" > id="TEST_PARISHES_0724930d_e27b_4279_ad0d_e0f6f7bf5973" expanded="1" > checked="Qt::Checked"> > > I think the way I'm calling the standalone script must just not work...but > I'm not sure why. > > Thanks again for all your help on this. > Paul > > -Original Message- > From: Paul Wittle > Sent: 25 May 2021 08:41 > To: rdmaili...@duif.net > Cc: qgis-dev > Subject: RE: [QGIS-Developer] QGIS standalone script examples (and > Oracle) > > Ah, I see your point. > > I will setup a project with a PostGIS table and a couple of WMS layers and > see how that fairs. > > I terms of the error I get... When I open the project all the layers are > there with datasource entries but the Layer name column is blank as is the > provider column. > > So and entry reads: > > Layer name = null Type = vector provider = null Auth config = Edit > Datasource = datasource (no errors there) > > I therefore assume it is deleting something in the canvas settings that is > needed for QGIS to realise the layers are Oracle. This is also proved by the > log windows where I get the same number of errors in a PostGIS tab even > though I have no PostGIS layers in the project. It appears that QGIS believes > them to be PostGIS layers. > > I'll have a go at your suggestions now. > > Paul > > -Original Message- > From: Richard Duivenvoorde > Sent: 24 May 2021 16:59 > To: Paul Wittle > Cc: qgis-dev > Subject: Re: [QGIS-Developer] QGIS standalone script examples (and > Oracle) > > On 5/24/21 2:54 PM, Paul Wittle wrote: > >> Unfortunately I can't simply exclude Oracle as that is currently our spatial >> database provider and whilst we are migrating to PostgresSQL that will be a >> while so I do need a solution that leaves those layers alone really. > > Sorry, I did not mean to exclude Oracle from the final scripts, just to check > if another