eylles / pywal16

16 colors fork of pywal
MIT License
157 stars 24 forks source link

After updating it via AUR #48

Closed niksingh710 closed 3 months ago

niksingh710 commented 3 months ago
󰘧 walset
[I] image: Using image wallhaven-x67oxo.png.
[I] colors: Generating a colorscheme.
[I] colors: Using wal backend.
Traceback (most recent call last):
  File "/usr/bin/wal", line 33, in <module>
    sys.exit(load_entry_point('pywal16==3.5.3', 'console_scripts', 'wal')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pywal/__main__.py", line 244, in main
    parse_args(parser)
  File "/usr/lib/python3.12/site-packages/pywal/__main__.py", line 184, in parse_args
    colors_plain = colors.get(image_file, args.l, args.cols16, args.backend,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pywal/colors.py", line 213, in get
    colors = getattr(backend, "get")(img, light, cols16)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pywal/backends/wal.py", line 77, in get
    colors = gen_colors(img)
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pywal/backends/wal.py", line 64, in gen_colors
    return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
niksingh710 commented 3 months ago

if i am using haishoku backend then there is no error but color generated is too bad

CapybaraWarrior commented 3 months ago

I am getting a similar error when trying to install with yay on artix

`> Generate a colorscheme. ... Generating a colorscheme. Using wal backend. ERROR test_gen_colors_checksum (tests.test_colors.TestGenColors.test_gen_colors_checksum)

Generate a colorscheme with the wallpaper's checksum ... Generating a colorscheme. Using wal backend. ERROR

====================================================================== ERROR: test_gen_colors (tests.test_colors.TestGenColors.test_gen_colors)

Generate a colorscheme.

Traceback (most recent call last): File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/tests/test_colors.py", line 13, in test_gen_colors result = colors.get("tests/test_files/test.jpg") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/colors.py", line 213, in get colors = getattr(backend, "get")(img, light, cols16) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/backends/wal.py", line 77, in get colors = gen_colors(img) ^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/backends/wal.py", line 64, in gen_colors return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'group'

====================================================================== ERROR: test_gen_colors_checksum (tests.test_colors.TestGenColors.test_gen_colors_checksum)

Generate a colorscheme with the wallpaper's checksum

Traceback (most recent call last): File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/tests/test_colors.py", line 38, in test_gen_colors_checksum result = colors.get("tests/test_files/test.jpg") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/colors.py", line 213, in get colors = getattr(backend, "get")(img, light, cols16) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/backends/wal.py", line 77, in get colors = gen_colors(img) ^^^^^^^^^^^^^^^ File "/home/theuser/.cache/yay/pywal-16-colors/src/pywal16/pywal/backends/wal.py", line 64, in gen_colors return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'group'


Ran 31 tests in 0.086s

FAILED (errors=2) Test failed: error: Test failed: ==> ERROR: A failure occurred in check(). Aborting... -> error making: pywal-16-colors-exit status 4 -> Failed to install the following packages. Manual intervention is required: pywal-16-colors - exit status 4`

Foxap commented 3 months ago

Same issue here , but I did not install it with the AUR , I used the pipx command to install pywal16 . It's exactly the same error . I also had to copy the wal file in the sbin directory .

niksingh710 commented 3 months ago

@eylles check this issue once

eylles commented 3 months ago

So weird, according to that the regular expression search return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] is not getting any match for the group #.{6} which would be a # followed by any 6 chars.

What is the output of running convert or magick convert with the following options convert <image> -resize 25% -colors 16 -unique-colors txt:-

I know arch should be on imagemagick 7 but no idea if it does already ship with the new policy to not allow writing to std out.

To change the policy run: sudo sed -i 's/\(<policy domain="path" rights="\)none\(" pattern="-"\/>\)/\1write\2/' /etc/ImageMagick-7/policy.xml

If that does nothing i'll work on this tomorrow, but it won't be an easy matter since i'm on devuan testing and need to do upgrade packages next month.

BEST8OY commented 3 months ago

What is the output of running

[best8oy@DIAMOND ~D/Others]$ convert RE4wB6A.jpeg -resize 25% -colors 16 -unique-colors txt:-
WARNING: The convert command is deprecated in IMv7, use "magick"

# ImageMagick pixel enumeration: 16,1,0,255,srgb
0,0: (23,12,10)  #170C0A  srgb(8.83685%,4.80871%,3.91507%)
1,0: (43,21,17)  #2B1511  srgb(17.0109%,8.3123%,6.70867%)
2,0: (53,35,31)  #35231F  srgb(20.9737%,13.9064%,12.1332%)
3,0: (76,26,17)  #4C1A11  srgb(29.6628%,10.2075%,6.83256%)
4,0: (108,27,20)  #6C1B14  srgb(42.3927%,10.5717%,7.73431%)
5,0: (79,36,26)  #4F241A  srgb(30.8095%,14.2853%,10.1747%)
6,0: (110,39,23)  #6E2717  srgb(43.1309%,15.3532%,9.09638%)
7,0: (78,44,39)  #4E2C27  srgb(30.7096%,17.2736%,15.1228%)
8,0: (109,49,41)  #6D3129  srgb(42.8787%,19.2912%,16.1005%)
9,0: (115,68,50)  #734432  srgb(45.1903%,26.7326%,19.7637%)
10,0: (156,46,27)  #9C2E1B  srgb(61.0645%,17.9774%,10.4099%)
11,0: (225,49,24)  #E13118  srgb(88.3114%,19.0796%,9.48198%)
12,0: (173,70,32)  #AD4620  srgb(67.8712%,27.588%,12.3556%)
13,0: (241,81,25)  #F15119  srgb(94.5589%,31.9382%,9.68763%)
14,0: (254,160,57)  #FEA039  srgb(99.5443%,62.8207%,22.3196%)
15,0: (253,194,135)  #FDC287  srgb(99.3849%,75.925%,52.9908%)

Changing policy didn't help!

eylles commented 3 months ago

I see... welp, will have to look if something changed on the latest python version shipped on arch, or write a new regex search.

eylles commented 3 months ago

Dumb question, does this also happen with dylan's pywal? be it 3.3.0 or pywal-git? That way at least i'd know if it was sonething i changed or is something that pywal has been dragging for years waiting to implode.

CapybaraWarrior commented 3 months ago

Just tried it and those 2 do not give an error when installing

eylles commented 3 months ago

@CapybaraWarrior do either of those give the runtime error with the traceback to:

return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
CapybaraWarrior commented 3 months ago

You mean python-pywal and pywal-git? They install fine with yay and work without any error. Sorry, I should have said that they install and work without error instead of just that they install.

eylles commented 3 months ago

You mean python-pywal and pywal-git? They install fine with yay and work without any error. Sorry, I should have said that they install and work without error instead of just that they install.

Just for completeness sake, you installed either python-pywal or pywal-git from the aur, ran wal -c to erase current colorschemes and then ran wal -i image and the program generated a colorscheme without errors? Both should reply with 3.3.0 when you run wal -v

It is very important as there have been 7 changes to backends/wal.py since pywal's 3.3.0 to pywal16's 3.5.3, and since this is an arch specific (it seems, as no other distro has suffered from this yet) it helps to know at which commit does it begin to happen.

And no, i don't mean the aur install bug, that is something that should be reported to the aur maintainer, i mean the runtime traceback error as that is also reported by users instally the pypi package.

CapybaraWarrior commented 3 months ago

I tried it again with the options you mentioned and python-pywal gave no errors when I gave it an image and it worked, -v said 3.3.0 and then I ran -c and removed python-pywal and installed pywal-git. For python-git -v said 3.3.1 but it worked as well and there was this: [I] colors: Using wal backend. WARNING: The convert command is deprecated in IMv7, use "magick"

But otherwise no diffreence

eylles commented 3 months ago

I tried it again with the options you mentioned and python-pywal gave no errors when I gave it an image and it worked, -v said 3.3.0 and then I ran -c and removed python-pywal and installed pywal-git. For python-git -v said 3.3.1 but it worked as well and there was this: [I] colors: Using wal backend. WARNING: The convert command is deprecated in IMv7, use "magick"

But otherwise no diffreence

Great, that DOES help a lot, just as a question, you can do clone the repo and do a pipx install . to install a different branch? Cuz i got an idea of where the runtime error may come from, but cannot push a fix that may not even work to master less alone to a release before testing.

For now while i prepare the branch anyone willing to help please install pipx from your package manager and make sure you uninstalled both pywal and pywal16.

CapybaraWarrior commented 3 months ago

So after testing some releases and installing them with pipx, all work and give no error when producing 9 colors but when I used --cols16 on version 3.5.3 I got this:

raceback (most recent call last): File "/home/theuser/.local/bin/wal", line 8, in sys.exit(main()) ^^^^^^ File "/home/theuser/.local/share/pipx/venvs/pywal16/lib/python3.12/site-packages/pywal/main.py", line 244, in main parse_args(parser) File "/home/theuser/.local/share/pipx/venvs/pywal16/lib/python3.12/site-packages/pywal/main.py", line 184, in parse_args colors_plain = colors.get(image_file, args.l, args.cols16, args.backend, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.local/share/pipx/venvs/pywal16/lib/python3.12/site-packages/pywal/colors.py", line 213, in get colors = getattr(backend, "get")(img, light, cols16) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/theuser/.local/share/pipx/venvs/pywal16/lib/python3.12/site-packages/pywal/backends/wal.py", line 77, in get colors = gen_colors(img) ^^^^^^^^^^^^^^^ File "/home/theuser/.local/share/pipx/venvs/pywal16/lib/python3.12/site-packages/pywal/backends/wal.py", line 64, in gen_colors return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'group'

CapybaraWarrior commented 3 months ago

Using version 3.5.2 works perfectly after installing with pipx

eylles commented 3 months ago

Thanks, now at least i know it was a change in 3.5.3 that caused this, give me some mins and i will have a branch to test.

DerTyp7214 commented 3 months ago

Hotfix if anyone wants it: in /usr/lib/python3.12/site-packages/pywal/backends/wal.py remove convert arg from magick and it works (if you have imagemagick 7+)

eylles commented 3 months ago

okay, before merging anything to master i need to know that this branch fixes the issue https://github.com/eylles/pywal16/tree/arch-fix

i think the correct command with pipx is pipx install git+https://github.com/eylles/pywal16.git@arch-fix to skip the whole clone, checkout branch and running pipx install .

DerTyp7214 commented 3 months ago

Seems to work image

eylles commented 3 months ago

nice, to speak about the solution.

def try_gen_in_range(img, magick_command):
    for i in range(0, 20, 1):
        raw_colors = imagemagick(16 + i, img, magick_command)

        if len(raw_colors) > 16:
            break

        if i == 19:
            logging.error("Imagemagick couldn't generate a suitable palette.")
            sys.exit(1)

        else:
            logging.warning("Imagemagick couldn't generate a palette.")
            logging.warning("Trying a larger palette size %s", 16 + i)
    return raw_colors

def gen_colors(img):
    """Format the output from imagemagick into a list
       of hex colors."""
    magick_command = has_im()

    raw_colors = try_gen_in_range(img, magick_command)

    try:
        out = [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
    except AttributeError:
        if magick_command == ["magick", "convert"]:
            logging.warning("magick convert failed, using only magick")
            magick_command = ["magick"]
            raw_colors = try_gen_in_range(img, magick_command)
            out = [re.search("#.{6}",
                             str(col)).group(0) for col in raw_colors[1:]]

    return out

had to move the generation of colors in a for loop for continuous large palettes into it's own function.

used a try except to catch the attribute error from the regex to then try the magick command without the "convert" part.

the idea is this won't affect distros that do got imagemagick 7 but is an older version than what arch ships so it will just work on those.

niksingh710 commented 3 months ago

Does aur have any -git version? If not then when this will be merged in tagged release?

eylles commented 3 months ago

well, i want to address not just this but also #31 and hopefully #49 as part of 3.5.4, if not i will only do #31 and take care of #49 for 3.6.0 which will entice the okthief backend from #47 and being able to separate the 16 color schemes in ones generated with the lighten or the darken method.

eylles commented 3 months ago

as everyone can see, i marked everything else as a milestone for 3.6.0 and released 3.5.4, please feel free to flood the aur maintainer for the latest release version.

if anyone wonders, yes constant email spam and flood is one of the reasons dylan's email is still the one publically associated with pywal16, but the main reason is i am lazy.