def get(self, path): self._connect() try: data, stat = self.zk.get(path) return data.decode("utf-8") except NoNodeError: raise KeyError("%s does not exist." % path) except Exception as e: Log.error(e.__class__) Log.error(e)
def _get_ingredient_primary_category(ingredient): category_mappings = IngredientCategoryMappingModel.query.filter( IngredientCategoryMappingModel.ingredient_id == ingredient.id) # print([mapping.category_id for mapping in category_mappings]) # exit() for category_id in [ result.category_id for result in category_mappings ]: category = IngredientCategoryModel.query.get(category_id) if category.position and category.position >= 5: return category.display_name Log.error("Could not find category for %s" % ingredient.canonical_name)
def delete(cocktail_object): try: indexables = CocktailFactory.obj_to_index(cocktail_object, RecipeIndex) for indexable in indexables: try: RecipeIndex.delete(indexable) except NotFoundError: Log.warning("No cache entry found for %s" % indexable) except KeyError as e: # Since this is a DELETE situation we don't particularly care to correct # the problem, but if we're creating or some other thing that could be # more problematic. Log.error("Recipe has bad data: %s" % e)
def get_recipes(): # character_list = list(range(0, 10)) + list(string.ascii_uppercase) character_list = string.ascii_uppercase[2:3] raw_recipes = [] for char in character_list: # print(UpneatConnector._get_recipes_alpha(char)) slugs = UpneatConnector._get_recipes_alpha(char) for slug in slugs: try: raw_recipes.append(UpneatConnector.scrape_recipe(slug)) except: Log.error("ERROR WITH %s " % slug) return raw_recipes
def fail(self, message): Log.error(message) if self.fatal: raise ValidationException(message)