예제 #1
0
def attemptLoadAvatar(username):
    try:
        __linker = DBManager(user='******', password='******')
        imageAsString = _encode64DecodeUTF8Image(
            __linker.fetchUserAvatar(username))
        return {
            'success': True,
            'message': "Avatar loaded successfully.",
            'parameters': {
                'avatar': imageAsString
            }
        }
    except Exception as db_except:
        return {
            'success': False,
            'message': str(db_except),
            'parameters': None
        }
    finally:
        del __linker
예제 #2
0
def attemptReplaceAvatar(username, avatar):
    try:
        __linker = DBManager(user='******', password='******')
        hasAvatar = __linker.fetchUserAvatar(username)
        if hasAvatar is not None:
            __linker.updateUserAvatar(
                username, avatar
            ) if avatar is not None else __linker.removeUserAvatar(username)
        else:
            __linker.addUserAvatar(username,
                                   avatar) if avatar is not None else None
        return {
            'success': True,
            'message': "Avatar updated successfully.",
            'parameters': None
        }
    except Exception as db_except:
        return {
            'success': False,
            'message': str(db_except),
            'parameters': None
        }
    finally:
        del __linker