Skip to content
Snippets Groups Projects
Commit 51add3cb authored by benjamin.jakimow@geo.hu-berlin.de's avatar benjamin.jakimow@geo.hu-berlin.de
Browse files

Merge branch 'develop' of https://bitbucket.org/jakimowb/hub-timeseriesviewer into develop

parents 7344e038 19f874b7
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
.idea/ .idea/
.idea/* .idea/*
deploy/ deploy/
deploy/*
temp/ temp/
example/*.aux.xml example/*.aux.xml
......
...@@ -81,43 +81,56 @@ if __name__ == "__main__": ...@@ -81,43 +81,56 @@ if __name__ == "__main__":
#the directory to build the "enmapboxplugin" folder #the directory to build the "enmapboxplugin" folder
DIR_DEPLOY = jp(DIR_REPO, 'deploy') DIR_DEPLOY = jp(DIR_REPO, 'deploy')
#DIR_DEPLOY = r'E:\_EnMAP\temp\temp_bj\enmapbox_deploys\most_recent_version'
#local pb_tool configuration file. #local pb_tool configuration file.
pathCfg = jp(DIR_REPO, 'pb_tool.cfg') pathCfg = jp(DIR_REPO, 'pb_tool.cfg')
mkDir(DIR_DEPLOY) mkDir(DIR_DEPLOY)
#required to choose andy DIR_DEPLOY of choice #required to choose andy DIR_DEPLOY of choice
#issue tracker: https://github.com/g-sherman/plugin_build_tool/issues/4 #issue tracker: https://github.com/g-sherman/plugin_build_tool/issues/4
pb_tool.get_plugin_directory = lambda : DIR_DEPLOY pb_tool.get_plugin_directory = lambda : DIR_DEPLOY
cfg = pb_tool.get_config(config=pathCfg)
#1. clean an existing directory = the enmapboxplugin folder
pb_tool.clean_deployment(ask_first=False, config=pathCfg)
#2. Compile. Basically call pyrcc to create the resources.rc file
#I don't know how to call this from pure python
if True: if True:
import subprocess #1. clean an existing directory = the enmapboxplugin folder
import make pb_tool.clean_deployment(ask_first=False, config=pathCfg)
#2. Compile. Basically call pyrcc to create the resources.rc file
#I don't know how to call this from pure python
if True:
import subprocess
import make
os.chdir(DIR_REPO) os.chdir(DIR_REPO)
subprocess.call(['pb_tool', 'compile']) subprocess.call(['pb_tool', 'compile'])
make.compile_rc_files(DIR_REPO) make.compile_rc_files(DIR_REPO)
else: else:
cfgParser = pb_tool.get_config(config=pathCfg) cfgParser = pb_tool.get_config(config=pathCfg)
pb_tool.compile_files(cfgParser) pb_tool.compile_files(cfgParser)
#3. Deploy = write the data to the new enmapboxplugin folder #3. Deploy = write the data to the new enmapboxplugin folder
pb_tool.deploy_files(pathCfg, confirm=False) pb_tool.deploy_files(pathCfg, confirm=False)
#4. As long as we can not specify in the pb_tool.cfg which file types are not to deploy, #4. As long as we can not specify in the pb_tool.cfg which file types are not to deploy,
# we need to remove them afterwards. # we need to remove them afterwards.
# issue: https://github.com/g-sherman/plugin_build_tool/issues/5 # issue: https://github.com/g-sherman/plugin_build_tool/issues/5
print('Remove files...') print('Remove files...')
for f in file_search(jp(DIR_DEPLOY, 'enmapboxplugin'), re.compile('(svg|pyc)$'), recursive=True):
os.remove(f)
for f in file_search(DIR_DEPLOY, re.compile('(svg|pyc)$'), recursive=True):
os.remove(f)
#5. create a zip
print('Create zipfile...')
from timeseriesviewer.utils import zipdir
pluginname= cfg.get('plugin', 'name')
pathZip = jp(DIR_DEPLOY, '{}.{}.zip'.format(pluginname,timestamp))
dirPlugin = jp(DIR_DEPLOY, pluginname)
zipdir(dirPlugin, pathZip)
#os.chdir(dirPlugin)
#shutil.make_archive(pathZip, 'zip', '..', dirPlugin)
print('Finished') print('Finished')
...@@ -12,7 +12,7 @@ icon=timeseriesviewer/ui/icons/icon.png ...@@ -12,7 +12,7 @@ icon=timeseriesviewer/ui/icons/icon.png
homepage=bitbucket.org/jakimowb/hub-timeseriesviewer homepage=bitbucket.org/jakimowb/hub-timeseriesviewer
tracker=bitbucket.org/jakimowb/hub-timeseriesviewer/issues tracker=bitbucket.org/jakimowb/hub-timeseriesviewer/issues
repository=bitbucket.org/jakimowb/hub-timeseriesviewer repository=bitbucket.org/jakimowb/hub-timeseriesviewer
experimental=True experimental=False
deprecated=False deprecated=False
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
[plugin] [plugin]
# Name of the plugin. This is the name of the directory that will # Name of the plugin. This is the name of the directory that will
# be created in C:/.qgis2/python/plugins # be created in C:/.qgis2/python/plugins
name: timeseriesviewer name: timeseriesviewerplugin
[files] [files]
# Python files that should be deployed with the plugin # Python files that should be deployed with the plugin
...@@ -43,6 +43,7 @@ extras: ...@@ -43,6 +43,7 @@ extras:
extra_dirs: extra_dirs:
timeseriesviewer timeseriesviewer
site-packages site-packages
example
# ISO code(s) for any locales (translations), separated by spaces. # ISO code(s) for any locales (translations), separated by spaces.
# Corresponding .ts files must exist in the i18n directory # Corresponding .ts files must exist in the i18n directory
......
...@@ -30,7 +30,7 @@ ABOUT = """ ...@@ -30,7 +30,7 @@ ABOUT = """
The HUB TimeSeriesViewer is developed at Humboldt-Universität zu Berlin. Born in the SenseCarbon project, it was funded by the German Aerospace Centre (DLR) and granted by the Federal Ministry of Education and Research (BMBF, grant no. 50EE1254). Since 2017 it is developed under contract by the German Research Centre for Geosciences (GFZ) as part of the EnMAP Core Science Team activities (www.enmap.org), funded by DLR and granted by the Federal Ministry of Economic Affairs and Energy (BMWi, grant no. 50EE1529). The HUB TimeSeriesViewer is developed at Humboldt-Universität zu Berlin. Born in the SenseCarbon project, it was funded by the German Aerospace Centre (DLR) and granted by the Federal Ministry of Education and Research (BMBF, grant no. 50EE1254). Since 2017 it is developed under contract by the German Research Centre for Geosciences (GFZ) as part of the EnMAP Core Science Team activities (www.enmap.org), funded by DLR and granted by the Federal Ministry of Economic Affairs and Energy (BMWi, grant no. 50EE1529).
""" """
import os, sys, fnmatch, site import os, sys, fnmatch, site, re
import six, logging import six, logging
from qgis.core import * from qgis.core import *
from qgis.gui import * from qgis.gui import *
...@@ -111,25 +111,32 @@ def icon(): ...@@ -111,25 +111,32 @@ def icon():
def file_search(rootdir, wildcard, recursive=False, ignoreCase=False): def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
assert rootdir is not None assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
if not os.path.isdir(rootdir): regType = type(re.compile('.*'))
six.print_("Path is not a directory:{}".format(rootdir), file=sys.stderr)
results = [] results = []
for root, dirs, files in os.walk(rootdir): for root, dirs, files in os.walk(rootdir):
for file in files: for file in files:
if (ignoreCase and fnmatch.fnmatch(file.lower(), wildcard.lower())) \ if isinstance(pattern, regType):
or fnmatch.fnmatch(file, wildcard): if pattern.search(file):
results.append(os.path.join(root, file)) path = os.path.join(root, file)
results.append(path)
elif (ignoreCase and fnmatch.fnmatch(file.lower(), pattern.lower())) \
or fnmatch.fnmatch(file, pattern):
path = os.path.join(root, file)
results.append(path)
if not recursive: if not recursive:
break break
pass pass
return results return results
def getFileAndAttributes(file): def getFileAndAttributes(file):
""" """
splits a GDAL valid file path into splits a GDAL valid file path into
......
This diff is collapsed.
...@@ -671,6 +671,33 @@ def loadUIFormClass(pathUi, from_imports=False, resourceSuffix=''): ...@@ -671,6 +671,33 @@ def loadUIFormClass(pathUi, from_imports=False, resourceSuffix=''):
return FORM_CLASSES[pathUi] return FORM_CLASSES[pathUi]
def zipdir(pathDir, pathZip):
"""
:param pathDir: directory to compress
:param pathZip: path to new zipfile
"""
#thx to https://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory
"""
import zipfile
assert os.path.isdir(pathDir)
zipf = zipfile.ZipFile(pathZip, 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(pathDir):
for file in files:
zipf.write(os.path.join(root, file))
zipf.close()
"""
import zipfile
relroot = os.path.abspath(os.path.join(pathDir, os.pardir))
with zipfile.ZipFile(pathZip, "w", zipfile.ZIP_DEFLATED) as zip:
for root, dirs, files in os.walk(pathDir):
# add directory (needed for empty dirs)
zip.write(root, os.path.relpath(root, relroot))
for file in files:
filename = os.path.join(root, file)
if os.path.isfile(filename): # regular files only
arcname = os.path.join(os.path.relpath(root, relroot), file)
zip.write(filename, arcname)
def initQgisApplication(pythonPlugins=None, PATH_QGIS=None, qgisDebug=False): def initQgisApplication(pythonPlugins=None, PATH_QGIS=None, qgisDebug=False):
""" """
Initializes the QGIS Environment Initializes the QGIS Environment
......
...@@ -36,8 +36,7 @@ from PyQt4.QtCore import * ...@@ -36,8 +36,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
DIR_REPO = os.path.normpath(os.path.split(inspect.getfile(inspect.currentframe()))[0])
DIR_SITE_PACKAGES = None
class TimeSeriesViewerPlugin: class TimeSeriesViewerPlugin:
def __init__(self, iface): def __init__(self, iface):
...@@ -50,14 +49,11 @@ class TimeSeriesViewerPlugin: ...@@ -50,14 +49,11 @@ class TimeSeriesViewerPlugin:
def initGui(self): def initGui(self):
self.toolbarActions = [] self.toolbarActions = []
syspaths = [os.path.normpath(p) for p in sys.path]
if DIR_REPO not in syspaths: sys.path.append(DIR_REPO) dir_repo = os.path.dirname(__file__)
site.addsitedir(dir_repo)
#import timeseriesviewer.ui.resources_py2 site.addsitedir(os.path.join(dir_repo, 'site-packages'))
#timeseriesviewer.ui.resources_py2.qInitResources()
# add platform independent site-packages
if DIR_SITE_PACKAGES:
site.addsitedir(DIR_SITE_PACKAGES)
import timeseriesviewer import timeseriesviewer
# init main UI # init main UI
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment