def build_url(host, port=80, username=None, password=None, protocol='http'):
    if ((username is not None) and (password is not None)):
        url = '{0}://{1}:{2}@{3}:{4}'.format(protocol, username, password, host, port)
    else:
        url = '{0}://{1}:{2}'.format(protocol, host, port)
    return url
def build_url(host, port=80, username=None, password=None, protocol='http'):
    if ((username is not None) and (password is not None)):
        url = '{0}://{1}:{2}@{3}:{4}'.format(protocol, username, password, host, port)
    else:
        url = '{0}://{1}:{2}'.format(protocol, host, port)
    return url