mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
remove bar exceptions
This commit is contained in:
parent
fa14c1f24b
commit
c7256d7212
15 changed files with 23 additions and 23 deletions
|
@ -44,7 +44,7 @@ def export_database(data: BackupJob, session: Session = Depends(generate_session
|
||||||
export_groups=data.options.groups,
|
export_groups=data.options.groups,
|
||||||
)
|
)
|
||||||
return {"export_path": export_path}
|
return {"export_path": export_path}
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
|
raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,5 +95,5 @@ def delete_backup(file_name: str):
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
try:
|
try:
|
||||||
file_path.unlink()
|
file_path.unlink()
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
|
raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||||
|
|
|
@ -39,7 +39,7 @@ async def create_group(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.groups.create(session, group_data.dict())
|
db.groups.create(session, group_data.dict())
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def update_meal_plan(
|
||||||
processed_plan = MealPlanInDB(uid=plan_id, **processed_plan.dict())
|
processed_plan = MealPlanInDB(uid=plan_id, **processed_plan.dict())
|
||||||
try:
|
try:
|
||||||
db.meals.update(session, plan_id, processed_plan.dict())
|
db.meals.update(session, plan_id, processed_plan.dict())
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ def delete_meal_plan(plan_id, session: Session = Depends(generate_session), curr
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.meals.delete(session, plan_id)
|
db.meals.delete(session, plan_id)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ async def create_recipe_category(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return db.categories.create(session, category.dict())
|
return db.categories.create(session, category.dict())
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ async def update_recipe_category(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return db.categories.update(session, category, new_category.dict())
|
return db.categories.update(session, category, new_category.dict())
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,5 +66,5 @@ async def delete_recipe_category(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.categories.delete(session, category)
|
db.categories.delete(session, category)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -97,7 +97,7 @@ def delete_recipe(
|
||||||
try:
|
try:
|
||||||
db.recipes.delete(session, recipe_slug)
|
db.recipes.delete(session, recipe_slug)
|
||||||
delete_image(recipe_slug)
|
delete_image(recipe_slug)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,5 +56,5 @@ async def delete_recipe_tag(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.tags.delete(session, tag)
|
db.tags.delete(session, tag)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -43,5 +43,5 @@ def delete_theme(theme_name: str, session: Session = Depends(generate_session),
|
||||||
""" Deletes theme from the database """
|
""" Deletes theme from the database """
|
||||||
try:
|
try:
|
||||||
db.themes.delete(session, theme_name)
|
db.themes.delete(session, theme_name)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -107,7 +107,7 @@ async def update_user_image(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
[x.unlink() for x in app_dirs.USER_DIR.join(id).glob("profile_image.*")]
|
[x.unlink() for x in app_dirs.USER_DIR.join(id).glob("profile_image.*")]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
dest = app_dirs.USER_DIR.joinpath(id, f"profile_image.{extension}")
|
dest = app_dirs.USER_DIR.joinpath(id, f"profile_image.{extension}")
|
||||||
|
@ -152,5 +152,5 @@ async def delete_user(
|
||||||
if current_user.id == id or current_user.admin:
|
if current_user.id == id or current_user.admin:
|
||||||
try:
|
try:
|
||||||
db.users.delete(session, id)
|
db.users.delete(session, id)
|
||||||
except:
|
except Exception:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
raise HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ExportDatabase:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.templates = [app_dirs.TEMPLATE_DIR.joinpath(x) for x in templates]
|
self.templates = [app_dirs.TEMPLATE_DIR.joinpath(x) for x in templates]
|
||||||
except:
|
except Exception:
|
||||||
self.templates = False
|
self.templates = False
|
||||||
logger.info("No Jinja2 Templates Registered for Export")
|
logger.info("No Jinja2 Templates Registered for Export")
|
||||||
|
|
||||||
|
|
|
@ -84,20 +84,20 @@ class ImportDatabase:
|
||||||
try:
|
try:
|
||||||
del recipe_dict["_id"]
|
del recipe_dict["_id"]
|
||||||
del recipe_dict["date_added"]
|
del recipe_dict["date_added"]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
# Migration from list to Object Type Data
|
# Migration from list to Object Type Data
|
||||||
try:
|
try:
|
||||||
if "" in recipe_dict["tags"]:
|
if "" in recipe_dict["tags"]:
|
||||||
recipe_dict["tags"] = [tag for tag in recipe_dict["tags"] if tag != ""]
|
recipe_dict["tags"] = [tag for tag in recipe_dict["tags"] if tag != ""]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if "" in recipe_dict["categories"]:
|
if "" in recipe_dict["categories"]:
|
||||||
recipe_dict["categories"] = [cat for cat in recipe_dict["categories"] if cat != ""]
|
recipe_dict["categories"] = [cat for cat in recipe_dict["categories"] if cat != ""]
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if type(recipe_dict["extras"]) == list:
|
if type(recipe_dict["extras"]) == list:
|
||||||
|
|
|
@ -54,7 +54,7 @@ def rename_image(original_slug, new_slug) -> Path:
|
||||||
def write_image(recipe_slug: str, file_data: bytes, extension: str) -> Path:
|
def write_image(recipe_slug: str, file_data: bytes, extension: str) -> Path:
|
||||||
try:
|
try:
|
||||||
delete_image(recipe_slug)
|
delete_image(recipe_slug)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
image_dir = Path(app_dirs.IMG_DIR.joinpath(f"{recipe_slug}"))
|
image_dir = Path(app_dirs.IMG_DIR.joinpath(f"{recipe_slug}"))
|
||||||
|
@ -100,7 +100,7 @@ def scrape_image(image_url: str, slug: str) -> Path:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(image_url, stream=True)
|
r = requests.get(image_url, stream=True)
|
||||||
except:
|
except Exception:
|
||||||
logger.exception("Fatal Image Request Exception")
|
logger.exception("Fatal Image Request Exception")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ def process_meals(session: Session, meal_plan_base: MealPlanIn) -> MealPlanProce
|
||||||
description=recipe.description,
|
description=recipe.description,
|
||||||
)
|
)
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
|
|
||||||
meal_data = MealOut(
|
meal_data = MealOut(
|
||||||
date=meal_plan_base.startDate + timedelta(days=x),
|
date=meal_plan_base.startDate + timedelta(days=x),
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Cleaner:
|
||||||
for step in instructions
|
for step in instructions
|
||||||
if step["type"].find("HowToStep") > -1
|
if step["type"].find("HowToStep") > -1
|
||||||
]
|
]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -21,7 +21,7 @@ def basic_recipe_from_opengraph(html: str, url: str) -> dict:
|
||||||
data = extruct.extract(html, base_url=base_url)
|
data = extruct.extract(html, base_url=base_url)
|
||||||
try:
|
try:
|
||||||
properties = data["opengraph"][0]["properties"]
|
properties = data["opengraph"][0]["properties"]
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -67,7 +67,7 @@ def download_image_for_recipe(recipe: dict) -> dict:
|
||||||
try:
|
try:
|
||||||
img_path = scrape_image(recipe.get("image"), recipe.get("slug"))
|
img_path = scrape_image(recipe.get("image"), recipe.get("slug"))
|
||||||
recipe["image"] = img_path.name
|
recipe["image"] = img_path.name
|
||||||
except:
|
except Exception:
|
||||||
recipe["image"] = "no image"
|
recipe["image"] = "no image"
|
||||||
|
|
||||||
return recipe
|
return recipe
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue