From 961b2bf3b8fc7c770b1f5982b71308b8affff359 Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Wed, 7 Dec 2022 08:03:17 +0100 Subject: [PATCH 1/4] move OUTPUTFOLDER to nonrequired --- t.geoserver.publish/t.geoserver.publish.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/t.geoserver.publish/t.geoserver.publish.py b/t.geoserver.publish/t.geoserver.publish.py index 87769ff..862d53a 100644 --- a/t.geoserver.publish/t.geoserver.publish.py +++ b/t.geoserver.publish/t.geoserver.publish.py @@ -100,9 +100,9 @@ def cleanup(): os.remove(rm_file) -def get_env(envname): +def get_env(envname, required=True): env = os.getenv(envname) - if env is None: + if env is None and required is True: grass.fatal(_(f"Environment variable {envname} not defined.")) else: return env @@ -295,11 +295,16 @@ def main(): geoserver_user = get_env("GEOSERVER_USER") geoserver_pw = get_env("GEOSERVER_PASSWORD") geoserver_workspace = get_env("GEOSERVER_WORKSPACE") - outputfolder = get_env("OUTPUTFOLDER") # geoserver_datapath can be empty if no shared folder # between GRASS GIS and GeoServer is allowed, so # data will be uploaded instead of shared. - geoserver_datapath = os.getenv("GEOSERVER_DATAPATH") + geoserver_datapath = get_env("GEOSERVER_DATAPATH", required=False) + # if no shared folder exists, the OUTPUTFOLDER (where to store the temporary zip) + # does not matter, hence it can be a temp dir + if geoserver_datapath: + outputfolder = grass.tempdir() + else: + outputfolder = get_env("OUTPUTFOLDER") layer_suffix = 1 layernames = list() @@ -395,7 +400,7 @@ def main(): if not geoserver_datapath: # Case when GRASS GIS and GeoServer don't share a common directory output_uuid = str(uuid.uuid4()) - targetdir_grass = f"{targetdir_grass}/{output_uuid}" + targetdir_grass = os.path.join(targetdir_grass, output_uuid) if not os.path.isdir(targetdir_grass): os.makedirs(targetdir_grass) # if the dir exists and has files, cancel @@ -505,7 +510,7 @@ def main(): geoserver_port, geoserver_auth, ) - rm_dirs.append(targetdir_grass) + rm_dirs.append(outputfolder) rm_files.append(zip_name) layernames.append(mosaic_layername) From fc418b3e3e96a96459bbfc6fe2e3d0f559baff10 Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Wed, 7 Dec 2022 08:15:38 +0100 Subject: [PATCH 2/4] fix if loop --- t.geoserver.publish/t.geoserver.publish.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t.geoserver.publish/t.geoserver.publish.py b/t.geoserver.publish/t.geoserver.publish.py index 862d53a..538d385 100644 --- a/t.geoserver.publish/t.geoserver.publish.py +++ b/t.geoserver.publish/t.geoserver.publish.py @@ -302,9 +302,9 @@ def main(): # if no shared folder exists, the OUTPUTFOLDER (where to store the temporary zip) # does not matter, hence it can be a temp dir if geoserver_datapath: - outputfolder = grass.tempdir() - else: outputfolder = get_env("OUTPUTFOLDER") + else: + outputfolder = grass.tempdir() layer_suffix = 1 layernames = list() From 12e4271de872ef7c20ceee7991eda7919fe9d53c Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Wed, 7 Dec 2022 08:44:08 +0100 Subject: [PATCH 3/4] skip deletion of zip --- t.geoserver.publish/t.geoserver.publish.py | 1 - 1 file changed, 1 deletion(-) diff --git a/t.geoserver.publish/t.geoserver.publish.py b/t.geoserver.publish/t.geoserver.publish.py index 538d385..49beac2 100644 --- a/t.geoserver.publish/t.geoserver.publish.py +++ b/t.geoserver.publish/t.geoserver.publish.py @@ -511,7 +511,6 @@ def main(): geoserver_auth, ) rm_dirs.append(outputfolder) - rm_files.append(zip_name) layernames.append(mosaic_layername) # style the layer(s) From 499b604ff3302924cdda7fc7235be2d7fcb34cf6 Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Wed, 7 Dec 2022 08:54:46 +0100 Subject: [PATCH 4/4] update html --- t.geoserver.publish/t.geoserver.publish.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t.geoserver.publish/t.geoserver.publish.html b/t.geoserver.publish/t.geoserver.publish.html index 62d768d..e9c063a 100644 --- a/t.geoserver.publish/t.geoserver.publish.html +++ b/t.geoserver.publish/t.geoserver.publish.html @@ -8,13 +8,13 @@

DESCRIPTION

  • GEOSERVER_USER
  • GEOSERVER_PASSWORD
  • GEOSERVER_WORKSPACE
  • -
  • OUTPUTFOLDER
  • In case a shared directory between GRASS GIS and GeoServer is possible, -another environment variable can be used to tell GeoServer to publish data +two further environment variables can be used to tell GeoServer to publish data from this local path instead of uploading the data:
      -
    • GEOSERVER_DATAPATH
    • +
    • OUTPUTFOLDER (path from GRASS GIS to shared directory)
    • +
    • GEOSERVER_DATAPATH (path from GeoServer to shared directory)
    There are two ways to publish GeoServer layers with t.geoserver.publish: