• 1
  • 8
  • 9
  • 10(current)
  • 11
  • 12
  • 15
Release script.colorbox
(2017-09-03, 16:57)Luke Cage Wrote: @badaas
I believe that you introduced a new error in version 2.0.4.5.
Version 2.0.4.5 debug log : https://pastebin.com/sqB5eVv7

Which bit?
There might be an occasional error on initial start up due to not all resources being loaded, but it shouldn't break anything.
Where it says 'NOTICE: script.colorbox' that means I caught the error, so no real harm.

Code:
16:47:09.232 T:139626425607936  NOTICE: script.colorbox: daemon started
16:47:09.234 T:139626425607936  NOTICE: script.colorbox: no colors.txt yet
...
16:47:09.261 T:139625197008640  NOTICE: script.colorbox: no colors.txt yet
...
16:47:09.263 T:139625197008640  NOTICE: script.colorbox: co: [Errno 2] No such file or directory: '/home/lukecage/.kodi/userdata/addon_data/script.colorbox/d22a2d328f04d3217431174921a38325.png' img: /home/lukecage/.kodi/userdata/addon_data/script.colorbox/d22a2d328f04d3217431174921a38325.png

I've put a new version with slightly better error handling, and spotted a bug as well.

2.0.4.6 @ https://github.com/BADMS/script.colorbox
Reply
(2017-09-04, 18:06)badaas Wrote:
(2017-09-03, 16:57)Luke Cage Wrote: @badaas
I believe that you introduced a new error in version 2.0.4.5.
Version 2.0.4.5 debug log : https://pastebin.com/sqB5eVv7

Which bit?
There might be an occasional error on initial start up due to not all resources being loaded, but it shouldn't break anything.
Where it says 'NOTICE: script.colorbox' that means I caught the error, so no real harm.

Code:
16:47:09.232 T:139626425607936  NOTICE: script.colorbox: daemon started
16:47:09.234 T:139626425607936  NOTICE: script.colorbox: no colors.txt yet
...
16:47:09.261 T:139625197008640  NOTICE: script.colorbox: no colors.txt yet
...
16:47:09.263 T:139625197008640  NOTICE: script.colorbox: co: [Errno 2] No such file or directory: '/home/lukecage/.kodi/userdata/addon_data/script.colorbox/d22a2d328f04d3217431174921a38325.png' img: /home/lukecage/.kodi/userdata/addon_data/script.colorbox/d22a2d328f04d3217431174921a38325.png

I've put a new version with slightly better error handling, and spotted a bug as well.

2.0.4.6 @ https://github.com/BADMS/script.colorbox

This "bit" :
Code:
16:47:09.273 T:139625197008640   ERROR: Exception in thread Thread-1:
                                            Traceback (most recent call last):
                                              File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
                                                self.run()
                                              File "/usr/lib/python2.7/threading.py", line 754, in run
                                                self.__target(*self.__args, **self.__kwargs)
                                              File "/home/lukecage/.kodi/addons/script.colorbox/resources/lib/Utils.py", line 648, in Color_Only
                                                img.thumbnail((200, 200))
                                            UnboundLocalError: local variable 'img' referenced before assignment

The error which you fixed by adding the return statements so that code execution wouldn't continue with processing the img.* methods.
Github highlights your changes in green (additions) in this commit : https://github.com/BADMS/script.colorbox...041cee8fec
A more elegant resolution would have been : try except else.
Reply
(2017-09-04, 21:22)Luke Cage Wrote: A more elegant resolution would have been : try except else.

Hmm, then where do I get the data to pass to closing ops below?

I could put the else code, but I'd still need to return after the error, as I cannot have any data for when I fall into ops below. Or I rewrite with double the code in favour of *neatness*.

That is how I see it, if I have missed something blatantly obvious then please say Wink


This is the block of code:

Code:
*

    if md5 not in colors_dict:
        filename = md5 + ".png"
        targetfile = os.path.join(ADDON_DATA_PATH, filename)
        Img = Check_XBMC_Internal(targetfile, filterimage)
        if not Img: return "", ""
        try:
            img = Image.open(Img)
        except Exception as e:
            log("co: %s img: %s" % (e,filterimage))
            return "", ""
        img.thumbnail((200, 200))
        img = img.convert('RGB')
        maincolor, cmaincolor = Get_Colors(img, md5)
    else:
        maincolor, cmaincolor = colors_dict[md5].split(':')
    Black_White(maincolor, cname)
    cimagecolor = Color_Modify(maincolor, cmaincolor, color_comp)
    imagecolor = Color_Modify(maincolor, cmaincolor, color_main)
    tmc = Thread(target=linear_gradient, args=(cname, HOME.getProperty(var3)[2:8], imagecolor[2:8], lgsteps, lgint, var3))
    tmc.start()
    tmcc = Thread(target=linear_gradient, args=(ccname, HOME.getProperty(var4)[2:8], cimagecolor[2:8], lgsteps, lgint, var4))
    tmcc.start()
    #linear_gradient(cname, HOME.getProperty(var3)[2:8], imagecolor[2:8], 50, 10, var3)
    #linear_gradient(ccname, HOME.getProperty(var4)[2:8], cimagecolor[2:8], 50, 10, var4)
    return imagecolor, cimagecolor
Reply
EDIT: I forgot to add this. Don't fix/change it if it ain't broken. I just said that it would be more elegant.

What I meant with that is this.
Every "try except" statement where you added the "return" statements would get the optional "else" clause (after the last "except" of each "try except" statement). The code in the "else" clause would only be executed if the "try" was successful.
In the "else" clause you would stick all code that depends on what's tested in the "try" clause. In this case anything using "img".

So in the block of code that you quoted :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
img.thumbnail((200, 200))
img = img.convert('RGB')
maincolor, cmaincolor = Get_Colors(img, md5)

becomes this :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
else:
    img.thumbnail((200, 200))
    img = img.convert('RGB')
    maincolor, cmaincolor = Get_Colors(img, md5)

If the return was removed like before, or if anything went wrong in the "try" clause, none of the (in this case) 3 lines of code following the else clause would have been reached.
Reply
(2017-09-05, 19:34)Luke Cage Wrote: EDIT: I forgot to add this. Don't fix/change it if it ain't broken. I just said that it would be more elegant.

What I meant with that is this.
Every "try except" statement where you added the "return" statements would get the optional "else" clause (after the last "except" of each "try except" statement). The code in the "else" clause would only be executed if the "try" was successful.
In the "else" clause you would stick all code that depends on what's tested in the "try" clause. In this case anything using "img".

So in the block of code that you quoted :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
img.thumbnail((200, 200))
img = img.convert('RGB')
maincolor, cmaincolor = Get_Colors(img, md5)

becomes this :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
else:
    img.thumbnail((200, 200))
    img = img.convert('RGB')
    maincolor, cmaincolor = Get_Colors(img, md5)

If the return was removed like before, or if anything went wrong in the "try" clause, none of the (in this case) 3 lines of code following the else clause would have been reached.

Yes, I see using the else for completeness in the case of those 3 lines, but I still need to return (exit) either way, as the code below will continue to run with missing vars 'maincolor, cmaincolor'. I might make some speed with the else on those 3 lines, but am too tired to test, hehe.
I hope that makes sense, it's been a long day Smile
And thanks for your input, I didn't know about the else clause for try, so have learned something Big Grin (coming from a cpp background and using catch!).
Reply
(2017-09-06, 17:54)badaas Wrote:
(2017-09-05, 19:34)Luke Cage Wrote: EDIT: I forgot to add this. Don't fix/change it if it ain't broken. I just said that it would be more elegant.

What I meant with that is this.
Every "try except" statement where you added the "return" statements would get the optional "else" clause (after the last "except" of each "try except" statement). The code in the "else" clause would only be executed if the "try" was successful.
In the "else" clause you would stick all code that depends on what's tested in the "try" clause. In this case anything using "img".

So in the block of code that you quoted :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
img.thumbnail((200, 200))
img = img.convert('RGB')
maincolor, cmaincolor = Get_Colors(img, md5)

becomes this :

Code:
try:
    img = Image.open(Img)
except Exception as e:
    log("co: %s img: %s" % (e,filterimage))
    return "", ""
else:
    img.thumbnail((200, 200))
    img = img.convert('RGB')
    maincolor, cmaincolor = Get_Colors(img, md5)

If the return was removed like before, or if anything went wrong in the "try" clause, none of the (in this case) 3 lines of code following the else clause would have been reached.

Yes, I see using the else for completeness in the case of those 3 lines, but I still need to return (exit) either way, as the code below will continue to run with missing vars 'maincolor, cmaincolor'. I might make some speed with the else on those 3 lines, but am too tired to test, hehe.
I hope that makes sense, it's been a long day Smile
And thanks for your input, I didn't know about the else clause for try, so have learned something Big Grin (coming from a cpp background and using catch!).

I never said that you should remove the return statements. Leaving the return statements out initially, was an error in your program logic.

