Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

krausening-python: If no default value is passed in, an exception is thrown #8

Open
ewilkins-csi opened this issue May 17, 2023 · 0 comments

Comments

@ewilkins-csi
Copy link

The defaultvalue argument is supposed to be optional in getProperty, but if it's not provided I get the following error:

Traceback (most recent call last):
  File "/opt/spark/jobs/pipelines/usgs-api-data/usgs_api_data_driver.py", line 31, in <module>
    ingest = Ingest().execute_step()
  File "/opt/spark/.local/lib/python3.9/site-packages/usgs_api_data/generated/step/ingest_base.py", line 56, in execute_step
    outbound = self.execute_step_impl()
  File "/opt/spark/.local/lib/python3.9/site-packages/usgs_api_data/step/ingest.py", line 44, in execute_step_impl
    self.config.query_additional(),
  File "/opt/spark/.local/lib/python3.9/site-packages/usgs_api_data/config/usgs_config.py", line 122, in query_additional
    raw_values = self.properties.getProperty("query.additional")
  File "/opt/spark/.local/lib/python3.9/site-packages/krausening/properties/property_manager.py", line 182, in getProperty
    return os.path.expandvars(defaultValue)
  File "/usr/local/lib/python3.9/posixpath.py", line 284, in expandvars
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

This is the calling code:

import os
from datetime import date, datetime
from krausening.properties import PropertyManager
from krausening.logging import LogManager

class UsgsConfig:
    def __init__(self):
        self.properties = PropertyManager.get_instance().get_properties(
            "usgs.properties"
        )


    def query_additional(self) -> {str, str}:
        raw_values = self.properties.getProperty("query.additional")
        additional = {}
        if raw_values is not None:
            for pair in raw_values.split("&"):
                key, value = pair.split("=")
                additional[key] = value
        return additional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant