Skip to content

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

@epwilkins

Description

@epwilkins

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions