コード例 #1
0
ファイル: new-release.py プロジェクト: fangohr/nmag-src
what_ver = plan.add_choice(OpenQuestion("What version do you want to use?"))
what_ver.when_should_ask(lambda: rel_kind.chosen == 3)

def problem_in_answer(ans):
    try:
        Version().from_str(ans)
        return None
    except:
        return ("Bad version. Should be something like X.Y.Z, "
                "where X, Y and Z are three integers")
what_ver.answer_checker(problem_in_answer)

#=============================================================================
# Ask the user to take decision and take note of the answers
script = Script()
plan.ask_user(script)

def confirm(s="", ask_anyway=False):
    if ask_anyway:
        print s
        print "PRESS [RETURN] TO CONTINUE...",
        raw_input()

if rel_kind.chosen == 3:
    new_version = Version().from_str(what_ver.answer)

else:
    new_version = v.next(["patch", "minor", "major"][rel_kind.chosen])

pkgname = "nsim-%s" % new_version
maintag = str(new_version)
コード例 #2
0
ファイル: distmake-builder.py プロジェクト: anyint/nmag-src
want_tarb.add_alternative(
    Alternative("Give me just the corresponding directory."))
want_tarb.add_alternative(Alternative("Give me both."))

final = plan.add_choice(
    Choice("I collected enough information. What should I do:"))
final.add_alternative(Alternative("Create the distribution file(s)"))
final.add_alternative(
    Alternative("Generate a bash script to create the "
                "distribution file"))
final.add_alternative(Alternative("Do both things"))

#=============================================================================
# Ask the user to take decision and take note of the answers
script = Script()
plan.ask_user(script)

#=============================================================================
# Consider the answer and build the script
script.writeln("# Automatically generated using %s" % version)
script.writeln("# Script generated from the following answers:")
script.writeln(comment(str(plan)))
script.writeln(". disttools.sh")

# Use the user-provided username, if necessary
if use_def_un.chosen == 1:
    username = what_un.answer

want_local_main = (want_ctr.chosen == 1)
local_main = "`cd .. && pwd`" if want_local_main else None