예제 #1
0
파일: __init__.py 프로젝트: ananelson/ado
def update_command(t=-1, p=-1, n=-1, r=-1, **kwargs):
    """
    Update a project, task or note with the supplied kwargs.
    """
    c = conn()
    if t > 0:
        Task.update(c, t, kwargs)
    elif n > 0:
        Note.update(c, n, kwargs)
    elif p > 0:
        Project.update(c, p, kwargs)
    elif r > 0:
        Recipe.update(c, r, kwargs)
    else:
        raise Exception("Must specify one of t (task), n (note), p (project) or r (recipe).")
예제 #2
0
파일: status.py 프로젝트: ananelson/ado
def due_command():
    c = ado.commands.conn()
    for survey in Survey.all_due(c):
        take_survey(survey.id)
    for metric in Metric.all_due(c):
        record_metric(metric.id)
    for recipe in Recipe.all_due(c):
        ado.commands.recipe.do_command(recipe.id)
예제 #3
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
예제 #4
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)
예제 #5
0
파일: status.py 프로젝트: ananelson/ado
def ok_command(debug=False):
    c = ado.commands.conn()
    surveys_due = bool(Survey.all_due(c))
    metrics_due = bool(Metric.all_due(c))
    recipes_due = bool(Recipe.all_due(c))

    if debug:
        print "Are surveys due?", surveys_due
        print "Are metrics due?", metrics_due
        print "Are recipes due?", recipes_due

    ok = (not surveys_due) and (not metrics_due) and (not recipes_due)
    if ok:
        if debug:
            print "nothing is due"
        sys.exit(0)
    else:
        print "something is due"
        sys.exit(1)
예제 #6
0
파일: recipe.py 프로젝트: ananelson/ado
def recipe_command():
    """
    Create a new recipe with steps.
    """
    c = ado.commands.conn()
    created_at = datetime.now()

    print "Creating a new recipe."

    Portfolio.printall(c)
    portfolio_id = int(ado.commands.clean_input("Enter portfolio id: "))

    # Verify portfolio choice.
    portfolio = Portfolio.get(c, portfolio_id)
    print "You chose portfolio %s - %s" % (portfolio.id, portfolio.name)

    name = ado.commands.clean_input("Enter short name for recipe: ")
    print "Name set to '%s'" % name
    description = ado.commands.clean_input("Description of recipe: ")
    print "Description set to '%s'" % description
    print "Describe each step in the recipe you wish to define."
    step = 0
    steps = []
    while True:
        step += 1
        step_text = ado.commands.clean_input("Step %s: " % step)
        if step_text:
            steps.append(step_text)
            print "Processing step text '%s'" % step_text
        else:
            print "done! %s steps recorded." % len(steps)
            break

    print "How often should you do this recipe (e.g. 1w (1 week), 1d (1 day), 12h (12 hours), 30m (30 minutes)"
    raw_frequency = ado.commands.clean_input("> ")
    if raw_frequency:
        frequency = raw_frequency
        print "This recipe should be done every %s days" % frequency
    else:
        frequency = "None"
        print "No specified frequency."

    context = ado.commands.clean_input("Context (where you can do this): ")
    recipe = Recipe.create(
            c,
            context=context,
            created_at=created_at,
            description=description,
            frequency=frequency,
            name=name,
            portfolio_id=portfolio_id
            )

    print "Created recipe", recipe.id
    for step_text in steps:
        step = Step.create(
                c,
                created_at=created_at,
                recipe_id = recipe.id,
                description = step_text
                )
        print "Created step id %s" % step.id
예제 #7
0
파일: portfolio.py 프로젝트: ananelson/ado
 def recipes(self, conn=None):
     if not conn:
         conn = self.conn
     sql = "select * from %s where portfolio_id = ?" % Recipe.table_name()
     return [Recipe.load(conn, row) for row in conn.execute(sql, [self.id])]
예제 #8
0
 def recipes(self):
     return Recipe.all(conn())