Skip to main content

HDX Python Utilities

Project description

Travis-CI Build Status Coveralls Build Status

The HDX Python Utilities Library provides a range of helpful utilities:

  1. Easy downloading of files with support for authentication, streaming and hashing
  2. Simple emailing
  3. Easy logging setup
  4. Dictionary and list utilities
  5. Text block matching
  6. Path utilities
  7. Loading and saving JSON and YAML (inc. OrderedDict)

This library is part of the Humanitarian Data Exchange (HDX) project. If you have humanitarian related data, please upload your datasets to HDX.


The library has detailed API documentation which can be found here: The code for the library is here:

Configuring Logging

The library provides coloured logs with a simple default setup. If you wish to change the logging configuration from the defaults, you will need to call setup_logging with arguments.

from hdx.utilities.easy_logging import setup_logging
logger = logging.getLogger(__name__)
setup_logging(KEYWORD ARGUMENTS)


Choose Argument Type Value Default
One of: logging_config_dict dict Logging configuration dictionary  
or logging_config_json str Path to JSON Logging configuration  
or logging_config_yaml str Path to YAML Logging configuration Library’s internal logging_configuration.yml
One of: smtp_config_dict dict Email Logging configuration dictionary  
or smtp_config_json str Path to JSON Email Logging configuration  
or smtp_config_yaml str Path to YAML Email Logging configuration  

Do not supply smtp_config_dict, smtp_config_json or smtp_config_yaml unless you are using the default logging configuration!

If you are using the default logging configuration, you have the option to have a default SMTP handler that sends an email in the event of a CRITICAL error by supplying either smtp_config_dict, smtp_config_json or smtp_config_yaml. Here is a template of a YAML file that can be passed as the smtp_config_yaml parameter:

        toaddrs: EMAIL_ADDRESSES
        subject: "RUN FAILED: MY_PROJECT_NAME"

Unless you override it, the mail server mailhost for the default SMTP handler is localhost and the from address fromaddr is noreply@localhost.

To use logging in your files, simply add the line below to the top of each Python file:

logger = logging.getLogger(__name__)

Then use the logger like this:

logger.debug('DEBUG message')'INFORMATION message')
logger.warning('WARNING message')
logger.error('ERROR message')
logger.critical('CRITICAL error message')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
hdx_python_utilities-1.4.5-py2.py3-none-any.whl (21.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Sep 25, 2018
hdx-python-utilities-1.4.5.tar.gz (36.9 kB) Copy SHA256 hash SHA256 Source None Sep 25, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page