当前位置: 首页>>代码示例>>Python>>正文


Python messages.error方法代码示例

本文整理汇总了Python中horizon.messages.error方法的典型用法代码示例。如果您正苦于以下问题:Python messages.error方法的具体用法?Python messages.error怎么用?Python messages.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizon.messages的用法示例。


在下文中一共展示了messages.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download_log

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def download_log(request, instance_id, filename):
    try:
        publish_value = request.GET.get('publish')
        if publish_value:
            publish = True
        else:
            publish = False

        data = get_contents(request,
                            instance_id,
                            filename,
                            publish,
                            FULL_LOG_VALUE)
        response = http.HttpResponse()
        response.write(data)
        response['Content-Disposition'] = ('attachment; '
                                           'filename="%s.log"' % filename)
        response['Content-Length'] = str(len(response.content))
        return response

    except Exception as e:
        messages.error(request, _('Error downloading log file: %s') % e)
        return shortcuts.redirect(request.build_absolute_uri()) 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:25,代码来源:views.py

示例2: analyze

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def analyze(request):
    # pwd = settings.BASE_DIR
    pwd = settings.ROOT_PATH
    JSON_FILE = pwd + '/don/ovs/don.json'

    params = {
        'error_file': pwd + '/don/templates/don/don.error.txt',
        'test:all': True,
        'test:ping': False,
        'test:ping_count': 1,
        'test:ovs': True,
        'test:report_file': pwd + '/don/templates/don/don.report.html',
    }
    print "params ====> ", params
    analyzer.analyze(JSON_FILE, params)
    # output = analyzer.analyze(JSON_FILE, params)
    # html = '<html><body>Output: %s</body></html>' % output
    # return HttpResponse(html)
    # return HttpResponseRedirect('/static/don.report.html')
    return render(request, "don/ovs/analyze.html")
    # return render_to_response('don/ovs/analyze.html') 
开发者ID:CiscoSystems,项目名称:don,代码行数:23,代码来源:views.py

示例3: collect

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def collect(request):
    macro = {'collect_status': 'Collection failed'}
    status = 0

    BASE_DIR = settings.ROOT_PATH
    # CUR_DIR = os.getcwd()
    os.chdir(BASE_DIR + '/don/ovs')
    cmd = 'sudo python collector.py'
    for line in run_command(cmd):
        if line.startswith('STATUS:') and line.find('Writing collected info') != -1:
            status = 1
            macro['collect_status'] = \
                "Collecton successful. Click visualize to display"
    # res = collector.main()
    os.chdir(BASE_DIR)
    if status:
        messages.success(request, macro['collect_status'])
    else:
        messages.error(request, macro['collect_status'])
    resp = HttpResponse(json.dumps(macro), content_type="application/json")
    return resp 
开发者ID:CiscoSystems,项目名称:don,代码行数:23,代码来源:views.py

示例4: get_data

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def get_data(self, request, stack_id):
        try:
            stack = api.heat.stack_get(request, stack_id)
            if stack.stack_status == 'DELETE_COMPLETE':
                # returning 404 to the ajax call removes the
                # row from the table on the ui
                raise Http404
            item = VNFManagerItemList.get_obj_given_stack_id(stack_id)
            item.status = stack.status
            item.stack_status = stack.stack_status
            return item
        except Http404:
            raise
        except Exception as e:
            messages.error(request, e)
            raise 
开发者ID:openstack,项目名称:tacker-horizon,代码行数:18,代码来源:tables.py

示例5: get_context_data

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def get_context_data(self, request):
        stack = self.tab_group.kwargs['stack']
        try:
            stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
            resources = api.heat.resources_list(self.request, stack_identifier)
            LOG.debug('got resources %s' % resources)
            # The stack id is needed to generate the resource URL.
            for r in resources:
                r.stack_id = stack.id
        except Exception:
            resources = []
            messages.error(request, _(
                'Unable to get resources for stack "%s".') % stack.stack_name)
        return {"stack": stack,
                "table": project_tables.ResourcesTable(
                    request, data=resources, stack=stack), } 
开发者ID:CiscoSystems,项目名称:avos,代码行数:18,代码来源:tabs.py

示例6: _set_external_network

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def _set_external_network(self, router, ext_net_dict):
        gateway_info = router.external_gateway_info
        if gateway_info:
            ext_net_id = gateway_info['network_id']
            if ext_net_id in ext_net_dict:
                gateway_info['network'] = ext_net_dict[ext_net_id]
            else:
                msg_params = {'ext_net_id': ext_net_id, 'router_id': router.id}
                msg = _('External network "%(ext_net_id)s" expected but not '
                        'found for router "%(router_id)s".') % msg_params
                messages.error(self.request, msg)
                # gateway_info['network'] is just the network name, so putting
                # in a smallish error message in the table is reasonable.
                gateway_info['network'] = pgettext_lazy(
                    'External network not found',
                    # Translators: The usage is "<UUID of ext_net> (Not Found)"
                    u'%s (Not Found)') % ext_net_id 
开发者ID:CiscoSystems,项目名称:avos,代码行数:19,代码来源:views.py

示例7: populate_network_id_choices

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def populate_network_id_choices(self, request):
        search_opts = {'router:external': True}
        try:
            networks = api.neutron.network_list(request, **search_opts)
        except Exception as e:
            msg = _('Failed to get network list %s') % e
            LOG.info(msg)
            messages.error(request, msg)
            redirect = reverse(self.failure_url)
            exceptions.handle(request, msg, redirect=redirect)
            return
        choices = [(network.id, network.name or network.id)
                   for network in networks]
        if choices:
            choices.insert(0, ("", _("Select network")))
        else:
            choices.insert(0, ("", _("No networks available")))
        return choices 