And maincolor and cmaincolor will never be missing, if you give maincolor and cmaincolor sensible defaults, like you do now in the else clause of the 2 if statements. Line 656 and line : 682
If you remove those 2 else clauses and move the statement that was in the else clause to right before the if statement, and substitute something for md5 (a special initialistation value in colors_dict), maincolor and cmaincolor would always have a sensible default value.
Instead of leaving them undefined like you do now. I hope that makes sense.
I have a background in C, C++, Ruby, and Python. But I'm not interested in coding in Ruby and Python anymore. Especially not in Ruby.
Reply
Yeah tbh, introducing the error catching has forced a side effect, so have reverted to crashing on github version until I get time.
Problem with sensible values, it will cause flashing in the colors, as it reverts to defaults (which is side effect of bad programming initially in default.py).

I need to work out some catches for initial calling of this op, as atm its a bit rushed !!

Thanks again for input Smile

Bring back TCL! Wink
Reply
@badaas
Yes I agree, finding the time for a refactor is always the issue. Wink
Regression testing.
Reply
v2.0.5 is awaiting approval in Kodi repo

* better error handling
* saturate, desaturate, angle tone + more fx
* colors.txt now colors.db (will force remake of data so can delete old or leave)
* quality setting affects all fx now
* filenaming convention changed to force recache of images due to new ops and above quality change
* chaining of fx possible; use a '-' between fx names
* in the mymultis new var to override quality (leave blank or set to 0 to use existing setting)


NOTE: blend var is set from 0-100 now
Reply
I think a name change is in order - script.photoshop Wink Rofl

Great work on the latest changes.
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
(2017-09-09, 08:20)jurialmunkey Wrote: I think a name change is in order - script.photoshop Wink Rofl

Great work on the latest changes.

I second that... I haven't played with it in a while but dude is brilliant with this.... need to add screenshots to the addon as well showing off what it does.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
Thanks all, I made a bit of a hash of error checking, it is fixed in kodi repo awaiting approval or use version in my repo [script.colorbox 2.0.5] @ https://github.com/BADMS/repository.BADM...-1.0.0.zip

The current on my GitHub is 2.0.5.1, but that changes the daemon updating property usage, so dont use 2.0.5.1 for now (or check adonic in my repo for changes). Version in kodi repo, daemon updating will be same as pre 2.0.5.1


Never straight forward ... Tongue
Reply
I am looking to have just my background image follow the color of poster, album cover, add image, ect that is currently selected within my lists. The entire skin uses the same background image and I am looking for some help pointing me in the right direction with this. Any help would be much appreciated.
Reply
(2017-10-20, 04:36)ekim232 Wrote: I am looking to have just my background image follow the color of poster, album cover, add image, ect that is currently selected within my lists.  The entire skin uses the same background image and I am looking for some help pointing me in the right direction with this. Any help would be much appreciated.

StartUp.xml
Code:
<onload>SetProperty(SEVEN_daemon_set,True,home)</onload>
<onload condition="System.HasAddon(script.colorbox)">RunScript(script.colorbox,daemon=True)</onload>

MyVideoNav.xml (or AddonBrowser.xml, MyMusicNav.xml, Home.xml etc)
Code:
        <control type="multiimage" id="7977">
            <left>-2160</left>
            <imagepath background="true">$VAR[MyPosterImage]</imagepath>
        </control>

Then you will have these propertys filled
PHP Code:
Window(home).Property(ImageColorSEVEN)
Window(home).Property(ImageCColorSEVEN
Reply
(2017-10-20, 14:22)badaas Wrote:
(2017-10-20, 04:36)ekim232 Wrote: I am looking to have just my background image follow the color of poster, album cover, add image, ect that is currently selected within my lists.  The entire skin uses the same background image and I am looking for some help pointing me in the right direction with this. Any help would be much appreciated.

StartUp.xml
Code:
<onload>SetProperty(SEVEN_daemon_set,True,home)</onload>
<onload condition="System.HasAddon(script.colorbox)">RunScript(script.colorbox,daemon=True)</onload>

MyVideoNav.xml (or AddonBrowser.xml, MyMusicNav.xml, Home.xml etc)
Code:
        <control type="multiimage" id="7977">
            <left>-2160</left>
            <imagepath background="true">$VAR[MyPosterImage]</imagepath>
        </control>

Then you will have these propertys filled
PHP Code:
Window(home).Property(ImageColorSEVEN)
Window(home).Property(ImageCColorSEVEN

Thanks for the insight! So what do I put in my image control for my background? I assume a colordiffuse, but not sure how to handle it correctly.
Reply
  • 1
  • 8
  • 9
  • 10(current)
  • 11
  • 12
  • 15

Logout Mark Read Team Forum Stats Members Help
script.colorbox1