[QGIS-Developer] Bug with python macro on project load

Mario Baranzini mario at opengis.ch
Thu Aug 15 00:21:23 PDT 2019


Bo's code works as expected, but even for me the traceback fails if there
are errors.

[image: image.png]

On Wed, 14 Aug 2019 at 22:13, Tim Sutton <tim at kartoza.com> wrote:

> Thanks Bo! @Mario can you confirm which behaviour you replicated? The
> exception when calling traceback.print_exception() failed
> or my dodgy code simply failing with a nice exception message as Bo
> demonstrated (which is expected behaviour).
>
> Regards
>
> Tim
>
>
> On 14 Aug 2019, at 20:25, Bo Victor Thomsen <bo.victor.thomsen at gmail.com>
> wrote:
>
> Hi Tim !  (Greetings from Denmark :-)
>
> On Windows 8.1 64 bit and QGIS 3.8.1 64 bit:
>
> I've modified your python code a little bit:
> from qgis.core import QgsProject
> from qgis.utils import iface
>
> def openProject():
>     layers = QgsProject.instance().mapLayersByName('kommune')
>     layer = layers[0]
>     iface.showAttributeTable(layer)
>
>
> def saveProject():
>     pass
>
> def closeProject():
>     pass
>
> It works after enabling macro's. (You'll have to change the layer name
> back to your original layer name)
>
> --
> Med venlig hilsen / Kind regards
>
> Bo Victor Thomsen
>
>
>
> Den 14-08-2019 kl. 17:21 skrev Tim Sutton:
>
> Hi
>
> Oh thanks for the feedback!
>
> Regards
>
> Tim
>
> On 14 Aug 2019, at 13:27, Mario Baranzini <mario at opengis.ch> wrote:
>
> Hi Tim,
> I have exactly the same error with QGIS 3.8.0 on Archlinux.
>
> Cheers
>
> On Wed, 14 Aug 2019 at 10:13, Tim Sutton <tim at kartoza.com> wrote:
>
>> Hi All
>>
>> I am running into a bug on macOS using QGIS 3.8 using the project load
>> python hook [1] and was curious:
>>
>> 1) Can anybody replicate this on other operating systems
>> 2) Does the macro run *after* layers have been loaded in the project or
>> before?  Former seems more logical to me but you should never assume to
>> much eh? :-)
>>
>> Thanks
>>
>> Tim
>>
>>
>>
>> [1] https://github.com/qgis/QGIS/issues/31235
>>>>
>>
>> <KartozaNewLogoThumbnail.jpg>
>>
>>
>>
>>
>>
>>
>> *Tim Sutton*
>>
>> *Co-founder:* Kartoza
>> *Ex Project chair:* QGIS.org <http://qgis.org/>
>>
>> Visit http://kartoza.com to find out about open source:
>>
>> Desktop GIS programming services
>> Geospatial web development
>> GIS Training
>> Consulting Services
>>
>> *Skype*: timlinux
>> *IRC:* timlinux on #qgis at freenode.net
>>
>> I'd love to connect. Here's my calendar link
>> <https://calendly.com/timlinux> to make finding time easy.
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> --
> Mario Baranzini
> mario at opengis.ch
> +41 (0)78 733 01 59 <+41787330159>
> [image: http://www.opengis.ch] <http://www.opengis.ch/>
>
>
>>
>
> <KartozaNewLogoThumbnail.jpg>
>
>
>
>
>
>
> *Tim Sutton*
>
> *Co-founder:* Kartoza
> *Ex Project chair:* QGIS.org <http://qgis.org/>
>
> Visit http://kartoza.com to find out about open source:
>
> Desktop GIS programming services
> Geospatial web development
> GIS Training
> Consulting Services
>
> *Skype*: timlinux
> *IRC:* timlinux on #qgis at freenode.net
>
> I'd love to connect. Here's my calendar link
> <https://calendly.com/timlinux> to make finding time easy.
>
>
> _______________________________________________
> QGIS-Developer mailing listQGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>>
>
>
>
>
>
>
>
> *Tim Sutton*
>
> *Co-founder:* Kartoza
> *Ex Project chair:* QGIS.org
>
> Visit http://kartoza.com to find out about open source:
>
> Desktop GIS programming services
> Geospatial web development
> GIS Training
> Consulting Services
>
> *Skype*: timlinux
> *IRC:* timlinux on #qgis at freenode.net
>
> I'd love to connect. Here's my calendar link
> <https://calendly.com/timlinux> to make finding time easy.
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Mario Baranzini
mario at opengis.ch
+41 (0)78 733 01 59 <+41787330159>
[image: http://www.opengis.ch] <http://www.opengis.ch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190815/54408c02/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190815/54408c02/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 19373 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190815/54408c02/attachment-0001.png>


More information about the QGIS-Developer mailing list