Kodi Community Forum

Full Version: PR13814 - discussion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(2018-04-25, 11:56)peak3d Wrote: [ -> ]- arguments passed from kodi to addon are only available in default script, you can not use sys.argv[1] in any submodules.
That breaks tons of stuff and is incompatible with python.
(2018-04-25, 17:25)takoi Wrote: [ -> ]
(2018-04-25, 11:56)peak3d Wrote: [ -> ]- arguments passed from kodi to addon are only available in default script, you can not use sys.argv[1] in any submodules.
That breaks tons of stuff and is incompatible with python.  
> That breaks tons of stuff <-- Yes
> incompatible with python <-- why?

It is no secret that the initial idea of kodi python addon system only reloads the initial file and rest is cached.
Only issue is that is hat not worked so far.

Edit the PR is already 2 days in milhouse builds.
Until now 2 addons are known which fail, most stuff is working (requests in kodinerds forum)
(2018-04-25, 17:36)peak3d Wrote: [ -> ]
(2018-04-25, 17:25)takoi Wrote: [ -> ]
(2018-04-25, 11:56)peak3d Wrote: [ -> ]- arguments passed from kodi to addon are only available in default script, you can not use sys.argv[1] in any submodules.
That breaks tons of stuff and is incompatible with python.    
> That breaks tons of stuff <-- Yes
> incompatible with python <-- why?

It is no secret that the initial idea of kodi python addon system only reloads the initial file and rest is cached.
Only issue is that is hat not worked so far.

Edit the PR is already 2 days in milhouse builds.
Until now 2 addons are known which fail, most stuff is working (requests in kodinerds forum)  
Because the python doc/reference says sys.argv returns "The list of command line arguments passed to a Python script.". If I read what you were saying correctly, it no longer does that. Libraries like xbmcswift and script.module.routing access sys.argv by design, so everything using those would break.
sys.args[#] works totally correct. Its simply not executed anymore / because the module is cached (on files != default.py)

Just to make one thing clear: It's pure python functionality, the caching is python build in functionality and nothing I implemented around it in the PR.

T.b.h I don't understand your real missun currently. Fixing the few broken addons will be less work compared to this discussion here.
If someone wants to access sys.args[#] in a file which was not opend by the python interpreter (and this is ONLY the default one), this is not my fault, really.
Ok, you're right with your assumptions:

- calls to sys.argv[#] will still work, if they are inside the function which is executed.
- what not will work is, if you set a global var on top of your python module script (aka plugin_handle=sys.args[1]) and access this global var in your function.
Reason is that this global part will not be executed on cached modules.

I think this will mke things much easier, right?
Don't see how that's any better. It still breaks the python module system.
(2017-01-04, 18:26)ronie Wrote: [ -> ]Please keep this thread clean. It should be an easy overview for python coders who are updating their addon for Kodi Krypton.
For discussions / feature requests / bugreports, please find (or create) the appropriate thread in the addon development forum.
 
 
thread split.
After giving it some thoughts I agree with @takoi : We should not break the language specification in sake of a questionable optimization. "Questionable" because it's not like we are receiving tons of complaints about plugins being slow to start. And if it happens for some plugins, the reason is always something else, like network latency or costly processing of fetched data to populate list items.