Kodi Community Forum
Weird python problem - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Weird python problem (/showthread.php?tid=203759)



Weird python problem - Pr0ph3cyTiger - 2014-09-06

Hi all,

I'm having a problem with the python, I'm running the code as it works fine without have any problem. When I close the skin window to return to the main menu and when I reopen them to run the code again, I will get an error to something like this:

Code:
TypeError: attribute of type 'NoneType' is not callable


The error are jumping on this line:

Code:
program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")



Here is the code:

Code:
import time
import _strptime

#get the programs list
cur.execute('SELECT channel, title, start_date, stop_date FROM programs WHERE channel="channel"')
programList = list()
programs = cur.fetchall()


for row in programs:
      program = row[1].encode('ascii'), str(row[2]), str(row[3])
      program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")
      program_endDate = datetime.datetime.strptime(str(row[3]), "%Y%m%d%H%M%S")

      # find nearest half hour
      viewStartDate = datetime.datetime.today()
      viewStartDate -= datetime.timedelta(minutes = viewStartDate.minute % 30, seconds = viewStartDate.second)



It sound like to me the python will need to be update?


RE: Weird python problem - Karnagious - 2014-09-06

1. Why not post the entire script?
2. list() is a builtin python function. Are you trying to create an empty list?
3. Why dont you print row to the log so you can see what is being returned?


RE: Weird python problem - learningit - 2014-09-06

I ran into this previously, drove me nuts. There are a couple of fixes described in this thread:
http://forum.xbmc.org/showthread.php?tid=112916


RE: Weird python problem - Pr0ph3cyTiger - 2014-09-06

(2014-09-06, 17:05)learningit Wrote: I ran into this previously, drove me nuts. There are a couple of fixes described in this thread:
http://forum.xbmc.org/showthread.php?tid=112916

Thank you, can you tell me in which post that i can get the fixes?


RE: Weird python problem - learningit - 2014-09-06

I've used this one: http://forum.xbmc.org/showthread.php?tid=112916&pid=1212394#pid1212394 in the past. The simplified version in the post following that one also worked - though it's been a while since I've used them.


RE: Weird python problem - vitorcarvalhoml - 2014-09-09

This error appear when you deactivate and then activate the addon.
Solution (without read the whole thread) but I suggest you read it any way..

Code:
        try:
            self.startDateTime = datetime.strptime( startDateTime, DATETIME_MASK )
        except Exception:
            # WORKAROUND: solução para bug que quando desabilitava e habilitava o addon novamente
            # o programa não conseguia gerar a data corretamente
            # ver thread: http://forum.xbmc.org/showthread.php?tid=112916
            self.startDateTime = datetime.fromtimestamp(time.mktime(time.strptime(startDateTime, DATETIME_MASK)))