Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getImage(self, url):
imagehash = hashlib.md5(url.encode('utf-8')).hexdigest()
if settings.STATIC_ROOT is None:
filepath = settings.STATICFILES_DIRS[0] + "webimg/" + imagehash + ".png"
else:
filepath = settings.STATIC_ROOT + "webimg/" + imagehash + ".png"
path = "static/webimg/" + imagehash + ".png"
options = {
'quiet': '',
'xvfb': '',
}
if not os.path.exists(filepath):
try:
imgkit.from_url(url, filepath, options=options)
except Exception as e:
logger.error(e)
return
return path