# Path: pyxform/errors.py
# class PyXFormError(Exception):
#     """Common base class for pyxform exceptions."""
# 
#     pass


import collections
import io
import logging
import os
import signal
import subprocess
import tempfile
import threading
import time
from contextlib import closing
from subprocess import PIPE, Popen
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
from pyxform.errors import PyXFormError
    try:
        return stream.decode("utf-8")
    except UnicodeDecodeError as ude:
        try:
            return stream.decode("latin-1")
        except BaseException as be:
            msg = "Failed to decode validate stderr as utf-8 or latin-1."
            raise IOError(msg, ude, be)


def request_get(url):
    """
    Get the response content from URL.
    """
    try:
        r = Request(url)
        r.add_header("Accept", "application/json")
        with closing(urlopen(r)) as u:
            content = u.read()
        if len(content) == 0:
            raise PyXFormError("Empty response from URL: '{u}'.".format(u=url))
        else:
            return content
    except HTTPError as e:
        raise PyXFormError(
            "Unable to fulfill request. Error code: '{c}'. "
            "Reason: '{r}'. URL: '{u}'."
            "".format(r=e.reason, c=e.code, u=url)
        )
    except URLError as e:

# Path: pyxform/errors.py
# class PyXFormError(Exception):
#     """Common base class for pyxform exceptions."""
# 
#     pass


# Path: pyxform/validators/util.py
import collections
import io
import logging
import os
import signal
import subprocess
import tempfile
import threading
import time
from contextlib import closing
from subprocess import PIPE, Popen
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
from pyxform.errors import PyXFormError

    try:
        return stream.decode("utf-8")
    except UnicodeDecodeError as ude:
        try:
            return stream.decode("latin-1")
        except BaseException as be:
            msg = "Failed to decode validate stderr as utf-8 or latin-1."
            raise IOError(msg, ude, be)


def request_get(url):
    """
    Get the response content from URL.
    """
    try:
        r = Request(url)
        r.add_header("Accept", "application/json")
        with closing(urlopen(r)) as u:
            content = u.read()
        if len(content) == 0:
            raise PyXFormError("Empty response from URL: '{u}'.".format(u=url))
        else:
            return content
    except HTTPError as e:
        raise PyXFormError(
            "Unable to fulfill request. Error code: '{c}'. "
            "Reason: '{r}'. URL: '{u}'."
            "".format(r=e.reason, c=e.code, u=url)
        )
    except URLError as e:

        raise PyXFormError(