#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""
Module that contains utility functions related with email
"""

import webbrowser
try:
    import urllib2 as urllib
except ImportError:
    import urllib


def open_web(url):
    """
    Open given web URL in user web browser
    :param url: str
    """

    webbrowser.open(url)


def safe_open_url(url):
    """
    Opens given URL in a safe way
    :param url: str
    :return:
    """

    try:
        result = urllib.urlopen(url)
    except urllib.HTTPError as exc:
        raise Exception('{} : {}'.format(exc, exc.url))

    return result
