I has a little problem with date comparison. Function check DB for domain and time, if domain not found, then execute code and insert into DB. If domain and date exist, then check if date is older than 24 hours and execute function.
DB entry looks like:
domain inform_date
pl23.hostex.lt 1426690221
Function is:
### Inform function
def information( domain ):
inform_timelimit = now - (inform_time*3600)
cur.execute("SELECT inform_date FROM php_inform_date WHERE `domain` = %s", (domain))
time_send = cur.fetchone()
if time_send == None:
cur.execute("REPLACE INTO php_inform_date VALUES (%s, %s)", (domain, now))
(...)
if inform_timelimit > time_send[0]:
cur.execute("REPLACE INTO php_inform_date VALUES (%s, %s)", (domain, now))
(...)
Variable timelimit is unixtime:
now = int(time.time())
inform_timelimit = now - (24*3600)
Error that I get, when domain is found:
Traceback (most recent call last):
File "/opt/php-secure-sendmail/secure_sendmail.py", line 84, in <module>
information(domain)
File "/opt/php-secure-sendmail/secure_sendmail.py", line 41, in information
if inform_timelimit > time_send[0]:
TypeError: 'NoneType' object is unsubscriptable
PS. sorry for my poor english ;)
Aucun commentaire:
Enregistrer un commentaire