0

So basically I have this python kodi which I'm running on Kodi since it's a Kodi addon.

import time 

def checkPassword(path, lock=None):
expdate = "10/07/15"
datenow = time.strftime("%x")

if datenow == expdate:
return 'ERROR'

if not lock:
    folderConfig = os.path.join(path, FOLDERCFG)
    lock = getParam('LOCK', folderConfig)

title  = GETTEXT(30069) % path.rsplit(os.sep, 1)[-1]
unlock = getText(title, hidden=True)

if not unlock:
    return ''

md5   = utils.generateMD5(unlock)
match = md5 == lock

if not match:
    return 'ERROR'

return md5

Basically I have a favourites folder which is locked with password, I want to show an error if the account is expired. I can preset the date from the addon myself like I did in the example, but somehow my addon is giving me an error with this code. Can you tell me what I have wrong? The problem is somewhere in the first 6 lines, since when I remove it, it works, but obviously without the date check.

  • you should use the datetime module. – postelrich Oct 07 '15 at 21:42
  • The addon won't work, and from logs it tells me that I have a syntax error in "if datenow == expdate:" – Jeffrey Spiteri Oct 08 '15 at 06:09
  • fix the code indentation. Use `datetime` objects instead of strings to compare dates. Use [utc time if your local timezone has DST transitions](http://stackoverflow.com/a/26313848/4279). – jfs Oct 08 '15 at 12:19

0 Answers0