-2

I have coded a discord bot using my Windows 11 computer, with python 3.12.3.

Searching for a hosting way, a friend shared me her private server running RetroPi project.

When running my code on my computer, it works fine and fetches the image with the good colors. But the problem is that when i run it on the server, the images aren't working properly cause the colors are mismatched. see images below:

good colors: The one with the good colors,

bad colors The one with the bad colors

At first i thought it was because the discord versions were not the same (3.9 on the server), so i asked my friend to update, what she did but now with 3.12.3 on both sides, the colors aren't working neither.

The color fetching is made by this function which i think is the problem but i'm not sure :

class EnumColorPixelya:

    ENUM = []

    @staticmethod
    def getColors(canvas):
        colors = canvas['colors']
        for i, color in enumerate(colors):
            EnumColorPixelya.ENUM.append(Color(i, tuple(color)))
    
    @staticmethod
    def index(i):
        for color in EnumColorPixelya.ENUM:
            if i == color.index:
                return color
        return EnumColorPixelya.ENUM[0]

I have no idea how to fix this as this is working on one device and not on the other one, so it's not a python error properly talking.

Here is my Github Repo with the code, the cog is areaDownload.py.

4
  • Are you using the same library version in your host and your local machine? The only thing I could think of is the host using a different PIL version.. Commented Aug 25, 2024 at 12:29
  • Oooh no indeed i'm using Pillow 10.3 on Windows and Pillow 10.4 on Linux. As i downloaded both in a short period of time i didn't thought about it ! let me try to downgrade server pillow to 10.3 Commented Aug 25, 2024 at 13:33
  • Well that was not the problem, still the same errors... Commented Aug 25, 2024 at 13:44
  • Well i installed WSL to make some tests and it appears that the error doesn't appear on the original code, and it appears on my edited version of the code made to run with discord.py. Thus the error doesn't only come from the version used but also with my modifications. Commented Aug 25, 2024 at 15:41

1 Answer 1

-1

I changed the EnumColorPixelya function from using the list and indice() function to a dictionary and it works perfectly.

here is the new function :

class OwnEnumColor :
    Colors : dict[int, str]  = {}

    @staticmethod
    def getColors(canvas):
        colors = canvas['colors']
        for i, color in enumerate(colors):
            OwnEnumColor.Colors[i] = Color(i, tuple(color))

I guess Enum doesn't work on Linux...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.