-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff8c78b
commit 11815e5
Showing
11 changed files
with
2,716 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
""" | ||
Configuration | ||
------------- | ||
WPS servers often need to specify a number of paths for processes to find data, shapefiles, caches and determine where | ||
outputs are stored. To make sure all birds use the same architecture, eggshell provides a :class:`Paths` class to help | ||
with this. | ||
""" | ||
|
||
import os | ||
from pywps import configuration | ||
import logging | ||
LOGGER = logging.getLogger("PYWPS") | ||
|
||
|
||
class Paths(object): | ||
"""This class facilitates the configuration of WPS birds.""" | ||
def __init__(self, module): | ||
"""Instantiate class relative to the given module. | ||
:param module: Imported module relative to which paths will be defined. | ||
""" | ||
self._base = module.__path__[0] | ||
|
||
@property | ||
def cache(self): | ||
"""Return the path to the server cache directory.""" | ||
out = configuration.get_config_value("cache", "cache_path") | ||
if not out: | ||
LOGGER.warn("No cache path configured. Using default value.") | ||
out = os.path.join(configuration.get_config_value("server", "outputpath"), "cache") | ||
return out | ||
|
||
@property | ||
def data(self): | ||
"""Return the path to the data directory.""" | ||
return os.path.join(self._base, 'data') | ||
|
||
@property | ||
def masks(self): | ||
"""Return the path to the masks directory.""" | ||
# TODO: currently this folder is not used | ||
return os.path.join(self.data, 'masks') | ||
|
||
@property | ||
def outputpath(self): | ||
"""Return the server directory for process outputs.""" | ||
return configuration.get_config_value("server", "outputpath") | ||
|
||
@property | ||
def outputurl(self): | ||
"""Return the server URL for process outputs.""" | ||
return configuration.get_config_value("server", "outputurl").rstrip('/') | ||
|
||
@property | ||
def Rsrc_dir(self): | ||
"""Return the path to the R source directory.""" | ||
return os.path.join(self._base, 'Rsrc') | ||
|
||
@property | ||
def shapefiles(self): | ||
"""Return the path to the geographic data directory.""" | ||
return os.path.join(self.data, 'shapefiles') | ||
|
||
@property | ||
def static(self): | ||
"""Return the path to the static content directory.""" | ||
return os.path.join(self._base, 'static') | ||
|
||
@property | ||
def testdata(self): | ||
"""Return the path to the test data directory.""" | ||
return os.path.join(self._base, 'tests/testdata') | ||
|
||
|
||
|
||
|
||
# Should these go into the class or they're too specialized ? | ||
def esgfsearch_distrib(): | ||
"""TODO""" | ||
distrib = configuration.get_config_value("extra", "esgfsearch_distrib") | ||
if distrib is None: | ||
LOGGER.warn("No ESGF Search distrib option configured. Using default value.") | ||
distrib = True | ||
return distrib | ||
|
||
|
||
def esgfsearch_url(): | ||
"""Return the server configuration value for the ESGF search node URL.""" | ||
url = configuration.get_config_value("extra", "esgfsearch_url") | ||
if not url: | ||
LOGGER.warn("No ESGF Search URL configured. Using default value.") | ||
url = 'https://esgf-data.dkrz.de/esg-search' | ||
return url |
Empty file.
Oops, something went wrong.