• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.err函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.err函数的典型用法代码示例。如果您正苦于以下问题:Python err函数的具体用法?Python err怎么用?Python err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: auth_nodes

def auth_nodes(nodes):
    if "-u" in utils.pcs_options:
        username = utils.pcs_options["-u"]
    else:
        username = None

    if "-p" in utils.pcs_options:
        password = utils.pcs_options["-p"]
    else:
        password = None

    for node in nodes:
        status = utils.checkAuthorization(node)
        if status[0] == 3 or "--force" in utils.pcs_options:
            if username == None:
                sys.stdout.write('Username: ')
                sys.stdout.flush()
                username = raw_input("")
            if password == None:
                if sys.stdout.isatty():
                    password = getpass.getpass("Password: ")
                else:
                    sys.stdout.write('Password: ')
                    sys.stdout.flush()
                    password = raw_input("")
            utils.updateToken(node,nodes,username,password)
            print "%s: Authorized" % (node)
        elif status[0] == 0:
            print node + ": Already authorized"
        else:
            utils.err("Unable to communicate with %s" % (node))
开发者ID:deriamis,项目名称:pcs,代码行数:31,代码来源:cluster.py


示例2: __getattr__

    def __getattr__(self, name):
        if not isinstance(name, str) or not hasattr(zookeeper, name):
            raise ZooKeeperError("Method %s() doesn't exist" % str(name))

        if name in ("ASSOCIATING_STATE","AUTH_FAILED_STATE",
                    "CONNECTED_STATE","CONNECTING_STATE",
                    "EXPIRED_SESSION_STATE","NOTWATCHING_EVENT",
                    "SESSION_EVENT","CREATED_EVENT",
                    "DELETED_EVENT","CHANGED_EVENT","CHILD_EVENT"):
            return getattr(zookeeper, name)

        def safe_get(*args, **kwargs):
            func, result = getattr(zookeeper, name), None
            def real_func():
                if name in ("get", "exists", "get_children"):
                    path, watcher = args[0], args[1] if len(args) > 1 else None
                    return func(self._handler, path, self._wrap_watcher(watcher))
                else:
                    return func(self._handler, *args, **kwargs)
            try:
                result = real_func()
            except zookeeper.SessionExpiredException, err:
                utils.err(utils.cur(), err, "session expired, retry %s(%s,%s)" % (name, args, kwargs))
                self.connect()
                result = real_func()
            except zookeeper.ConnectionLossException, err:
                utils.err(utils.cur(), err, "connection loss, retry %s(%s,%s)" % (name, args, kwargs))
                self.connect()
                result = real_func()
开发者ID:fifar,项目名称:mysql_proxy,代码行数:29,代码来源:zk_helper.py


示例3: config_restore

def config_restore(argv):
    if len(argv) > 1:
        usage.config(["restore"])
        sys.exit(1)

    infile_name = infile_obj = None
    if argv:
        infile_name = argv[0]
    if not infile_name:
        infile_obj = cStringIO.StringIO(sys.stdin.read())

    if os.getuid() == 0:
        if "--local" in utils.pcs_options:
            config_restore_local(infile_name, infile_obj)
        else:
            config_restore_remote(infile_name, infile_obj)
    else:
        new_argv = ['config', 'restore']
        new_stdin = None
        if '--local' in utils.pcs_options:
            new_argv.append('--local')
        if infile_name:
            new_argv.append(os.path.abspath(infile_name))
        else:
            new_stdin = infile_obj.read()
        err_msgs, exitcode, std_out, std_err = utils.call_local_pcsd(
            new_argv, True, new_stdin
        )
        if err_msgs:
            for msg in err_msgs:
                utils.err(msg, False)
            sys.exit(1)
        print std_out
        sys.stderr.write(std_err)
        sys.exit(exitcode)
开发者ID:WeiRG,项目名称:pcs,代码行数:35,代码来源:config.py


示例4: acl_permission

def acl_permission(argv):
    if len(argv) < 1:
        usage.acl("permission")
        sys.exit(1)

    dom = utils.get_cib_dom()
    dom, acls = get_acls(dom)

    command = argv.pop(0)
    if command == "add":
        if len(argv) < 4:
            usage.acl("permission add")
            sys.exit(1)
        role_id = argv.pop(0)
        found = False
        for role in dom.getElementsByTagName("acl_role"):
            if role.getAttribute("id") == role_id:
                found = True
                break
        if found == False:
            acl_role(["create", role_id] + argv) 
            return

        while len(argv) >= 3:
            kind = argv.pop(0)
            se = dom.createElement("acl_permission")
            se.setAttribute("id", utils.find_unique_id(dom, role_id + "-" + kind))
            se.setAttribute("kind", kind)
            xp_id = argv.pop(0)
            if xp_id == "xpath":
                xpath_query = argv.pop(0)
                se.setAttribute("xpath",xpath_query)
            elif xp_id == "id":
                acl_ref = argv.pop(0)
                se.setAttribute("reference",acl_ref)
            else:
                usage.acl("permission add")
            role.appendChild(se)

        utils.replace_cib_configuration(dom)

    elif command == "delete":
        if len(argv) < 1:
            usage.acl("permission delete")
            sys.exit(1)

        perm_id = argv.pop(0)
        found = False
        for elem in dom.getElementsByTagName("acl_permission"):
            if elem.getAttribute("id") == perm_id:
                elem.parentNode.removeChild(elem)
                found = True
        if not found:
            utils.err("Unable to find permission with id: %s" % perm_id)

        utils.replace_cib_configuration(dom)

    else:
        usage.acl("permission")
        sys.exit(1)
开发者ID:MichalCab,项目名称:pcs,代码行数:60,代码来源:acl.py


示例5: list_property

def list_property(argv):
    print_all = False
    if len(argv) == 0:
        print_all = True

    if "--all" in utils.pcs_options or "--defaults" in utils.pcs_options:
        if len(argv) != 0:
            utils.err("you cannot specify a property when using --all or --defaults")
        properties = get_default_properties()
    else:
        properties = {}

    if "--defaults" not in utils.pcs_options:
        (output, retVal) = utils.run(["cibadmin", "-Q", "--scope", "crm_config"])
        if retVal != 0:
            utils.err("unable to get crm_config\n" + output)
        dom = parseString(output)
        de = dom.documentElement
        crm_config_properties = de.getElementsByTagName("nvpair")
        for prop in crm_config_properties:
            if print_all == True or (argv[0] == prop.getAttribute("name")):
                properties[prop.getAttribute("name")] = prop.getAttribute("value")

    print "Cluster Properties:"
    for prop, val in sorted(properties.iteritems()):
        print " " + prop + ": " + val

    node_attributes = utils.get_node_attributes()
    if node_attributes:
        print "Node Attributes:"
        for node in sorted(node_attributes):
            print " " + node + ":",
            for attr in node_attributes[node]:
                print attr,
            print
开发者ID:paul-guo-,项目名称:appstack,代码行数:35,代码来源:prop.py


示例6: cluster_remote_node

def cluster_remote_node(argv):
    if len(argv) < 1:
        usage.cluster(["remote-node"])
        sys.exit(1)

    command = argv.pop(0)
    if command == "add":
        if len(argv) < 2:
            usage.cluster(["remote-node"])
            sys.exit(1)
        hostname = argv.pop(0)
        rsc = argv.pop(0)
        if not utils.is_resource(rsc):
            utils.err("unable to find resource '%s'", rsc)
        resource.resource_update(rsc, ["meta", "remote-node="+hostname] + argv)

    elif command in ["remove","delete"]:
        if len(argv) < 1:
            usage.cluster(["remote-node"])
            sys.exit(1)
        hostname = argv.pop(0)
        dom = utils.get_cib_dom()
        nvpairs = dom.getElementsByTagName("nvpair")
        nvpairs_to_remove = []
        for nvpair in nvpairs:
            if nvpair.getAttribute("name") == "remote-node" and nvpair.getAttribute("value") == hostname:
                for np in nvpair.parentNode.getElementsByTagName("nvpair"):
                    if np.getAttribute("name").startswith("remote-"):
                        nvpairs_to_remove.append(np)
        for nvpair in nvpairs_to_remove[:]:
            nvpair.parentNode.removeChild(nvpair)
        utils.replace_cib_configuration(dom)
    else:
        usage.cluster(["remote-node"])
        sys.exit(1)
开发者ID:yash2710,项目名称:wamp,代码行数:35,代码来源:cluster.py


示例7: node_standby

def node_standby(argv,standby=True):
    if len(argv) == 0 and "--all" not in utils.pcs_options:
        if standby:
            usage.cluster(["standby"])
        else:
            usage.cluster(["unstandby"])
        sys.exit(1)

    nodes = utils.getNodesFromPacemaker()

    if "--all" not in utils.pcs_options:
        nodeFound = False
        for node in nodes:
            if node == argv[0]:
                nodeFound = True
                break

        if not nodeFound:
            utils.err("node '%s' does not appear to exist in configuration" % argv[0])

        if standby:
            utils.run(["crm_standby", "-v", "on", "-N", node])
        else:
            utils.run(["crm_standby", "-D", "-N", node])
    else:
        for node in nodes:
            if standby:
                utils.run(["crm_standby", "-v", "on", "-N", node])
            else:
                utils.run(["crm_standby", "-D", "-N", node])
