|
@@ -1,5 +1,6 @@
|
|
|
import os
|
|
|
import subprocess
|
|
|
+import shutil
|
|
|
from typing import Optional
|
|
|
from fastapi import FastAPI, UploadFile, HTTPException
|
|
|
from fastapi.responses import JSONResponse, FileResponse
|
|
@@ -67,8 +68,13 @@ async def convert_eps_to_svg(file: UploadFile):
|
|
|
|
|
|
subprocess.run(['eps2svg', input_path, temp_svg], check=True)
|
|
|
|
|
|
-
|
|
|
- subprocess.run(['scour', '-i', temp_svg, '-o', final_svg], check=True)
|
|
|
+
|
|
|
+ try:
|
|
|
+ subprocess.run(['scour', '-i', temp_svg, '-o', final_svg], check=True)
|
|
|
+ except subprocess.CalledProcessError:
|
|
|
+
|
|
|
+ shutil.copy(temp_svg, final_svg)
|
|
|
+ print("Scour optimization failed, using unoptimized SVG")
|
|
|
|
|
|
|
|
|
obs_client = get_obs_client()
|
|
@@ -95,4 +101,4 @@ async def convert_eps_to_svg(file: UploadFile):
|
|
|
|
|
|
@app.get("/health")
|
|
|
def health_check():
|
|
|
- return {"status": "healthy"}
|
|
|
+ return {"status": "healthy"}
|