import dogecoinrpc


connection = dogecoinrpc.connect_to_local()


def get_cost():
    return 0


def generate_address():
    return connection.getnewaddress()


def check_balance(addr):
    return connection.getbalance(addr)

from socket import error
from httplib import HTTPException

import dogecoinrpc

from dinosaurs.exceptions import NoCoinServerError

connection = dogecoinrpc.connect_to_local()


def requires_connection(func):
    def wraps(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except (HTTPException, error):
            raise NoCoinServerError()
    return wraps


def get_cost():
    return 0


@requires_connection
def generate_address():
    return connection.getnewaddress()


@requires_connection
def check_balance(addr):
    return connection.getbalance(addr)

Add a decorator for catching coin server related errors