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 @@
.idea/
.idea/*
deploy/
deploy/*
temp/
example/*.aux.xml
......
......@@ -81,43 +81,56 @@ if __name__ == "__main__":
#the directory to build the "enmapboxplugin" folder
DIR_DEPLOY = jp(DIR_REPO, 'deploy')
#DIR_DEPLOY = r'E:\_EnMAP\temp\temp_bj\enmapbox_deploys\most_recent_version'
#local pb_tool configuration file.
pathCfg = jp(DIR_REPO, 'pb_tool.cfg')
mkDir(DIR_DEPLOY)
#required to choose andy DIR_DEPLOY of choice
#issue tracker: https://github.com/g-sherman/plugin_build_tool/issues/4
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:
import subprocess
import make
#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:
import subprocess
import make
os.chdir(DIR_REPO)
subprocess.call(['pb_tool', 'compile'])
make.compile_rc_files(DIR_REPO)
os.chdir(DIR_REPO)
subprocess.call(['pb_tool', 'compile'])
make.compile_rc_files(DIR_REPO)
else:
cfgParser = pb_tool.get_config(config=pathCfg)
pb_tool.compile_files(cfgParser)
else:
cfgParser = pb_tool.get_config(config=pathCfg)
pb_tool.compile_files(cfgParser)
#3. Deploy = write the data to the new enmapboxplugin folder
pb_tool.deploy_files(pathCfg, confirm=False)
#3. Deploy = write the data to the new enmapboxplugin folder
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,
# we need to remove them afterwards.
# issue: https://github.com/g-sherman/plugin_build_tool/issues/5
print('Remove files...')
for f in file_search(jp(DIR_DEPLOY, 'enmapboxplugin'), re.compile('(svg|pyc)$'), recursive=True):
os.remove(f)
#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.
# issue: https://github.com/g-sherman/plugin_build_tool/issues/5
print('Remove files...')
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')
......@@ -12,7 +12,7 @@ icon=timeseriesviewer/ui/icons/icon.png
homepage=bitbucket.org/jakimowb/hub-timeseriesviewer
tracker=bitbucket.org/jakimowb/hub-timeseriesviewer/issues
repository=bitbucket.org/jakimowb/hub-timeseriesviewer
experimental=True
experimental=False
deprecated=False
# Tags are comma separated with spaces allowed
......
......@@ -8,7 +8,7 @@
[plugin]
# Name of the plugin. This is the name of the directory that will
# be created in C:/.qgis2/python/plugins
name: timeseriesviewer
name: timeseriesviewerplugin
[files]
# Python files that should be deployed with the plugin
......@@ -43,6 +43,7 @@ extras:
extra_dirs:
timeseriesviewer
site-packages
example
# ISO code(s) for any locales (translations), separated by spaces.
# Corresponding .ts files must exist in the i18n directory
......
......@@ -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).
"""
import os, sys, fnmatch, site
import os, sys, fnmatch, site, re
import six, logging
from qgis.core import *
from qgis.gui import *
......@@ -111,25 +111,32 @@ def icon():
def file_search(rootdir, wildcard, recursive=False, ignoreCase=False):
assert rootdir is not None
if not os.path.isdir(rootdir):
six.print_("Path is not a directory:{}".format(rootdir), file=sys.stderr)
def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
regType = type(re.compile('.*'))
results = []
for root, dirs, files in os.walk(rootdir):
for file in files:
if (ignoreCase and fnmatch.fnmatch(file.lower(), wildcard.lower())) \
or fnmatch.fnmatch(file, wildcard):
results.append(os.path.join(root, file))
if isinstance(pattern, regType):
if pattern.search(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:
break
pass
return results
def getFileAndAttributes(file):
"""
splits a GDAL valid file path into
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -671,6 +671,33 @@ def loadUIFormClass(pathUi, from_imports=False, resourceSuffix=''):
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):
"""
Initializes the QGIS Environment
......
......@@ -36,8 +36,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
DIR_REPO = os.path.normpath(os.path.split(inspect.getfile(inspect.currentframe()))[0])
DIR_SITE_PACKAGES = None
class TimeSeriesViewerPlugin:
def __init__(self, iface):
......@@ -50,14 +49,11 @@ class TimeSeriesViewerPlugin:
def initGui(self):
self.toolbarActions = []
syspaths = [os.path.normpath(p) for p in sys.path]
if DIR_REPO not in syspaths: sys.path.append(DIR_REPO)
#import timeseriesviewer.ui.resources_py2
#timeseriesviewer.ui.resources_py2.qInitResources()
# add platform independent site-packages
if DIR_SITE_PACKAGES:
site.addsitedir(DIR_SITE_PACKAGES)
dir_repo = os.path.dirname(__file__)
site.addsitedir(dir_repo)
site.addsitedir(os.path.join(dir_repo, 'site-packages'))
import timeseriesviewer
# 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