0

Following on from a question I asked about getting the version information from python-qgis, with a brilliant solution provided by @falsetru, I am running into a problem whereby importing qgis.utils seems to hide all exceptions. Running the following code in the interpreter, I get no traceback, or anything useful following a raised exception, see below.

>>> import qgis.utils
>>> qgis.utils.QGis.QGIS_VERSION
'2.4.0-Chugiak'
>>> raise Exception('boof!')
>>>

Could someone tell me how I can turn back on traceback after importing qgis-utils or another way of getting the version information from python-qgis without needing to import utils?

Many thanks!

Community
  • 1
  • 1
Mike
  • 439
  • 1
  • 6
  • 13
  • 1
    Did you try `traceback` module? if not import traceback and use functions like `traceback.print_exc` or ... . – hamidfzm Oct 21 '14 at 11:22
  • I don't have much experience with the `traceback` module I'm afraid. I tried running `traceback.print_exc()` as you suggested, but with no success. I will read up on that module. I have also noticed the warnings module. Could it also be related to this? – Mike Oct 21 '14 at 11:29
  • Possibly yes. maybe the module you imported filtered warnings use `warnings` module. – hamidfzm Oct 21 '14 at 11:44
  • It looks like I can use `qgis.core.QGis.QGIS_VERSION` to get the version info, so I didn't need to use `utils` after all. It is however, still a problem, and one I will continue to look into. – Mike Oct 21 '14 at 11:51

1 Answers1

0

I have found a solution, which allows me to avoid using the utils module to get the version information, and uses the core module instead.

>>> import qgis.core
>>> qgis.core.Qgis.QGIS_VERSION
'2.4.0-Chugiak'
>>> raise Exception('boof!')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Exception: boof!

This doesn't provide a full answer to my question, but does provide a work-around to get the version information for python-qgis.

Mike
  • 439
  • 1
  • 6
  • 13