Weird python problem
#1
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?
Reply
#2
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?
Reply
#3
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
Reply
#4
(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?
Reply
#5
I've used this one: http://forum.xbmc.org/showthread.php?tid...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.
Reply
#6
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)))
Reply

Logout Mark Read Team Forum Stats Members Help
Weird python problem0