Skip to content

Commit

Permalink
feat: more improvements; error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Dec 31, 2023
1 parent 4bfd99e commit af9027f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"files.associations": {
"CNAME": "plaintext",
"*.yml": "yml",
},
"files.insertFinalNewline": true,
"editor.formatOnSave": true,
Expand Down
18 changes: 15 additions & 3 deletions bereal/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ def make_video(token: str, phone: str, year: str, song_path: str, mode: Mode) ->

# TODO(michaelfromyeg): implement better error handling, everywhere
logger.info("Creating images for %s...", video_file)
image_folder = create_images(phone, year)
try:
image_folder = create_images(phone, year)
except Exception as e:
logger.error("Failed to create images: %s", e)
raise e

logger.info("Creating video %s from %s...", video_file, image_folder)
build_slideshow(phone, year, image_folder, song_path, video_file, mode)
try:
build_slideshow(phone, year, image_folder, song_path, video_file, mode)
except Exception as e:
logger.error("Failed to build slideshow: %s", e)
raise e

logger.info("Cleaning up images")
cleanup_images(phone, year)
try:
cleanup_images(phone, year)
except Exception as e:
logger.error("Failed to clean up images: %s", e)
pass

logger.info("Returning %s...", video_file)
return video_file
9 changes: 8 additions & 1 deletion bereal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ def step(idx: int, retval: dict[str, Any] | None) -> dict[str, Any] | None:
short_token = retval["token"][:10]
video_file = f"{short_token}-{retval['phone']}-{retval['year']}.mp4"

build_slideshow(retval["image_folder"], retval["song_path"], video_file, retval["mode"])
build_slideshow(
phone=retval["phone"],
year=retval["year"],
image_folder=retval["image_folder"],
song_path=retval["song_path"],
filename=video_file,
mode=retval["mode"],
)

# TODO(michaelfromyeg): delete images in production
cleanup_images(retval["phone"], retval["year"])
Expand Down
File renamed without changes.

0 comments on commit af9027f

Please sign in to comment.