Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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