def setup_static(options): with pushd('geonode/static'): sh('bower install') sh('bower-installer') with pushd('geonode/static/geonode'): sh('make') # HACK Remove this recursive symlink manually sh('rm geonode/static/.components/jquery-timeago/public')
def start_geoserver(options): download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(JETTY_RUNNER_URL) data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() config = path('scripts/jetty-runner.xml').abspath() with pushd(data_dir): sh(('java -Xmx512m -XX:MaxPermSize=1024m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --log %(log_file)s' ' %(config)s' ' > /dev/null &' % locals() )) info('Starting GeoServer on %s' % GEOSERVER_BASE_URL) # wait for GeoServer to start started = waitfor(GEOSERVER_BASE_URL) info('The logs are available at %s' % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(('GeoServer never started properly or timed out.' 'It may still be running in the background.')) sys.exit(1)
def deb(options): """ Creates debian packages. Example uses: paver deb paver deb -k 12345 paver deb -k 12345 -p geonode/testing """ key = options.get("key", None) ppa = options.get("ppa", None) version, simple_version = versions() info("Creating package for GeoNode version %s" % version) with pushd("package"): # Get rid of any uncommitted changes to debian/changelog info("Getting rid of any uncommitted changes in debian/changelog") sh("git checkout debian/changelog") # Workaround for git-dch bug # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594580 # path('.git').makedirs() # Link the parent git repository folder in to the current one # needed by git-dch sh("ln -s ../.git .git") # Install requirements # sh('sudo apt-get -y install debhelper devscripts git-buildpackage') sh( ( "git-dch --spawn-editor=snapshot --git-author --new-version=%s" " --id-length=6 --ignore-branch --release" % (simple_version) ) ) deb_changelog = path("debian") / "changelog" for line in fileinput.input([deb_changelog], inplace=True): print line.replace("urgency=low", "urgency=high"), ## Revert workaround for git-dhc bug sh("rm -rf .git") if key is None and ppa is None: # A local installable package sh("debuild -uc -us -A") elif key is None and ppa is not None: # A sources package, signed by daemon sh("debuild -S") elif key is not None and ppa is None: # 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) if ppa is not None: sh("dput ppa:%s geonode_%s_source.changes" % (ppa, simple_version))
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from geonode.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = "http://localhost:8080/geoserver/" if GEOSERVER_BASE_URL != url: print 'your GEOSERVER_BASE_URL does not match %s' % url sys.exit(1) download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(JETTY_RUNNER_URL) data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() config = path('scripts/misc/jetty-runner.xml').abspath() # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" loggernullpath = "/dev/null" try: sh(('java -version')) except: if not options.get('java_path', None): print "Paver cannot find java in the Windows Environment. Please provide the --java_path flag with your full path to java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" sys.exit(1) # if there are spaces javapath = 'START /B "" "' + options['java_path'] + '"' # cmd log file needs to exist in windows # using folder from .gitignore open("../../downloaded/null.txt", 'w+').close() loggernullpath = "../../downloaded/null.txt" sh(( '%(javapath)s -Xmx512m -XX:MaxPermSize=256m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' # workaround for JAI sealed jar issue and jetty classloader ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals() )) info('Starting GeoServer on %s' % url) # wait for GeoServer to start started = waitfor(url) info('The logs are available at %s' % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(('GeoServer never started properly or timed out.' 'It may still be running in the background.')) sys.exit(1)
def package(options): """ Creates a tarball to use for building the system elsewhere """ import tarfile import geonode version = geonode.get_version() # Use GeoNode's version for the package name. pkgname = 'GeoNode-%s-all' % version # Create the output directory. out_pkg = path(pkgname) out_pkg_tar = path("%s.tar.gz" % pkgname) # Create a distribution in zip format for the geonode python package. dist_dir = path('dist') dist_dir.rmtree() sh('python setup.py sdist --formats=zip') with pushd('package'): # Delete old tar files in that directory for f in glob.glob('GeoNode*.tar.gz'): old_package = path(f) if old_package != out_pkg_tar: old_package.remove() if out_pkg_tar.exists(): info('There is already a package for version %s' % version) return # Clean anything that is in the oupout package tree. out_pkg.rmtree() out_pkg.makedirs() support_folder = path('support') install_file = path('install.sh') # And copy the default files from the package folder. justcopy(support_folder, out_pkg / 'support') justcopy(install_file, out_pkg) geonode_dist = path('..') / 'dist' / 'GeoNode-%s.zip' % version justcopy(geonode_dist, out_pkg) # Create a tar file with all files in the output package folder. tar = tarfile.open(out_pkg_tar, "w:gz") for file in out_pkg.walkfiles(): tar.add(file) # Add the README with the license and important links to documentation. tar.add('README', arcname=('%s/README.rst' % out_pkg)) tar.close() # Remove all the files in the temporary output package directory. out_pkg.rmtree() # Report the info about the new package. info("%s created" % out_pkg_tar.abspath())
def build_2010(): """ Build HDF5 using Visual Studio 2010 """ check_zip() if not op.exists(ZIPDIR): with zipfile.ZipFile(ZIPFILE_NAME) as z: z.extractall('.') with pushd(ZIPDIR): build(2010)
def deb(options): """ Creates debian packages. Example uses: paver deb paver deb -k 12345 paver deb -k 12345 -p geonode/testing """ key = options.get('key', None) ppa = options.get('ppa', None) version, simple_version = versions() info('Creating package for GeoNode version %s' % version) # Get rid of any uncommitted changes to debian/changelog info('Getting rid of any uncommitted changes in debian/changelog') sh('git checkout package/debian/changelog') # Workaround for git-dch bug # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594580 sh('ln -s %s %s' % (os.path.realpath('.git'), os.path.realpath('package'))) with pushd('package'): # Install requirements # sh('sudo apt-get -y install debhelper devscripts git-buildpackage') sh(('git-dch --spawn-editor=snapshot --git-author --new-version=%s' ' --id-length=6 --ignore-branch --release' % (simple_version))) #In case you publish from Ubuntu Xenial (git-dch is removed from upstream) # use the following line instead: #sh(('gbp dch --spawn-editor=snapshot --git-author --new-version=%s' # ' --id-length=6 --ignore-branch --release' % (simple_version))) deb_changelog = path('debian') / 'changelog' for line in fileinput.input([deb_changelog], inplace=True): print line.replace("urgency=medium", "urgency=high"), # Revert workaround for git-dhc bug sh('rm -rf .git') if key is None and ppa is None: # A local installable package sh('debuild -uc -us -A') elif key is None and ppa is not None: # A sources package, signed by daemon sh('debuild -S') elif key is not None and ppa is None: # 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) if ppa is not None: sh('dput ppa:%s geonode_%s_source.changes' % (ppa, simple_version))
def pdf(args): texdir = os.path.join(options.out, 'tex') pdfdir = os.path.join('..', 'pdf') for book in options.books: with pushd(texdir) as old_dir: texfile = book+'.tex' pdffile = book+'.pdf' sh('rubber --pdf '+texfile) if os.path.isfile(pdffile): shutil.copy(pdffile, pdfdir)
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from geonode.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER["default"]["LOCATION"] url = "http://localhost:8080/geoserver/" if GEOSERVER_BASE_URL != url: print "your GEOSERVER_BASE_URL does not match %s" % url sys.exit(1) download_dir = path("downloaded").abspath() jetty_runner = download_dir / os.path.basename(JETTY_RUNNER_URL) data_dir = path("geoserver/data").abspath() web_app = path("geoserver/geoserver").abspath() log_file = path("geoserver/jetty.log").abspath() config = path("scripts/misc/jetty-runner.xml").abspath() # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): sh( ( "java -Xmx512m -XX:MaxPermSize=256m" " -DGEOSERVER_DATA_DIR=%(data_dir)s" # workaround for JAI sealed jar issue and jetty classloader " -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true" " -jar %(jetty_runner)s" " --log %(log_file)s" " %(config)s" " > /dev/null &" % locals() ) ) info("Starting GeoServer on %s" % url) # wait for GeoServer to start started = waitfor(url) info("The logs are available at %s" % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(("GeoServer never started properly or timed out." "It may still be running in the background.")) sys.exit(1)
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from openquakeplatform.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = "http://localhost:" + GEM_GEOSERVER_PORT + "/geoserver/" if GEOSERVER_BASE_URL != url: print 'your GEOSERVER_BASE_URL (%s) does not match %s' % (GEOSERVER_BASE_URL, url) sys.exit(1) download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(JETTY_RUNNER_URL) geoserver_port = GEM_GEOSERVER_PORT data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() # TODO: - we should not have set workdir to the datadir but a bug in # geoserver prevents geonode security from initializing correctly otherwise with pushd(data_dir): sh('java -Xmx512m -XX:MaxPermSize=256m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' # workaround for JAI sealed jar issue and jetty classloader ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --port %(geoserver_port)s' ' --log %(log_file)s' ' --path /geoserver %(web_app)s' ' > /dev/null &' % locals()) info('Starting GeoServer on %s' % url) # wait for GeoServer to start started = waitfor(url) info('The logs are available at %s' % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(('GeoServer never started properly or timed out.' 'It may still be running in the background.')) sys.exit(1)
def test_javascript(options): with pushd("geonode/static/geonode"): sh("./run-tests.sh")
def update_static(options): with pushd("geonode/static"): sh("npm install") sh("bower install") sh("grunt production")
def update_static(options): with pushd('geonode/static'): sh('npm install') sh('bower install') sh('grunt production')
def static(options): with pushd("geonode/static"): sh("make")
def static(options): with pushd('geonode/static'): sh('grunt production')
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from {{ project_name }}.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = GEOSERVER_BASE_URL if urlparse(GEOSERVER_BASE_URL).hostname != 'localhost': print "Warning: OGC_SERVER['default']['LOCATION'] hostname is not equal to 'localhost'" if not GEOSERVER_BASE_URL.endswith('/'): print "Error: OGC_SERVER['default']['LOCATION'] does not end with a '/'" sys.exit(1) download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(dev_config['JETTY_RUNNER_URL']) data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() config = path('jetty-runner.xml').abspath() jetty_port = urlparse(GEOSERVER_BASE_URL).port # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" loggernullpath = os.devnull # 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: 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." sys.exit(1) loggernullpath = "../../downloaded/null.txt" try: sh(('java -version')) except: 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") elif options.get('java_path'): javapath_opt = options.get('java_path') else: print "Paver cannot find java in the Windows Environment. \ Please provide the --java_path flag with your full path to \ java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" sys.exit(1) # if there are spaces javapath = 'START /B "" "' + javapath_opt + '"' sh(( '%(javapath)s -Xmx512m -XX:MaxPermSize=256m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' # workaround for JAI sealed jar issue and jetty classloader ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --port %(jetty_port)i' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals() ))
def package(options): """ Creates a tarball to use for building the system elsewhere """ import pkg_resources import tarfile import geonode version = geonode.get_version() # Use GeoNode's version for the package name. pkgname = 'GeoNode-%s-all' % version # Create the output directory. out_pkg = path(pkgname) out_pkg_tar = path("%s.tar.gz" % pkgname) # Create a distribution in zip format for the geonode python package. dist_dir = path('dist') dist_dir.rmtree() sh('python setup.py sdist --formats=zip') with pushd('package'): #Delete old tar files in that directory for f in glob.glob('GeoNode*.tar.gz'): old_package = path(f) if old_package != out_pkg_tar: old_package.remove() if out_pkg_tar.exists(): info('There is already a package for version %s' % version) return # Clean anything that is in the oupout package tree. out_pkg.rmtree() out_pkg.makedirs() support_folder = path('support') install_file = path('install.sh') # And copy the default files from the package folder. justcopy(support_folder, out_pkg / 'support') justcopy(install_file, out_pkg) geonode_dist = path('..') / 'dist' / 'GeoNode-%s.zip' % version justcopy(geonode_dist, out_pkg) # Create a tar file with all files in the output package folder. tar = tarfile.open(out_pkg_tar, "w:gz") for file in out_pkg.walkfiles(): tar.add(file) # Add the README with the license and important links to documentation. tar.add('README', arcname=('%s/README.rst' % out_pkg)) tar.close() # Remove all the files in the temporary output package directory. out_pkg.rmtree() # Report the info about the new package. info("%s created" % out_pkg_tar.abspath())
def package(options): """ Creates a tarball to use for building the system elsewhere """ import pkg_resources import tarfile import geonode version = geonode.get_version() # Use GeoNode's version for the package name. pkgname = "GeoNode-%s-all" % version # Create the output directory. out_pkg = path(pkgname) out_pkg_tar = path("%s.tar.gz" % pkgname) # Create a distribution in zip format for the geonode python package. dist_dir = path("dist") dist_dir.rmtree() sh("python setup.py sdist --formats=zip") with pushd("package"): # Delete old tar files in that directory for f in glob.glob("GeoNode*.tar.gz"): old_package = path(f) if old_package != out_pkg_tar: old_package.remove() if out_pkg_tar.exists(): info("There is already a package for version %s" % version) return # Clean anything that is in the oupout package tree. out_pkg.rmtree() out_pkg.makedirs() support_folder = path("support") install_file = path("install.sh") # And copy the default files from the package folder. justcopy(support_folder, out_pkg / "support") justcopy(install_file, out_pkg) geonode_dist = path("..") / "dist" / "GeoNode-%s.zip" % version justcopy(geonode_dist, out_pkg) rogue_dist = path("../..") / "dist" / "geoshape-0.1.zip" justcopy(rogue_dist, out_pkg) # Create a tar file with all files in the output package folder. tar = tarfile.open(out_pkg_tar, "w:gz") for file in out_pkg.walkfiles(): tar.add(file) # Add the README with the license and important links to documentation. tar.add("README", arcname=("%s/README.md" % out_pkg)) tar.close() # Remove all the files in the temporary output package directory. out_pkg.rmtree() # Report the info about the new package. info("%s created" % out_pkg_tar.abspath())
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ # we use docker-compose for integration tests if integration_tests: return # only start if using Geoserver backend if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server': return GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = GEOSERVER_BASE_URL if urlparse(GEOSERVER_BASE_URL).hostname != 'localhost': print "Warning: OGC_SERVER['default']['LOCATION'] hostname is not equal to 'localhost'" if not GEOSERVER_BASE_URL.endswith('/'): print "Error: OGC_SERVER['default']['LOCATION'] does not end with a '/'" sys.exit(1) download_dir = path('downloaded').abspath() 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() jetty_port = urlparse(GEOSERVER_BASE_URL).port import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket_free = True try: s.bind(("127.0.0.1", jetty_port)) except socket.error as e: socket_free = False if e.errno == 98: info('Port %s is already in use' % jetty_port) else: info( 'Something else raised the socket.error exception while checking port %s' % jetty_port) print(e) finally: s.close() if socket_free: # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" loggernullpath = os.devnull # 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 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." sys.exit(1) loggernullpath = "../../downloaded/null.txt" try: sh(('java -version')) 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") elif options.get('java_path'): javapath_opt = options.get('java_path') else: print "Paver cannot find java in the Windows Environment. \ Please provide the --java_path flag with your full path to \ java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" sys.exit(1) # if there are spaces javapath = 'START /B "" "' + javapath_opt + '"' sh(( '%(javapath)s -Xms512m -Xmx2048m -server -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m' ' -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' ' -jar %(jetty_runner)s' ' --port %(jetty_port)i' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals() )) info('Starting GeoServer on %s' % url) # wait for GeoServer to start started = waitfor(url) info('The logs are available at %s' % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(('GeoServer never started properly or timed out.' 'It may still be running in the background.')) sys.exit(1)
def deb(options): """ Creates debian packages. Example uses: paver deb paver deb -k 12345 paver deb -k 12345 -p geonode/testing """ key = options.get('key', None) ppa = options.get('ppa', None) import geonode from geonode.version import get_git_changeset raw_version = geonode.__version__ version = geonode.get_version() timestamp = get_git_changeset() major, minor, revision, stage, edition = raw_version branch = 'dev' if stage == 'alpha' and edition == 0: tail = '%s%s' % (branch, timestamp) else: tail = '%s%s' % (stage, edition) simple_version = '%s.%s.%s+%s' % (major, minor, revision, tail) info('Creating package for GeoNode version %s' % version) with pushd('package'): # Get rid of any uncommitted changes to debian/changelog info('Getting rid of any uncommitted changes in debian/changelog') sh('git checkout debian/changelog') # Workaround for git-dch bug # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594580 path('.git').makedirs() # Install requirements #sh('sudo apt-get -y install debhelper devscripts git-buildpackage') sh(('git-dch --spawn-editor=snapshot --git-author --new-version=%s' ' --id-length=6 --ignore-branch --release' % ( simple_version))) ## Revert workaround for git-dhc bug path('.git').rmtree() if key is None and ppa is None: # A local installable package sh('debuild -uc -us -A') elif key is None and ppa is not None: # A sources package, signed by daemon sh('debuild -S') elif key is not None and ppa is None: # 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) if ppa is not None: sh('dput ppa:%s geonode_%s_source.changes' % (ppa, simple_version))
def test_javascript(options): with pushd('geonode/static/geonode'): sh('./run-tests.sh')
def static(options): with pushd('geonode/static'): sh('make')
def static(options): with pushd("geonode/static"): sh("grunt production")
def run_latex(builddir): with pushd(builddir) as old_dir: for texfile in glob.glob('*.tex'): sh('rubber --pdf '+texfile)
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from geonode.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = "http://localhost:8080/geoserver/" if GEOSERVER_BASE_URL != url: print 'your GEOSERVER_BASE_URL does not match %s' % url sys.exit(1) download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(JETTY_RUNNER_URL) data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() config = path('scripts/jetty-runner.xml').abspath() # @todo - we should not have set workdir to the datadir but a bug # in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" loggernullpath = os.devnull # 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 as e: print "Chances are that you have Geoserver currently running.\ Youcan either stop all servers with paver stop or start only\ the django application with paver start_django." sys.exit(1) loggernullpath = "../../downloaded/null.txt" try: sh(('java -version')) 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") elif options.get('java_path'): javapath_opt = options.get('java_path') else: print "Paver cannot find java in the Windows Environment. \ Please provide the --java_path flag with your full path to \ java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" sys.exit(1) # if there are spaces javapath = 'START /B "" "' + javapath_opt + '"' sh(( '%(javapath)s -Xmx512m -XX:MaxPermSize=256m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' # workaround for JAI sealed jar issue and jetty classloader ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals())) info('Starting GeoServer on %s' % url) # wait for GeoServer to start started = waitfor(url) info('The logs are available at %s' % log_file) if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info(('GeoServer never started properly or timed out.' 'It may still be running in the background.')) sys.exit(1)
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ from geonode.settings import OGC_SERVER GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = GEOSERVER_BASE_URL if urlparse(GEOSERVER_BASE_URL).hostname != 'localhost': print "Warning: OGC_SERVER['default']['LOCATION'] hostname is not equal to 'localhost'" if not GEOSERVER_BASE_URL.endswith('/'): print "Error: OGC_SERVER['default']['LOCATION'] does not end with a '/'" sys.exit(1) download_dir = path('downloaded').abspath() jetty_runner = download_dir / os.path.basename(dev_config['JETTY_RUNNER_URL']) data_dir = path('geoserver/data').abspath() web_app = path('geoserver/geoserver').abspath() log_file = path('geoserver/jetty.log').abspath() config = path('scripts/misc/jetty-runner.xml').abspath() jetty_port = urlparse(GEOSERVER_BASE_URL).port # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" loggernullpath = os.devnull # 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: 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." sys.exit(1) loggernullpath = "../../downloaded/null.txt" try: sh(('java -version')) except: 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") elif options.get('java_path'): javapath_opt = options.get('java_path') else: print "Paver cannot find java in the Windows Environment. \ Please provide the --java_path flag with your full path to \ java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" sys.exit(1) # if there are spaces javapath = 'START /B "" "' + javapath_opt + '"' sh(( '%(javapath)s -Xmx512m -XX:MaxPermSize=256m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' # workaround for JAI sealed jar issue and jetty classloader ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --port %(jetty_port)i' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals() ))
def deb(options): """ Creates debian packages. Example uses: paver deb paver deb -k 12345 paver deb -k 12345 -p geonode/testing """ key = options.get('key', None) ppa = options.get('ppa', None) version, simple_version = versions() info('Creating package for GeoNode version %s' % version) # Get rid of any uncommitted changes to debian/changelog info('Getting rid of any uncommitted changes in debian/changelog') sh('git checkout package/debian/changelog') # Workaround for git-dch bug # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594580 sh('rm -rf %s/.git' % (os.path.realpath('package'))) sh('ln -s %s %s' % (os.path.realpath('.git'), os.path.realpath('package'))) with pushd('package'): # Install requirements # sh('sudo apt-get -y install debhelper devscripts git-buildpackage') # sh(('git-dch --spawn-editor=snapshot --git-author --new-version=%s' # ' --id-length=6 --ignore-branch --release' % (simple_version))) # In case you publish from Ubuntu Xenial (git-dch is removed from upstream) # use the following line instead: # sh(('gbp dch --spawn-editor=snapshot --git-author --new-version=%s' # ' --id-length=6 --ignore-branch --release' % (simple_version))) distribution = "xenial" sh(('gbp dch --distribution=%s --force-distribution --spawn-editor=snapshot --git-author --new-version=%s' ' --id-length=6 --ignore-branch --release' % (distribution, simple_version))) deb_changelog = path('debian') / 'changelog' for idx, line in enumerate(fileinput.input([deb_changelog], inplace=True)): if idx == 0: print "geonode (%s) %s; urgency=high" % (simple_version, distribution), else: print line.replace("urgency=medium", "urgency=high"), # Revert workaround for git-dhc bug sh('rm -rf .git') if key is None and ppa is None: # A local installable package sh('debuild -uc -us -A') elif key is None and ppa is not None: # A sources package, signed by daemon sh('debuild -S') elif key is not None and ppa is None: # 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) if ppa is not None: sh('dput ppa:%s geonode_%s_source.changes' % (ppa, simple_version))
def start_geoserver(options): """ Start GeoServer with GeoNode extensions """ # we use docker-compose for integration tests if on_travis and not options.get('force_exec', False): return # only start if using Geoserver backend if 'geonode.geoserver' not in INSTALLED_APPS: return GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION'] url = GEOSERVER_BASE_URL if urlparse(GEOSERVER_BASE_URL).hostname != 'localhost': logger.warning( "Warning: OGC_SERVER['default']['LOCATION'] hostname is not equal to 'localhost'" ) if not GEOSERVER_BASE_URL.endswith('/'): logger.error( "Error: OGC_SERVER['default']['LOCATION'] does not end with a '/'") sys.exit(1) download_dir = path('downloaded').abspath() 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() jetty_port = urlparse(GEOSERVER_BASE_URL).port import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket_free = True try: s.bind(("127.0.0.1", jetty_port)) except OSError as e: socket_free = False if e.errno == 98: info(f'Port {jetty_port} is already in use') else: info( f'Something else raised the socket.error exception while checking port {jetty_port}' ) print(e) finally: s.close() if socket_free: # @todo - we should not have set workdir to the datadir but a bug in geoserver # prevents geonode security from initializing correctly otherwise with pushd(data_dir): javapath = "java" if on_travis: sh('sudo apt install -y openjdk-8-jre openjdk-8-jdk;' ' sudo update-java-alternatives --set java-1.8.0-openjdk-amd64;' ' export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::");' ' export PATH=$JAVA_HOME\'bin/java\':$PATH;') # import subprocess # result = subprocess.run(['update-alternatives', '--list', 'java'], stdout=subprocess.PIPE) # javapath = result.stdout javapath = "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" loggernullpath = os.devnull # checking if our loggernullpath exists and if not, reset it to # something manageable if loggernullpath == "nul": try: open("../../downloaded/null.txt", 'w+').close() except OSError: 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.") sys.exit(1) loggernullpath = "../../downloaded/null.txt" try: sh(('%(javapath)s -version') % locals()) except Exception: logger.warning( "Java was not found in your path. Trying some other options: " ) javapath_opt = None if os.environ.get('JAVA_HOME', None): logger.info("Using the JAVA_HOME environment variable") 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: logger.critical( "Paver cannot find java in the Windows Environment. " "Please provide the --java_path flag with your full path to " "java.exe e.g. --java_path=C:/path/to/java/bin/java.exe" ) sys.exit(1) # if there are spaces javapath = f"START /B \"\" \"{javapath_opt}\"" sh('%(javapath)s -Xms512m -Xmx2048m -server -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m' ' -DGEOSERVER_DATA_DIR=%(data_dir)s' ' -DGEOSERVER_CSRF_DISABLED=true' ' -Dgeofence.dir=%(geofence_dir)s' ' -Djava.awt.headless=true' # ' -Dgeofence-ovr=geofence-datasource-ovr.properties' # workaround for JAI sealed jar issue and jetty classloader # ' -Dorg.eclipse.jetty.server.webapp.parentLoaderPriority=true' ' -jar %(jetty_runner)s' ' --port %(jetty_port)i' ' --log %(log_file)s' ' %(config)s' ' > %(loggernullpath)s &' % locals()) info(f'Starting GeoServer on {url}') # wait for GeoServer to start started = waitfor(url) info(f'The logs are available at {log_file}') if not started: # If applications did not start in time we will give the user a chance # to inspect them and stop them manually. info('GeoServer never started properly or timed out.' 'It may still be running in the background.') sys.exit(1)