# Path: watcher_dashboard/utils/errors.py
# def handle_errors(error_message, error_default=None, request_arg=None):
#     def decorator(func):
#         def wrapper(*args, **kwargs):


import logging
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.api import base
from watcherclient import client as wc
from watcher_dashboard.utils import errors as errors_utils
    insert_watcher_policy_file()

    endpoint = base.url_for(request, WATCHER_SERVICE)

    LOG.debug('watcherclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, endpoint))

    client = wc.get_client(
        api_version,
        watcher_url=endpoint,
        insecure=insecure,
        ca_file=ca_file,
        username=request.user.username,
        password=password,
        os_auth_token=request.user.token.id
    )
    return client


def insert_watcher_policy_file():
    policy_files = getattr(settings, 'POLICY_FILES', {})
    policy_files['infra-optim'] = 'watcher_policy.json'
    setattr(settings, 'POLICY_FILES', policy_files)


class Audit(base.APIDictWrapper):
    _attrs = ('uuid', 'name', 'created_at', 'modified_at', 'deleted_at',
              'state', 'audit_type', 'audit_template_uuid',
              'audit_template_name', 'interval')


# Path: watcher_dashboard/utils/errors.py
# def handle_errors(error_message, error_default=None, request_arg=None):
#     def decorator(func):
#         def wrapper(*args, **kwargs):


# Path: watcher_dashboard/api/watcher.py
import logging
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.api import base
from watcherclient import client as wc
from watcher_dashboard.utils import errors as errors_utils

    insert_watcher_policy_file()

    endpoint = base.url_for(request, WATCHER_SERVICE)

    LOG.debug('watcherclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, endpoint))

    client = wc.get_client(
        api_version,
        watcher_url=endpoint,
        insecure=insecure,
        ca_file=ca_file,
        username=request.user.username,
        password=password,
        os_auth_token=request.user.token.id
    )
    return client


def insert_watcher_policy_file():
    policy_files = getattr(settings, 'POLICY_FILES', {})
    policy_files['infra-optim'] = 'watcher_policy.json'
    setattr(settings, 'POLICY_FILES', policy_files)


class Audit(base.APIDictWrapper):
    _attrs = ('uuid', 'name', 'created_at', 'modified_at', 'deleted_at',
              'state', 'audit_type', 'audit_template_uuid',
              'audit_template_name', 'interval')


    def __init__(self, apiresource, request=None):