开发者ID:yash2710,项目名称:wamp,代码行数:30,代码来源:cluster.py


示例8: export

    def export(self, pos):
        elements = []
        delta_pos = self.gen_pos_delta(pos)
        for tile in self.view.tiles:
            tile_html = TileHtmlElement()
            tile_html.pos = list(map(lambda x: x[0]+x[1],
                                     zip(tile.pos, delta_pos)))
            tile_html.size = tile.size
            for facet in tile.facets:
                f = FacetHtmlElement(facet.pic, facet.title)
                if facet.typecode not in api_module.api_mapping:
                    err("ViewExport::export() no typecode found in api mapping "
                        "structure: %s"%facet.typecode)
                    exit(0)
                if facet.typecode not in api_module.module_mapping:
                    errtrace("Facet::self_verify() no api module defined for "
                             "typecode %s"%facet.typecode.encode())
                    exit(0)
                cl = api_module.module_mapping[facet.typecode]
                m = cl(facet.id, facet.title)
                f.url = m.export_html(settings.POSTER_HOME, settings.override)
                om_output("Facet %s export html %s"%(facet.title, f.url))
                if f.url is False:
                    f.url = "#"

                tile_html.facets.append(f)
            elements.append(tile_html)

        s = ""
        for e in elements:
            s += e.export() + "\n"
        return s
开发者ID:wanziforever,项目名称:tools,代码行数:32,代码来源:html_export.py


示例9: post

    def post(self):
        """
        HTTP POST request
        :return: status code from the slack end point
        """

        post_data = get_post_data(request)
        current_app.logger.info('Received feedback: {0}'.format(post_data))

        if not post_data.get('g-recaptcha-response', False) or \
                not verify_recaptcha(request):
            current_app.logger.info('The captcha was not verified!')
            return err(ERROR_UNVERIFIED_CAPTCHA)
        else:
            current_app.logger.info('Skipped captcha!')

        try:
            current_app.logger.info('Prettifiying post data: {0}'
                                    .format(post_data))
            formatted_post_data = json.dumps(self.prettify_post(post_data))
            current_app.logger.info('Data prettified: {0}'
                                    .format(formatted_post_data))
        except BadRequestKeyError as error:
            current_app.logger.error('Missing keywords: {0}, {1}'
                                     .format(error, post_data))
            return err(ERROR_MISSING_KEYWORDS)

        slack_response = requests.post(
            url=current_app.config['FEEDBACK_SLACK_END_POINT'],
            data=formatted_post_data
        )

        return slack_response.json(), slack_response.status_code
开发者ID:jonnybazookatone,项目名称:slackback,代码行数:33,代码来源:views.py


示例10: send_msg

 def send_msg(self, msg):
     try:
         self.pika.send_msg(msg)
     except Exception, err:
         utils.err(utils.cur(), err)
         self.is_server_down = True
         self.try_reconnect()
开发者ID:fifar,项目名称:mysql_proxy,代码行数:7,代码来源:mq_helper.py


示例11: order_rm

def order_rm(argv):
    if len(argv) == 0:
        usage.constraint()
        sys.exit(1)

    elementFound = False
    (dom,constraintsElement) = getCurrentConstraints()

    for resource in argv:
        for ord_loc in constraintsElement.getElementsByTagName('rsc_order')[:]:
            if ord_loc.getAttribute("first") == resource or ord_loc.getAttribute("then") == resource:
                constraintsElement.removeChild(ord_loc)
                elementFound = True

        resource_refs_to_remove = []
        for ord_set in constraintsElement.getElementsByTagName('resource_ref'):
            if ord_set.getAttribute("id") == resource:
                resource_refs_to_remove.append(ord_set)
                elementFound = True

        for res_ref in resource_refs_to_remove:
            res_set = res_ref.parentNode
            res_order = res_set.parentNode

            res_ref.parentNode.removeChild(res_ref)
            if len(res_set.getElementsByTagName('resource_ref')) <= 0:
                res_set.parentNode.removeChild(res_set)
                if len(res_order.getElementsByTagName('resource_set')) <= 0:
                    res_order.parentNode.removeChild(res_order)

    if elementFound == True:
        utils.replace_cib_configuration(dom)
    else:
        utils.err("No matching resources found in ordering list")
开发者ID:vincepii,项目名称:pcs,代码行数:34,代码来源:constraint.py


示例12: config_checkpoint_list

