예제 #1
0
파일: main.py 프로젝트: HideoYamauchi/crmsh
def render_prompt(context):
    rendered_prompt = constants.prompt
    if options.interactive and not options.batch:
        # TODO: fix how color interacts with readline,
        # seems the color prompt messes it up
        promptstr = "crm(%s)%s# " % (cib_prompt(), context.prompt())
        constants.prompt = promptstr
        if clidisplay.colors_enabled():
            rendered_prompt = term.render(clidisplay.prompt(promptstr))
        else:
            rendered_prompt = promptstr
    return rendered_prompt
예제 #2
0
파일: main.py 프로젝트: lge/crmsh
def render_prompt(context):
    rendered_prompt = constants.prompt
    if options.interactive and not options.batch:
        # TODO: fix how color interacts with readline,
        # seems the color prompt messes it up
        promptstr = "crm(%s)%s# " % (cib_prompt(), context.prompt())
        constants.prompt = promptstr
        if clidisplay.colors_enabled():
            rendered_prompt = term.render(clidisplay.prompt(promptstr))
        else:
            rendered_prompt = promptstr
    return rendered_prompt
예제 #3
0
파일: ui_configure.py 프로젝트: lge/crmsh
 def help(cls, topic, helptxt):
     if cls.lasttopic == topic and \
             time.time() - cls.laststamp < cls.timeout:
         return
     if helptxt:
         import readline
         cmdline = readline.get_line_buffer()
         print "\n%s" % helptxt
         if clidisplay.colors_enabled():
             print "%s%s" % (term.render(clidisplay.prompt_noreadline(constants.prompt)),
                             cmdline),
         else:
             print "%s%s" % (constants.prompt, cmdline),
         cls.laststamp = time.time()
         cls.lasttopic = topic
예제 #4
0
 def help(cls, topic, helptxt):
     if cls.lasttopic == topic and \
             time.time() - cls.laststamp < cls.timeout:
         return
     if helptxt:
         import readline
         cmdline = readline.get_line_buffer()
         print "\n%s" % helptxt
         if clidisplay.colors_enabled():
             print "%s%s" % (term.render(
                 clidisplay.prompt_noreadline(constants.prompt)), cmdline),
         else:
             print "%s%s" % (constants.prompt, cmdline),
         cls.laststamp = time.time()
         cls.lasttopic = topic
예제 #5
0
def print_node(uname, id, node_type, other, inst_attr, offline):
    """
    Try to pretty print a node from the cib. Sth like:
    uname(id): node_type
        attr1=v1
        attr2=v2
    """
    s_offline = offline and "(offline)" or ""
    if not node_type:
        node_type = "normal"
    if uname == id:
        print term.render("%s: %s%s" % (uname, node_type, s_offline))
    else:
        print term.render("%s(%s): %s%s" % (uname, id, node_type, s_offline))
    for a in other:
        print term.render("\t%s: %s" % (a, other[a]))
    for s in inst_attr:
        print term.render("\t%s" % (s))
예제 #6
0
def print_node(uname, id, node_type, other, inst_attr, offline):
    """
    Try to pretty print a node from the cib. Sth like:
    uname(id): node_type
        attr1=v1
        attr2=v2
    """
    s_offline = offline and "(offline)" or ""
    if not node_type:
        node_type = "normal"
    if uname == id:
        print term.render("%s: %s%s" % (uname, node_type, s_offline))
    else:
        print term.render("%s(%s): %s%s" % (uname, id, node_type, s_offline))
    for a in other:
        print term.render("\t%s: %s" % (a, other[a]))
    for s in inst_attr:
        print term.render("\t%s" % (s))
예제 #7
0
파일: utils.py 프로젝트: lge/crmsh
def term_render(s):
    'Render for TERM.'
    try:
        return term.render(s)
    except:
        return s
예제 #8
0
def term_render(s):
    'Render for TERM.'
    try:
        return term.render(s)
    except:
        return s
예제 #9
0
파일: main.py 프로젝트: ingted/clusterLab
            usage(2)

    if options.interactive and not options.batch:
        context.setup_readline()

    rc = 0
    while True:
        try:
            rendered_prompt = constants.prompt
            if options.interactive and not options.batch:
                # TODO: fix how color interacts with readline,
                # seems the color prompt messes it up
                promptstr = "crm(%s)%s# " % (cib_prompt(), context.prompt())
                constants.prompt = promptstr
                if clidisplay.colors_enabled():
                    rendered_prompt = term.render(clidisplay.prompt(promptstr))
                else:
                    rendered_prompt = promptstr
            inp = utils.multi_input(rendered_prompt)
            if inp is None:
                if options.interactive:
                    rc = 0
                context.quit(rc)
            try:
                if not context.run(inp):
                    rc = 1
            except ValueError, msg:
                rc = 1
                common_err(msg)
        except KeyboardInterrupt:
            if options.interactive and not options.batch: