Skip to content

Commit 37dd46c

Browse files
committed
feat: load graphene using pip in venv
1 parent f3bc085 commit 37dd46c

14 files changed

Lines changed: 27490 additions & 55 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55
docker/qgis_plugins/*
6+
plugin_code/shogun_qgis_venv/
67

78
# C extensions
89
*.so

docker/docker-compose-dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
services:
22
qgis:
33
image: qgis/qgis:3.44
4-
command: ["/bin/bash", "-c", "pip install debugpy; qgis /root/shogun_qgis_konfigurator.qgs"]
4+
command: ["/bin/bash", "-c", "qgis /root/shogun_qgis_konfigurator.qgs"]
55
environment:
66
DISPLAY: "unix${DISPLAY}"
77
RUN_IN_DOCKER: "1"
8+
IS_DEV: "true"
89
ports:
910
- "5678:5678"
1011
volumes:

plugin_code/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
This script initializes the plugin, making it known to QGIS.
2323
"""
2424

25+
from qgis.core import QgsMessageLog
26+
2527

2628
# noinspection PyPep8Naming
2729
def classFactory(iface): # pylint: disable=invalid-name
@@ -31,5 +33,19 @@ def classFactory(iface): # pylint: disable=invalid-name
3133
:type iface: QgsInterface
3234
"""
3335
#
36+
import os
37+
from .plugin_utils.installer import ensure_venv, SHOGUN_VENV_NAME, ensure_dependencies
3438
from .qgis_shogun_editor import QgisShogunEditor
39+
40+
project_path = os.path.dirname(__file__)
41+
QgsMessageLog.logMessage(f"Project path: {project_path}", "QgisShogunEditor")
42+
43+
venv_path = ensure_venv(
44+
os.path.join(
45+
project_path,
46+
SHOGUN_VENV_NAME
47+
)
48+
)
49+
ensure_dependencies(venv_path)
50+
3551
return QgisShogunEditor(iface)

plugin_code/graphene_util.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
/***************************************************************************
4+
QgisShogunEditor
5+
-------------------
6+
begin : 2025-09
7+
git sha : $Format:%H$
8+
copyright : (C) 2025 by terrestris
9+
email : info@terrestris.de
10+
***************************************************************************/
11+
12+
/***************************************************************************
13+
* *
14+
* This program is free software; you can redistribute it and/or modify *
15+
* it under the terms of the GNU General Public License as published by *
16+
* the Free Software Foundation; either version 2 of the License, or *
17+
* (at your option) any later version. *
18+
* *
19+
***************************************************************************/
20+
"""
21+
import graphene
22+
import requests
23+
24+
25+
class ApplicationType(graphene.ObjectType):
26+
id = graphene.ID()
27+
name = graphene.String()
28+
description = graphene.String()
29+
layerTree = graphene.JSONString()
30+
31+
class Query(graphene.ObjectType):
32+
applications = graphene.List(ApplicationType)
33+
34+
def resolve_applications(self, info):
35+
# You may want to parameterize the endpoint URL, here it's hardcoded for demo purposes
36+
shogun_url = info.context.get('shogun_url', '')
37+
if not shogun_url:
38+
return []
39+
40+
# Build the applications URL (same logic as check_url_for_applications)
41+
if shogun_url.endswith('applications'):
42+
applications_url = shogun_url
43+
elif shogun_url.endswith('application'):
44+
applications_url = shogun_url + 's'
45+
elif shogun_url.endswith('/'):
46+
applications_url = shogun_url + 'applications'
47+
else:
48+
applications_url = shogun_url + '/applications'
49+
50+
# Use requests to fetch (or replace with QGIS networking if needed)
51+
try:
52+
response = requests.get(applications_url, verify=False) # TODO: ssl verification handling
53+
if response.status_code == 200:
54+
applications_json = response.json()
55+
content = applications_json.get('content', [])
56+
return [
57+
ApplicationType(
58+
id=app.get('id'),
59+
name=app.get('name'),
60+
description=app.get('description'),
61+
layerTree=app.get('layerTree')
62+
)
63+
for app in content
64+
]
65+
except Exception as e:
66+
print(f"Error fetching applications: {e}")
67+
return []
68+
69+
schema = graphene.Schema(query=Query)

plugin_code/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tags=python
2727

2828
homepage=http://homepage
2929
category=Plugins
30-
icon=icon.png
30+
icon=shogun_logo.png
3131
# experimental flag
3232
experimental=True
3333

plugin_code/plugin_utils/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)