예제 #1
0
파일: recipe.py 프로젝트: ananelson/ado
    def latest(self, conn=None):
        """
        Returns most recent DoingRecipe point available.
        """
        if not conn:
            conn = self.conn

        sql = "select * from %s where recipe_id = %s ORDER BY started_at DESC LIMIT 1"
        rows = conn.execute(sql % (DoingRecipe.table_name(), self.id))
        row = rows.fetchone()
        if row:
            return DoingRecipe.load(conn, row)
예제 #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)
예제 #3
0
 def doings(self):
     return DoingRecipe.all(conn())