[VISION] Made vision not mandatory

This commit is contained in:
Alexis LEBEL
2023-03-31 16:10:13 +02:00
parent 09ee32c8b6
commit bd1fa13924

View File

@@ -7,10 +7,17 @@ from config import debug
from google.cloud import vision from google.cloud import vision
# Instantiates a client # Instantiates a client
client = vision.ImageAnnotatorClient() try:
client = vision.ImageAnnotatorClient()
except:
debug("Google Vision API is not setup, please run /setup")
async def process(attachment): async def process(attachment):
if not os.path.exists("./../database/google-vision"):
debug("Google Vision API is not setup, please run /setup")
return
debug("Processing image...") debug("Processing image...")
image = vision.Image() image = vision.Image()
image.source.image_uri = attachment.url image.source.image_uri = attachment.url