开发者ID:CiscoSystems,项目名称:avos,代码行数:20,代码来源:forms.py

示例8: delete

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def delete(self, request, obj_id):
        try:
            # detach all interfaces before attempting to delete the router
            search_opts = {'device_owner': 'network:router_interface',
                           'device_id': obj_id}
            ports = api.neutron.port_list(request, **search_opts)
            for port in ports:
                api.neutron.router_remove_interface(request, obj_id,
                                                    port_id=port.id)
            api.neutron.router_delete(request, obj_id)
        except q_ext.NeutronClientException as e:
            msg = _('Unable to delete router "%s"') % e
            LOG.info(msg)
            messages.error(request, msg)
            redirect = reverse(self.redirect_url)
            raise exceptions.Http302(redirect, message=msg)
        except Exception:
            obj = self.table.get_object_by_id(obj_id)
            name = self.table.get_object_display(obj)
            msg = _('Unable to delete router "%s"') % name
            LOG.info(msg)
            exceptions.handle(request, msg) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:24,代码来源:tables.py

示例9: download_rc_file

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def download_rc_file(request):
    template = 'project/access_and_security/api_access/openrc.sh.template'
    try:
        context = _get_openrc_credentials(request)

        response = shortcuts.render(request,
                                    template,
                                    context,
                                    content_type="text/plain")
        response['Content-Disposition'] = ('attachment; '
                                           'filename="%s-openrc.sh"'
                                           % context['tenant_name'])
        response['Content-Length'] = str(len(response.content))
        return response

    except Exception as e:
        LOG.exception("Exception in DownloadOpenRCForm.")
        messages.error(request, _('Error Downloading RC File: %s') % e)
        return shortcuts.redirect(request.build_absolute_uri()) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:21,代码来源:views.py

示例10: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def handle(self, request, data):
        user_is_editable = api.keystone.keystone_can_edit_user()

        if user_is_editable:
            try:
                api.keystone.user_update_own_password(request,
                                                      data['current_password'],
                                                      data['new_password'])
                response = http.HttpResponseRedirect(settings.LOGOUT_URL)
                msg = _("Password changed. Please log in again to continue.")
                utils.add_logout_reason(request, response, msg)
                return response
            except Exception:
                exceptions.handle(request,
                                  _('Unable to change password.'))
                return False
        else:
            messages.error(request, _('Changing password is not supported.'))
            return False 
开发者ID:CiscoSystems,项目名称:avos,代码行数:21,代码来源:forms.py

示例11: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def handle(self, table, request, obj_ids):
        try:
            username, password = api.trove.root_enable(request, obj_ids)
            table.data[0].enabled = True
            table.data[0].password = password
        except Exception:
            messages.error(request, _('There was a problem enabling root.')) 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:9,代码来源:tables.py

示例12: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def handle(self, table, request, obj_ids):
        datum_display_objs = []
        for datum_id in obj_ids:
            datum = table.get_object_by_id(datum_id)
            datum_display = table.get_object_display(datum) or datum_id
            datum_display_objs.append(datum_display)
        display_str = functions.lazy_join(", ", datum_display_objs)

        try:
            cluster_id = table.kwargs['cluster_id']
            data = [{'id': instance_id} for instance_id in obj_ids]
            api.trove.cluster_shrink(request, cluster_id, data)
            LOG.info('%s: "%s"' %
                     (self._get_action_name(past=True),
                      display_str))
            msg = _('Removed instances from cluster.')
            messages.info(request, msg)
        except Exception as ex:
            LOG.error('Action %(action)s failed with %(ex)s for %(data)s' %
                      {'action': self._get_action_name(past=True).lower(),
                       'ex': ex,
                       'data': display_str})
            msg = _('Unable to remove instances from cluster: %s')
            messages.error(request, msg % ex)

        return shortcuts.redirect(self.get_success_url(request)) 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:28,代码来源:tables.py

示例13: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def handle(self, table, request, obj_ids):
        configuration_id = table.kwargs['configuration_id']
        if config_param_manager.get(request, configuration_id).has_changes():
            try:
                config_param_manager.delete(configuration_id)
                messages.success(request, _('Reset Parameters'))
            except Exception as ex:
                messages.error(
                    request,
                    _('Error resetting parameters: %s') % ex)

        return shortcuts.redirect(request.build_absolute_uri()) 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:14,代码来源:tables.py

示例14: delete

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def delete(self, request, obj_id):
        share = manila.share_get(request, obj_id)
        try:
            manila.share_delete(
                request, share.id, share_group_id=share.share_group_id)
        except Exception:
            msg = _('Unable to delete share "%s". ') % obj_id
            messages.error(request, msg) 
开发者ID:openstack,项目名称:manila-ui,代码行数:10,代码来源:tables.py

示例15: delete

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import error [as 别名]
def delete(self, request, obj_id):
        try:
            manila.share_replica_delete(request, obj_id)
        except Exception:
            msg = _('Unable to delete replica "%s".') % obj_id
            messages.error(request, msg) 
开发者ID:openstack,项目名称:manila-ui,代码行数:8,代码来源:tables.py


注:本文中的horizon.messages.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。