Last active
March 19, 2019 22:40
-
-
Save ceholden/84b9cd7734d5c87c8e1c7345ed332a9b to your computer and use it in GitHub Desktop.
QGIS Python API issue test Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPT=./test_qgis.py | |
echo "Turning off error checking ('set +e')" | |
set +e | |
echo "Trying to run '$SCRIPT'" | |
python $SCRIPT | |
echo "Hey we made it despite segfault..." | |
echo "------------------------------" | |
echo "Turning on error checking ('set -e')" | |
set -e | |
echo "Trying to run '$SCRIPT' -- see you on other side?" | |
python $SCRIPT | |
echo "You won't see this..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys | |
HERE = os.path.dirname(os.path.abspath(__file__)) | |
f = os.path.join(HERE, 'ne_110m_land.geojson') | |
def test(): | |
from qgis.core import QgsApplication, QgsProcessingFeedback, QgsVectorLayer | |
app = QgsApplication([], False) | |
app.initQgis() | |
vl = QgsVectorLayer(f) | |
valid = vl.isValid() | |
print('Valid?', valid) | |
if not valid: | |
print('Could not even validate the vector file... ' | |
'you have bigger problems') | |
sys.exit(1) | |
else: | |
print('Feature count?', vl.featureCount()) | |
app.exitQgis() | |
print('Ran `app.exitQgis()`') | |
app.exit() | |
print('Ran `app.exit()`') | |
if __name__ == '__main__': | |
test() | |
print('Will be done if it does not segfault') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment