robweber / xbmclibraryautoupdate

Kodi Addon to update your video/music libraries on a schedule
MIT License
30 stars 22 forks source link

added urllib2 #55

Closed desigi closed 4 years ago

desigi commented 4 years ago

I'm running your addon on Coreelec (a standalone OS version of Kodi for ARM boards) and I've been getting the following error recently:

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.NameError'>
                                            Error Contents: global name 'urllib2' is not defined
                                            Traceback (most recent call last):
                                              File "/storage/.kodi/addons/service.libraryautoupdate/default.py", line 6, in <module>
                                                AutoUpdater().runProgram()
                                              File "/storage/.kodi/addons/service.libraryautoupdate/service.py", line 63, in runProgram
                                                self.evalSchedules()
                                              File "/storage/.kodi/addons/service.libraryautoupdate/service.py", line 89, in evalSchedules
                                                if(self._networkUp() and (not utils.getSettingBool('check_sources') or (utils.getSettingBool('check_sources') and self._checkSources(cronJob)))):
                                              File "/storage/.kodi/addons/service.libraryautoupdate/service.py", line 378, in _checkSources
                                                if(not self._sourceExists(source['file'])):
                                              File "/storage/.kodi/addons/service.libraryautoupdate/service.py", line 401, in _sourceExists
                                                if not xbmcvfs.exists(urllib2.unquote(aSource)):
                                            NameError: global name 'urllib2' is not defined
                                            -->End of Python script error report<--

Coreelec doesn't allow the installation of anything via a repository such as APT, but adding urllib2 to the service.py file fixed the issue for me. Any chance you could add it?

robweber commented 4 years ago

I can't tell from the log but what version of Kodi and of the addon are you running?

If we go back in time, older versions of this addon did have an import for urllib2. These were replaced with the urllib class from the future library as part of the move to Python3. Python3 doesn't have urllib2, the module was split into 2 different ones. This was to keep both versions compatible for python 2 and python 3. There is an import for the futures library in the addon.xml - is it possible this isn't working (or even available) on your system?

desigi commented 4 years ago

I'm running Coreelec 9.2.2 which incorporates Kodi v18.6. I'm running 1.1.0 of your addon. I read that Kodi still runs with python 2 and only in Kod v19 will they switch to python 3. Since Coreelec (similar to Libreelec) is a minimal OS only for Kodi I can't install python 3 via repository.

I didn't realize your addon used to include urllib2. You might as well leave it as is. I added the line locally and it runs well for me and in the near future v19 will come out with python 3 and all should be fixed.

Thanks for your reply and thanks for making this plugin. It's a must for me to load the new content from my nas.

robweber commented 4 years ago

Thanks for pointing this out. I'm still at a loss why the future import wasn't working correctly for you. It should just be a regular Kodi import. It includes all the cross-compatibility imports (like urllib) needed so this addon will run on both python2 and python3 for the moment. If your fix is working for you I won't dig much further into it unless others start to have the same issues.