Skip to content

Commit

Permalink
Merge branch 'master-qgis_server' into fix-default-set-thumbnail-and-…
Browse files Browse the repository at this point in the history
…remove-map-kartoza#207
  • Loading branch information
boney-bun authored Oct 10, 2017
2 parents c25239c + 70d64ff commit 47bb5d7
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 31 deletions.
5 changes: 5 additions & 0 deletions geonode/layers/templates/layers/layer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ <h4 class="modal-title" id="myModalLabel">{% trans "Download Layer" %}</h4>
</div>
{% endif %}
{% if links_download %}
{% if not links %}
{# if links doesn't exist, make this tab active by default #}
<div class="tab-pane active" id="download_tab2">
{% else %}
<div class="tab-pane" id="download_tab2">
{% endif %}
<li>
<ul>
{% for link in links_download %}
Expand Down
144 changes: 113 additions & 31 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

try:
from geonode.settings import GEONODE_APPS
except:
except BaseException:
# probably trying to run install_win_deps.
pass

Expand Down Expand Up @@ -89,11 +89,23 @@ def setup_geoserver(options):

geoserver_dir = path('geoserver')

geoserver_bin = download_dir / os.path.basename(dev_config['GEOSERVER_URL'])
jetty_runner = download_dir / os.path.basename(dev_config['JETTY_RUNNER_URL'])

grab(options.get('geoserver', dev_config['GEOSERVER_URL']), geoserver_bin, "geoserver binary")
grab(options.get('jetty', dev_config['JETTY_RUNNER_URL']), jetty_runner, "jetty runner")
geoserver_bin = download_dir / \
os.path.basename(dev_config['GEOSERVER_URL'])
jetty_runner = download_dir / \
os.path.basename(dev_config['JETTY_RUNNER_URL'])

grab(
options.get(
'geoserver',
dev_config['GEOSERVER_URL']),
geoserver_bin,
"geoserver binary")
grab(
options.get(
'jetty',
dev_config['JETTY_RUNNER_URL']),
jetty_runner,
"jetty runner")

if not geoserver_dir.exists():
geoserver_dir.makedirs()
Expand All @@ -117,13 +129,61 @@ def _install_data_dir():
original_data_dir = path('geoserver/geoserver/data')
justcopy(original_data_dir, target_data_dir)

config = path('geoserver/data/security/auth/geonodeAuthProvider/config.xml')
with open(config) as f:
xml = f.read()
m = re.search('baseUrl>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/" + xml[m.end(1):]
with open(config, 'w') as f:
f.write(xml)
try:
config = path(
'geoserver/data/security/auth/geonodeAuthProvider/config.xml')
with open(config) as f:
xml = f.read()
m = re.search('baseUrl>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/" + xml[m.end(1):]
with open(config, 'w') as f:
f.write(xml)
except Exception as e:
print(e)

try:
config = path(
'geoserver/data/global.xml')
with open(config) as f:
xml = f.read()
m = re.search('proxyBaseUrl>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8080/geoserver" + xml[m.end(1):]
with open(config, 'w') as f:
f.write(xml)
except Exception as e:
print(e)

try:
config = path(
'geoserver/data/security/filter/geonode-oauth2/config.xml')
with open(config) as f:
xml = f.read()
m = re.search('accessTokenUri>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/o/token/" + xml[m.end(1):]
m = re.search('userAuthorizationUri>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/o/authorize/" + xml[m.end(1):]
m = re.search('redirectUri>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8080/geoserver" + xml[m.end(1):]
m = re.search('checkTokenEndpointUrl>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/api/o/v4/tokeninfo/" + xml[m.end(1):]
m = re.search('logoutUri>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000/account/logout/" + xml[m.end(1):]
with open(config, 'w') as f:
f.write(xml)
except Exception as e:
print(e)

try:
config = path(
'geoserver/data/security/role/geonode REST role service/config.xml')
with open(config) as f:
xml = f.read()
m = re.search('baseUrl>([^<]+)', xml)
xml = xml[:m.start(1)] + "http://localhost:8000" + xml[m.end(1):]
with open(config, 'w') as f:
f.write(xml)
except Exception as e:
print(e)


@task
Expand Down Expand Up @@ -178,7 +238,7 @@ def win_install_deps(options):
grab_winfiles(url, tempfile, package)
try:
easy_install.main([tempfile])
except Exception, e:
except Exception as e:
failed = True
print "install failed with error: ", e
os.remove(tempfile)
Expand Down Expand Up @@ -214,6 +274,7 @@ def sync(options):
"""
Run the migrate and migrate management commands to create and migrate a DB
"""
sh("python manage.py makemigrations --noinput")
sh("python manage.py migrate --noinput")
sh("python manage.py loaddata sample_admin.json")
sh("python manage.py loaddata geonode/base/fixtures/default_oauth_apps.json")
Expand Down Expand Up @@ -295,6 +356,8 @@ def start():
"""
Start GeoNode (Django, GeoServer & Client)
"""
call_task('start_messaging')

info("GeoNode is now available.")


Expand All @@ -304,6 +367,7 @@ def stop_django():
Stop the GeoNode Django application
"""
kill('python', 'runserver')
kill('python', 'runmessaging')


@task
Expand All @@ -319,7 +383,8 @@ def stop():
"""
Stop GeoNode
"""
# windows needs to stop the geoserver first b/c we can't tell which python is running, so we kill everything
# windows needs to stop the geoserver first b/c we can't tell which python
# is running, so we kill everything
stop_geoserver()
info("Stopping GeoNode ...")
stop_django()
Expand All @@ -337,6 +402,14 @@ def start_django():
foreground = '' if options.get('foreground', False) else '&'
sh('python manage.py runserver %s %s' % (bind, foreground))

def start_messaging():
"""
Start the GeoNode messaging server
"""
foreground = '' if options.get('foreground', False) else '&'
sh('python manage.py runmessaging %s' % foreground)



@cmdopts([
('java_path=', 'j', 'Full path to java install for Windows')
Expand Down Expand Up @@ -364,8 +437,10 @@ def start_geoserver(options):
sys.exit(1)

download_dir = path('downloaded').abspath()
jetty_runner = download_dir / os.path.basename(dev_config['JETTY_RUNNER_URL'])
jetty_runner = download_dir / \
os.path.basename(dev_config['JETTY_RUNNER_URL'])
data_dir = path('geoserver/data').abspath()
geofence_dir = path('geoserver/data/geofence').abspath()
web_app = path('geoserver/geoserver').abspath()
log_file = path('geoserver/jetty.log').abspath()
config = path('scripts/misc/jetty-runner.xml').abspath()
Expand All @@ -376,11 +451,12 @@ def start_geoserver(options):
javapath = "java"
loggernullpath = os.devnull

# checking if our loggernullpath exists and if not, reset it to something manageable
# checking if our loggernullpath exists and if not, reset it to
# something manageable
if loggernullpath == "nul":
try:
open("../../downloaded/null.txt", 'w+').close()
except IOError, e:
except IOError as e:
print "Chances are that you have Geoserver currently running. You \
can either stop all servers with paver stop or start only \
the django application with paver start_django."
Expand All @@ -389,12 +465,13 @@ def start_geoserver(options):

try:
sh(('java -version'))
except:
except BaseException:
print "Java was not found in your path. Trying some other options: "
javapath_opt = None
if os.environ.get('JAVA_HOME', None):
print "Using the JAVA_HOME environment variable"
javapath_opt = os.path.join(os.path.abspath(os.environ['JAVA_HOME']), "bin", "java.exe")
javapath_opt = os.path.join(os.path.abspath(
os.environ['JAVA_HOME']), "bin", "java.exe")
elif options.get('java_path'):
javapath_opt = options.get('java_path')
else:
Expand All @@ -408,8 +485,10 @@ def start_geoserver(options):
sh((
'%(javapath)s -Xms512m -Xmx1024m -server -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m'
' -DGEOSERVER_DATA_DIR=%(data_dir)s'
# ' -Dgeofence.dir=%(geofence_dir)s'
# ' -Dgeofence-ovr=geofence-datasource-ovr.properties'
# workaround for JAI sealed jar issue and jetty classloader
' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true'
# ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true'
' -jar %(jetty_runner)s'
' --port %(jetty_port)i'
' --log %(log_file)s'
Expand Down Expand Up @@ -462,6 +541,7 @@ def test(options):
if not success:
sys.exit(1)


@task
def test_javascript(options):
with pushd('geonode/static/geonode'):
Expand All @@ -471,7 +551,7 @@ def test_javascript(options):
@task
@cmdopts([
('name=', 'n', 'Run specific tests.')
])
])
def test_integration(options):
"""
Run GeoNode's Integration test suite against the external apps
Expand All @@ -491,8 +571,8 @@ def test_integration(options):
sh('sleep 30')
call_task('setup_data')
sh(('python manage.py test %s'
' --noinput -v 3 --liveserver=0.0.0.0:8000' % name))
except BuildFailure, e:
' --noinput --liveserver=0.0.0.0:8000' % name))
except BuildFailure as e:
info('Tests failed! %s' % str(e))
else:
success = True
Expand Down Expand Up @@ -620,13 +700,13 @@ def deb(options):
sh('debuild -uc -us -A')
elif key is None and ppa is not None:
# A sources package, signed by daemon
sh('debuild -S')
sh('debuild -S')
elif key is not None and ppa is None:
# A signed installable package
sh('debuild -k%s -A' % key)
# A signed installable package
sh('debuild -k%s -A' % key)
elif key is not None and ppa is not None:
# A signed, source package
sh('debuild -k%s -S' % key)
# A signed, source package
sh('debuild -k%s -S' % key)

if ppa is not None:
sh('dput ppa:%s geonode_%s_source.changes' % (ppa, simple_version))
Expand Down Expand Up @@ -670,7 +750,7 @@ def versions():
if stage == 'final':
stage = 'thefinal'

if stage == 'alpha' and edition == 0:
if stage == 'unstable':
tail = '%s%s' % (branch, timestamp)
else:
tail = '%s%s' % (stage, edition)
Expand Down Expand Up @@ -703,7 +783,9 @@ def kill(arg1, arg2):
running = False
for line in lines:
# this kills all java.exe and python including self in windows
if ('%s' % arg2 in line) or (os.name == 'nt' and '%s' % arg1 in line):
if ('%s' %
arg2 in line) or (os.name == 'nt' and '%s' %
arg1 in line):
running = True

# Get pid
Expand Down

0 comments on commit 47bb5d7

Please sign in to comment.