def post(self): print "TEST1 HANDLER" try: test_drink = manual_db.TEST_DRINK controller.EnqueueGroup(actions_for_recipe(test_drink)) except ValueError: self.response.status = 400 self.response.write("valve and oz arguments are required.")
def post(self): name = self.request.get('name') if name: for drink in manual_db.db: if drink.name.lower() == name.lower(): self.response.write("Making drink %s" % drink) controller.EnqueueGroup(actions_for_recipe(drink)) return elif self.request.get('random') == 'bubbly sour': controller.EnqueueGroup(actions_for_recipe(RandomBubblySourDrink())) elif self.request.get('random') == 'bubbly boozy': controller.EnqueueGroup(actions_for_recipe(RandomBubblySpirituousDrink())) elif self.request.get('random') == 'sour': controller.EnqueueGroup(actions_for_recipe(RandomSourDrink())) elif self.request.get('random') == 'boozy': controller.EnqueueGroup(actions_for_recipe(RandomSpirituousDrink())) self.response.status = 400
def post(self): controller.EnqueueGroup(actions_for_recipe(manual_db.Recipe( name='Prime', ingredients=[ manual_db.Ingredient( #manual_db.Oz(.725), ingredient) manual_db.Oz(.2), ingredient) for ingredient in ingredients.IngredientsOrdered()[:] if ingredient != "air" ], #for ingredient in ingredients.IngredientsOrdered() if "itters" in ingredient], user_name="dev console")))
def main(robot): ingredients = [] for name in INGREDIENTS_ORDERED: if name in BITTERS: ingredients.append(Ingredient(Oz(1), name)) recipe = Recipe('prime-bitters', ingredients) print recipe for action in actions_for_recipe(recipe): print action action(robot)
def post(self): try: recipe_obj = json.loads(self.request.get('recipe')) recipe = recipe_from_json_object(recipe_obj) print "Drink requested: %s", recipe controller.EnqueueGroup(actions_for_recipe(recipe)) self.response.status = 200 self.response.write("ok") except ValueError: print 'Error parsing custom drink request: %s' % ( self.request.get('recipe', None)) traceback.print_exc() self.response.status = 400 self.response.write("valve and oz arguments are required.")
def run(self): last_drink_id = None while True: try: queue = json.loads(self.get('next_drink')) if not self.controller and queue: json_recipe = queue[0] drink_id = json_recipe['id'] if drink_id == last_drink_id: print "Refusing to remake order %s" % last_drink_id time.sleep(20) # Sleep extra long continue # Don't make the same drink twice last_drink_id = drink_id next_recipe = water_down_recipe(Recipe.from_json(json_recipe)) raw_actions = actions_for_recipe(next_recipe) actions = [] for i, action in enumerate(raw_actions): progress = 10 + 90 * i / len(raw_actions) actions.append(UpdateProgressAction(self, drink_id, progress)) actions.append(action) actions.append(FinishDrinkAction(self, drink_id)) self.controller.EnqueueGroup(actions) else: actions = self.controller.InspectQueue() if actions: logging.info("Current action: %s", actions[0]) if (isinstance(actions[0], (WaitForGlassRemoval, WaitForGlassPlaced)) and isinstance(self.controller.robot, FakeRobot)): logging.info("Placing glass") actions[0].force = True self.write(queue) except urllib2.URLError, e: logging.warning("URLError: %s", e) except ValueError, e: print e