def config_checkpoint_list():
    try:
        file_list = os.listdir(settings.cib_dir)
    except OSError as e:
        utils.err("unable to list checkpoints: %s" % e)
    cib_list = []
    cib_name_re = re.compile("^cib-(\d+)\.raw$")
    for filename in file_list:
        match = cib_name_re.match(filename)
        if not match:
            continue
        file_path = os.path.join(settings.cib_dir, filename)
        try:
            if os.path.isfile(file_path):
                cib_list.append(
                    (float(os.path.getmtime(file_path)), match.group(1))
                )
        except OSError:
            pass
    cib_list.sort()
    if not cib_list:
        print "No checkpoints available"
        return
    for cib_info in cib_list:
        print(
            "checkpoint %s: date %s"
            % (cib_info[1], datetime.datetime.fromtimestamp(round(cib_info[0])))
        )
开发者ID:disco-stu,项目名称:pcs,代码行数:28,代码来源:config.py


示例13: navigate

def navigate():
    global current_label
    while(True):
        inp = raw_input("Enter your choice: ")
        inp = inp.strip()
        if inp.lower() == "q":
            exit(0)
        if inp == "":
            show_current_menu()
            continue
        if inp.lower() == "u":
            current_label = up_label(current_label)
            show_current_menu()
            continue
        succ, msg = validate_label(inp)
        if succ is False:
            err(msg)
            continue
        print "your choice is %s"%inp
        label = go_to_label(inp)
        if label not in menu_items:
            err("label is out of range")
            continue
        item = menu_items[label]
        if item.__class__.__name__ == "CommandItem":
            item.execute()
            show_current_menu()
        else:
            current_label = label
            show_current_menu()
        continue
开发者ID:wanziforever,项目名称:tools,代码行数:31,代码来源:imenu.py


示例14: cluster_cib_revisions

def cluster_cib_revisions(argv):
    try:
        file_list = os.listdir(settings.cib_dir)
    except OSError as e:
        utils.err("unable to list CIB revisions: %s" % e)
    cib_list = []
    cib_name_re = re.compile("^cib-\d+\.raw$")
    for filename in file_list:
        if not cib_name_re.match(filename):
            continue
        file_path = os.path.join(settings.cib_dir, filename)
        try:
            if os.path.isfile(file_path):
                cib_list.append((int(os.path.getmtime(file_path)), filename))
        except OSError:
            pass
    cib_list.sort()
    if not cib_list:
        print "No CIB revisions available"
        return
    for cib_info in cib_list:
        print datetime.datetime.fromtimestamp(cib_info[0]), cib_info[1]
    print
    print(
        "You can inspect a CIB revision using the '-f' switch, e.g. "
        "'pcs -f %(path)s status' or 'pcs -f %(path)s constraint'"
        % {"path": os.path.join(settings.cib_dir, "<cib-revision>")}
    )
开发者ID:deriamis,项目名称:pcs,代码行数:28,代码来源:cluster.py


示例15: list_property

def list_property(argv):
    print_all = False
    if len(argv) == 0:
        print_all = True

    if "--all" in utils.pcs_options or "--defaults" in utils.pcs_options:
        if len(argv) != 0:
            utils.err("you cannot specify a property when using --all or --defaults")
        properties = get_default_properties()
    else:
        properties = {}
        
    if "--defaults" not in utils.pcs_options:
        properties = get_set_properties(
            None if print_all else argv[0],
            properties
        )

    print("Cluster Properties:")
    for prop,val in sorted(properties.items()):
        print(" " + prop + ": " + val)

    node_attributes = utils.get_node_attributes()
    if node_attributes:
        print("Node Attributes:")
        for node in sorted(node_attributes):
            print(" " + node + ":", end=' ')
            for attr in node_attributes[node]:
                print(attr, end=' ')
            print()
开发者ID:tradej,项目名称:pcs,代码行数:30,代码来源:prop.py


示例16: location_rule

def location_rule(argv):
    if len(argv) < 3:
        usage.constraint("location rule")
        sys.exit(1)
    
    res_name = argv.pop(0)
    resource_valid, resource_error = utils.validate_constraint_resource(
        utils.get_cib_dom(), res_name
    )
    if not resource_valid:
        utils.err(resource_error)

    argv.pop(0)

    cib = utils.get_cib_dom()
    constraints = cib.getElementsByTagName("constraints")[0]
    lc = cib.createElement("rsc_location")
    constraints.appendChild(lc)
    lc_id = utils.find_unique_id(cib, "location-" + res_name)
    lc.setAttribute("id", lc_id)
    lc.setAttribute("rsc", res_name)

    rule_utils.dom_rule_add(lc, argv)

    utils.replace_cib_configuration(cib)
