Skip to content

Commit

Permalink
Merge pull request #9 from Riverscapes/dev
Browse files Browse the repository at this point in the history
Version 0.2.0
  • Loading branch information
MattReimer authored May 5, 2021
2 parents f17c4e2 + 4f03548 commit b4d6e0e
Show file tree
Hide file tree
Showing 20 changed files with 1,458 additions and 1,209 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 0.2.0 ***(May 4, 2021)***

### Bug Fixes

* [Respect the "collapsed" attribute in the business logic](https://github.com/Riverscapes/QRAVEPlugin/issues/8)
* [Metadata.txt version not updating on plugin build.](https://github.com/Riverscapes/QRAVEPlugin/issues/7)
* [Acknowledgements Not Updating](https://github.com/Riverscapes/QRAVEPlugin/issues/6)
* [Toolbar Icons Disabled upon first install](https://github.com/Riverscapes/QRAVEPlugin/issues/5)
* [Symbology qml not loading correctly](https://github.com/Riverscapes/QRAVEPlugin/issues/4)
* [Multiple projects open at once](https://github.com/Riverscapes/QRAVEPlugin/issues/3)
* [Support transparency attribute](https://github.com/Riverscapes/QRAVEPlugin/issues/2)


## 0.0.1

First version. Everything is new.
13 changes: 13 additions & 0 deletions CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Deployment Checklist

There are a number of steps that have to be performed in the correct order for this plugin to deploy correctly.

NEVER WORK DIRECTLY ON THE MASTER BRANCH

1. Commit and push everything to git
2. increment the version number in `__version__.py`
3. Do a compile of all the UI and resources and commit that `pb_tool compile`
4. Run the `deploy.py` script once and test the local version of the plugin
5. Do a code review and a pull request to get this onto the master branch
6. Tag the commit in git with the version number
7. Run `deploy.py` again. This will produce the zip file to upload
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.1"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"basemapsInclude": true,
"lastDigestSync": null,
"lastResourceSync": null,
"lastBrowsePath": null,
"basemapRegion": "United States"
},
"constants": {
"logCategory": "QRAVE",
"settingsCategory": "QRAVE",
"project_filepath": "qrave_project_path",
"businessLogicDir": "blXML",
"symbologyDir": "symbology",
"digestSyncFreqHours": 24,
Expand Down
4 changes: 2 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name=Riverscapes Plugin (QRAVE) DEV_COPY
qgisMinimumVersion=3.0
description=Explore symbolized Riverscapes projects
version=0.1
version=0.0.0dev
author=North Arrow Research
[email protected]

Expand All @@ -20,7 +20,7 @@ repository=https://github.com/Riverscapes/QRAVEPlugin

hasProcessingProvider=no
# Uncomment the following line and add your changelog:
# changelog=
changelog=https://github.com/Riverscapes/QRAVEPlugin/blob/master/CHANGELOG.md

# Tags are comma separated with spaces allowed
tags=python,riverscapes,rave
Expand Down
11 changes: 7 additions & 4 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import zipfile


PLUGIN_NAME = "qrave_toolbar"
UI_DIR = "src/ui"

Expand Down Expand Up @@ -52,14 +53,16 @@ def copy_plugin():
return deployfolder


def move_meta(deployfolder):
def move_meta(deployfolder, version):
# Metadata must be handled separately
src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'metadata.txt'))
dst = os.path.abspath(os.path.join(deployfolder, 'metadata.txt'))

with open(src, 'r', encoding="utf8") as f, open(dst, 'w+', encoding="utf8") as wf:
text = f.read()
wf.write(text.replace(' DEV_COPY', ''))
text = text.replace(' DEV_COPY', '')
text = text.replace('version=0.0.0dev', 'version={}'.format(version))
wf.write(text)


def zip_plugin(deployfolder: str):
Expand Down Expand Up @@ -96,7 +99,7 @@ def yesno(msg):

deployfolder = copy_plugin()

move_meta(deployfolder)
move_meta(deployfolder, version)
zip_plugin(deployfolder)

# deploy_plugin()
deploy_plugin()
1 change: 1 addition & 0 deletions src/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, parent=None):
"""Constructor."""
QDialog.__init__(self, parent)
self.setupUi(self)

pixmap = QPixmap(':/plugins/qrave_toolbar/RaveAddIn.png').scaled(128, 128)
self.logo.setPixmap(pixmap)
self.website.setText('<a href="{0}">{0}</a>'.format(CONSTANTS['webUrl']))
Expand Down
32 changes: 18 additions & 14 deletions src/classes/basemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import lxml.etree
from .borg import Borg

from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem, QIcon
from qgis.PyQt.QtGui import QStandardItem, QIcon
from qgis.PyQt.QtCore import Qt
from qgis.core import QgsTask, QgsApplication, Qgis

from .qrave_map_layer import QRaveMapLayer, QRaveTreeTypes
from .qrave_map_layer import QRaveMapLayer, QRaveTreeTypes, ProjectTreeData
from .settings import CONSTANTS, Settings
from .util import md5, requestFetch

Expand Down Expand Up @@ -66,7 +66,9 @@ def parse_layer(self, root_el, parent: QStandardItem):

try:
title = root_el.find('Title').text
name = root_el.find('Name').text
name_fnd = root_el.find('Name')
name = name_fnd.text if name_fnd is not None else title

srs = root_el.find('SRS').text.split(' ')[0]
lyr_format = root_el.find('Style/LegendURL/Format').text

Expand All @@ -82,7 +84,12 @@ def parse_layer(self, root_el, parent: QStandardItem):
"lyr_format": lyr_format
}
lyr_item.setData(
QRaveMapLayer(title, QRaveMapLayer.LayerTypes.WMS, urlWithParams, extra_meta), Qt.UserRole)
ProjectTreeData(
QRaveTreeTypes.LEAF,
None,
QRaveMapLayer(title, QRaveMapLayer.LayerTypes.WMS, urlWithParams, extra_meta)
),
Qt.UserRole)
lyr_item.setToolTip(wrap_by_word(abstract, 20))

except AttributeError as e:
Expand All @@ -93,7 +100,7 @@ def parse_layer(self, root_el, parent: QStandardItem):
Qgis.Warning
)
lyr_item = QStandardItem(QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), root_el.find('Title').text)
lyr_item.setData({'type': QRaveTreeTypes.BASEMAP_SUB_FOLDER}, Qt.UserRole),
lyr_item.setData(ProjectTreeData(QRaveTreeTypes.BASEMAP_SUB_FOLDER), Qt.UserRole),

parent.appendRow(lyr_item)

Expand All @@ -120,10 +127,6 @@ def __init__(self):
if 'regions' not in self.__dict__:
self.regions = {}

def load_capabilities(self):
# https://hydro.nationalmap.gov/arcgis/services/wbd/MapServer/WmsServer?service=wms&request=GetCapabilities&version=1.0.0
print('load_capabilities')

def load(self):
"""
Parse the XML and return any basemaps you find
Expand All @@ -138,12 +141,12 @@ def load(self):
try:
for region in lxml.etree.parse(BASEMAPS_XML_PATH).getroot().findall('Region'):
q_region = QStandardItem(QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), 'Basemaps')
q_region.setData({'type': QRaveTreeTypes.BASEMAP_ROOT}, Qt.UserRole),
q_region.setData(ProjectTreeData(QRaveTreeTypes.BASEMAP_ROOT), Qt.UserRole),
self.regions[region.attrib['name']] = q_region

for group_layer in region.findall('GroupLayer'):
q_group_layer = QStandardItem(QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), group_layer.attrib['name'])
q_group_layer.setData({'type': QRaveTreeTypes.BASEMAP_SUPER_FOLDER}, Qt.UserRole),
q_group_layer.setData(ProjectTreeData(QRaveTreeTypes.BASEMAP_SUPER_FOLDER), Qt.UserRole),
q_region.appendRow(q_group_layer)

for layer in group_layer.findall('Layer'):
Expand All @@ -153,12 +156,13 @@ def load(self):

meta = {meta.attrib['name']: meta.text for meta in layer.findall('Metadata/Meta')}
# We set the data to be Basemaps to help us load this stuff later
q_layer.setData(QRaveBaseMap(q_layer, layer_url, meta), Qt.UserRole)
q_layer.setData(ProjectTreeData(QRaveTreeTypes.LEAF, None, QRaveBaseMap(q_layer, layer_url, meta)), Qt.UserRole)

q_group_layer.appendRow(q_layer)
except Exception as e:
self.settings.msg_bar("Error loading basemaps", "Exception: {}".format(e),
Qgis.Critical)
settings = Settings()
settings.msg_bar("Error loading basemaps", "Exception: {}".format(e),
Qgis.Critical)


def wrap_by_word(s, n):
Expand Down
9 changes: 7 additions & 2 deletions src/classes/context_menu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qgis.PyQt.QtWidgets import QDockWidget, QWidget, QTreeView, QVBoxLayout, QMenu, QAction
from qgis.PyQt.QtCore import pyqtSlot
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import pyqtSlot, QModelIndex
from qgis.PyQt.QtGui import QIcon, QStandardItem


class ContextMenu(QMenu):
Expand All @@ -25,6 +25,10 @@ class ContextMenu(QMenu):
'Browse Project Folder',
':/plugins/qrave_toolbar/BrowseFolder.png'
),
'OPEN_FILE': (
'Open File',
':/plugins/qrave_toolbar/RaveAddIn_16px.png'
),
'BROWSE_FOLDER': (
'Browse Folder',
':/plugins/qrave_toolbar/BrowseFolder.png'
Expand Down Expand Up @@ -60,6 +64,7 @@ class ContextMenu(QMenu):
}

# def __init__(self):
# self.menu = ContextMenu()
# super().__init__(self)

def addAction(self, lookup: str, slot: pyqtSlot = None, enabled=True):
Expand Down
40 changes: 31 additions & 9 deletions src/classes/net_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import json
import pdb
from glob import glob
from time import time, sleep
from qgis.core import QgsTask, QgsMessageLog, Qgis

Expand All @@ -25,10 +26,10 @@ def __init__(self, description):
self.progress = 0
self.downloaded = 0

self.resource_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'resources')
self.business_logic_xml_dir = os.path.join(self.resource_dir, CONSTANTS['businessLogicDir'])
self.symbology_dir = os.path.join(self.resource_dir, CONSTANTS['symbologyDir'])
self.digest_path = os.path.join(self.resource_dir, 'index.json')
self.resource_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
self.business_logic_xml_dir = os.path.abspath(os.path.join(self.resource_dir, CONSTANTS['businessLogicDir']))
self.symbology_dir = os.path.abspath(os.path.join(self.resource_dir, CONSTANTS['symbologyDir']))
self.digest_path = os.path.abspath(os.path.join(self.resource_dir, 'index.json'))

self.initialized = False # self.initialize sets this
self.need_sync = True # self.initialize sets this
Expand Down Expand Up @@ -123,12 +124,21 @@ def _syncFiles(self):
self.progress = 0
self.downloaded = 0

all_local_files = [os.path.abspath(x) for x in glob(os.path.join(self.resource_dir, '**', '*.?ml'), recursive=True)]

# Symbologies have directory structure
for remote_path, remote_md5 in symbologies.items():
local_path = os.path.join(self.symbology_dir, os.path.basename(remote_path))
local_path = os.path.abspath(os.path.join(self.symbology_dir, *remote_path.replace('Symbology/qgis/', '').split('/')))

# There might be subdirs to make here
os.makedirs(os.path.dirname(local_path), exist_ok=True)

if not os.path.isfile(local_path) or remote_md5 != md5(local_path):
requestDownload(CONSTANTS['resourcesUrl'] + remote_path, local_path, remote_md5)
QgsMessageLog.logMessage("Symobology downloaded: {}".format(local_path), MESSAGE_CATEGORY, level=Qgis.Info)

self.downloaded += 1
all_local_files = [x for x in all_local_files if x != local_path]
self.progress += 1
self.setProgress(self.progress)

Expand All @@ -137,7 +147,9 @@ def _syncFiles(self):
if not os.path.isfile(local_path) or remote_md5 != md5(local_path):
requestDownload(CONSTANTS['resourcesUrl'] + remote_path, local_path, remote_md5)
QgsMessageLog.logMessage("BusinessLogic downloaded: {}".format(local_path), MESSAGE_CATEGORY, level=Qgis.Info)

self.downloaded += 1
all_local_files = [x for x in all_local_files if x != local_path]
self.progress += 1
self.setProgress(self.progress)

Expand All @@ -147,12 +159,22 @@ def _syncFiles(self):
if not os.path.isfile(local_path) or remote_md5 != md5(local_path):
requestDownload(CONSTANTS['resourcesUrl'] + remote_path, local_path, remote_md5)
QgsMessageLog.logMessage("Basemaps downloaded: {}".format(local_path), 'QRAVE', level=Qgis.Info)

self.downloaded += 1
all_local_files = [x for x in all_local_files if x != local_path]
self.progress += 1
self.setProgress(self.progress)

# Now we clean up any files that aren't supposed to be there
for dfile in all_local_files:
try:
# Do a quick (probably redundant check) to make sure this file is in our current folder
rel_check = os.path.relpath(dfile, os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
if len(os.path.split(rel_check)) < 3:
os.remove(dfile)
QgsMessageLog.logMessage("Extraneous file removed: {}".format(dfile), 'QRAVE', level=Qgis.Warning)
else:
QgsMessageLog.logMessage("Can't remove file because it's in the wrong place: {}".format(dfile), 'QRAVE', level=Qgis.Critical)
except Exception as e:
QgsMessageLog.logMessage("Error deleting file: {}".format(dfile), 'QRAVE', level=Qgis.Critical)
self.setProgress(100)
# if downloaded == 0:
# self.set_label('No symbology or xml updates needed. 0 files downloaded')
# else:
# self.set_label('Downloaded and updated {}/{} symbology or xml files'.format(downloaded, total))
Loading

0 comments on commit b4d6e0e

Please sign in to comment.