def ai_upload_icon(id): ai = AI.query.get(id) if ai: cache.delete_memoized(ai_icon, id) return upload_single_file(request, "AIs/"+str(id)+"/icon.png", image=True) else: return CommonErrors.INVALID_ID
def ai_upload_icon(id): ai = AI.query.get(id) if ai: cache.delete_memoized(ai_icon, id) return upload_single_file(request, "AIs/" + str(id) + "/icon.png", image=True) else: return CommonErrors.INVALID_ID
def api_ai_reset_icon(id): ai = AI.query.get(id) if ai: cache.delete_memoized(ai_icon, id) @ftp.safe def f(): path = "AIs/"+str(id)+"/icon.png" if not ftp.ftp_host.path.isfile(path): return {"error": "No custom Icon"}, 400 ftp.ftp_host.remove(path) return {"error": False}, 200 try: return f() except ftp.err: return CommonErrors.FTP_ERROR else: return CommonErrors.INVALID_ID
def api_ai_reset_icon(id): ai = AI.query.get(id) if ai: cache.delete_memoized(ai_icon, id) @ftp.safe def f(): path = "AIs/" + str(id) + "/icon.png" if not ftp.ftp_host.path.isfile(path): return {"error": "No custom Icon"}, 400 ftp.ftp_host.remove(path) return {"error": False}, 200 try: return f() except ftp.err: return CommonErrors.FTP_ERROR else: return CommonErrors.INVALID_ID