开发者ID:MichalCab,项目名称:pcs,代码行数:25,代码来源:constraint.py


示例17: node_standby

def node_standby(argv,standby=True):
    # If we didn't specify any arguments, use the current node name
    if len(argv) == 0 and "--all" not in utils.pcs_options:
        p = subprocess.Popen(["uname","-n"], stdout=subprocess.PIPE)
        cur_node = p.stdout.readline().rstrip()
        argv = [cur_node]

    nodes = utils.getNodesFromPacemaker()

    if "--all" not in utils.pcs_options:
        nodeFound = False
        for node in nodes:
            if node == argv[0]:
                nodeFound = True
                break

        if not nodeFound:
            utils.err("node '%s' does not appear to exist in configuration" % argv[0])

        if standby:
            utils.run(["crm_standby", "-v", "on", "-N", node])
        else:
            utils.run(["crm_standby", "-D", "-N", node])
    else:
        for node in nodes:
            if standby:
                utils.run(["crm_standby", "-v", "on", "-N", node])
            else:
                utils.run(["crm_standby", "-D", "-N", node])
开发者ID:deriamis,项目名称:pcs,代码行数:29,代码来源:cluster.py


示例18: location_prefer

def location_prefer(argv):
    rsc = argv.pop(0)
    prefer_option = argv.pop(0)

    if prefer_option == "prefers":
        prefer = True
    elif prefer_option == "avoids":
        prefer = False
    else:
        usage.constraint()
        sys.exit(1)


    for nodeconf in argv:
        nodeconf_a = nodeconf.split("=",1)
        if len(nodeconf_a) == 1:
            node = nodeconf_a[0]
            if prefer:
                score = "INFINITY"
            else:
                score = "-INFINITY"
        else:
            score = nodeconf_a[1]
            if not utils.is_score(score):
                utils.err("invalid score '%s', use integer or INFINITY or -INFINITY" % score)
            if not prefer:
                if score[0] == "-":
                    score = score[1:]
                else:
                    score = "-" + score
            node = nodeconf_a[0]
        location_add(["location-" +rsc+"-"+node+"-"+score,rsc,node,score])
开发者ID:vincepii,项目名称:pcs,代码行数:32,代码来源:constraint.py


示例19: full_status

def full_status():
    if "--full" in utils.pcs_options:
        (output, retval) = utils.run(["crm_mon", "-1", "-r", "-R", "-A", "-f"])
    else:
        (output, retval) = utils.run(["crm_mon", "-1", "-r"])

    if (retval != 0):
        utils.err("cluster is not currently running on this node")

    if not utils.usefile or "--corosync_conf" in utils.pcs_options:
        cluster_name = utils.getClusterName()
        print "Cluster name: %s" % cluster_name

    if utils.stonithCheck():
        print("WARNING: no stonith devices and stonith-enabled is not false")

    if utils.corosyncPacemakerNodeCheck():
        print("WARNING: corosync and pacemaker node names do not match (IPs used in setup?)")

    print output

    if not utils.usefile:
        if not utils.is_rhel6():
            print "PCSD Status:"
            cluster.cluster_gui_status([],True)
            print ""
        utils.serviceStatus("  ")
开发者ID:disco-stu,项目名称:pcs,代码行数:27,代码来源:status.py


示例20: set_add_resource_sets

def set_add_resource_sets(elem, sets, cib):
    allowed_options = {
        "sequential": ("true", "false"),
        "require-all": ("true", "false"),
        "action" : ("start", "promote", "demote", "stop"),
        "role" : ("Stopped", "Started", "Master", "Slave"),
    }

    for o_set in sets:
        set_id = "pcs_rsc_set"
        res_set = ET.SubElement(elem,"resource_set")
        for opts in o_set:
            if opts.find("=") != -1:
                key,val = opts.split("=")
                if key not in allowed_options:
                    utils.err(
                        "invalid option '%s', allowed options are: %s"
                        % (key, ", ".join(allowed_options.keys()))
                    )
                if val not in allowed_options[key]:
                    utils.err(
                        "invalid value '%s' of option '%s', allowed values are: %s"
                        % (val, key, ", ".join(allowed_options[key]))
                    )
                res_set.set(key,val)
            else:
                se = ET.SubElement(res_set,"resource_ref")
                se.set("id",opts)
                set_id = set_id + "_" + opts
        res_set.set("id", utils.find_unique_id(cib,set_id))
开发者ID:vincepii,项目名称:pcs,代码行数:30,代码来源:constraint.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.error函数代码示例发布时间:2022-05-26
下一篇:
Python utils.eq_contents函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap