コード例 #1
0
ファイル: __init__.py プロジェクト: ananelson/ado
def start_command(r=None):
    """
    Start a timer for a recipe.
    """
    c = conn()
    recipe = Recipe.get(c, r)
    recipe_id = recipe.id
    print recipe.recipe
    task = Task.create(
        c, name="Doing Recipe %s (%s)" % (recipe_id, recipe.name), recipe_id=recipe_id, context=recipe.context
    )
    time_command(task.id)
    print "Created task %s and started timer" % task.id
コード例 #2
0
ファイル: recipe.py プロジェクト: ananelson/ado
def do_command(r=False):
    """
    Do a recipe.
    """
    c = ado.commands.conn()
    if not r:
        Recipe.printall(c)
        raw_r = ado.commands.clean_input("Choose a recipe number: ")
        if raw_r:
            r = int(raw_r)
        else:
            sys.stderr.write("No recipe chosen.\n")
            sys.exit(1)

    print "You chose recipe '%s'" % r
    recipe = Recipe.get(c, r)
    print recipe.description

    doing = DoingRecipe.create(
            c,
            started_at = datetime.now(),
            recipe_id=recipe.id)

    for i, step in enumerate(recipe.steps()):
        started_at = datetime.now()
        print "Step %s) %s" % (i+1, step.description)
        description = ado.commands.clean_input("notes> ")
        completed_at = datetime.now()
        elapsed = completed_at - started_at
        print "Completed Step %s in %s" % (i+1, elapsed)
        DoingStep.create(c,
                started_at = started_at,
                completed_at = completed_at,
                step_description = step.description,
                description = description,
                step_id = step.id,
                doing_recipe_id = doing.id)