From 776df65917b9936cdc5097d668b2948f3e9a0ce0 Mon Sep 17 00:00:00 2001 From: Boney Bun Date: Tue, 10 Oct 2017 15:26:02 +0700 Subject: [PATCH 1/2] update pavement.py from upstream (#353) merge pavement from upstream into existing code fix #352 --- pavement.py | 144 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 113 insertions(+), 31 deletions(-) diff --git a/pavement.py b/pavement.py index 9c8f2b8dcbc..ee633dc53ab 100644 --- a/pavement.py +++ b/pavement.py @@ -39,7 +39,7 @@ try: from geonode.settings import GEONODE_APPS -except: +except BaseException: # probably trying to run install_win_deps. pass @@ -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() @@ -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 @@ -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) @@ -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") @@ -295,6 +356,8 @@ def start(): """ Start GeoNode (Django, GeoServer & Client) """ + call_task('start_messaging') + info("GeoNode is now available.") @@ -304,6 +367,7 @@ def stop_django(): Stop the GeoNode Django application """ kill('python', 'runserver') + kill('python', 'runmessaging') @task @@ -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() @@ -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') @@ -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() @@ -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." @@ -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: @@ -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' @@ -462,6 +541,7 @@ def test(options): if not success: sys.exit(1) + @task def test_javascript(options): with pushd('geonode/static/geonode'): @@ -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 @@ -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 @@ -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)) @@ -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) @@ -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 From 70d64ff3b9a3ece0cb0e9bde8964ad846e68b6e2 Mon Sep 17 00:00:00 2001 From: Boney Bun Date: Tue, 10 Oct 2017 16:05:35 +0700 Subject: [PATCH 2/2] fix data tab (#351) fix #348 --- geonode/layers/templates/layers/layer_detail.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geonode/layers/templates/layers/layer_detail.html b/geonode/layers/templates/layers/layer_detail.html index dde4f114809..e56aa86ae93 100644 --- a/geonode/layers/templates/layers/layer_detail.html +++ b/geonode/layers/templates/layers/layer_detail.html @@ -287,7 +287,12 @@ {% endif %} {% if links_download %} + {% if not links %} + {# if links doesn't exist, make this tab active by default #} +
+ {% else %}
+ {% endif %}
    • {% for link in links_download %}