From 11453810e022df4e90179451e43c79174a32119b Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Sun, 7 Nov 2010 12:44:37 +0000 Subject: [PATCH] Use datetime.utcnow() instead of datetime.now() --- py-i2phosts-checker | 2 +- py-i2phosts-fetcher | 4 ++-- py-i2phosts-maint | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/py-i2phosts-checker b/py-i2phosts-checker index f08d950..c509579 100755 --- a/py-i2phosts-checker +++ b/py-i2phosts-checker @@ -84,7 +84,7 @@ for host in all_hosts: continue log.info('alive host: %s', host.name) # update lastseen timestamp - host.last_seen = datetime.datetime.now() + host.last_seen = datetime.datetime.utcnow() host.save() S.close() log.info('check finished') diff --git a/py-i2phosts-fetcher b/py-i2phosts-fetcher index e6eb680..c169a79 100755 --- a/py-i2phosts-fetcher +++ b/py-i2phosts-fetcher @@ -79,7 +79,7 @@ for source in all_sources: elif hasattr(e, 'code'): if e.code == 304: log.info('%s: not modified', source.name) - source.last_success = datetime.datetime.now() + source.last_success = datetime.datetime.utcnow() source.save() else: log.warning('server %s can\'t finish the request, error code: %s', @@ -116,5 +116,5 @@ for source in all_sources: os.remove(tmpfile) log.info('injector output: \n%s', out) # update last_success - source.last_success = datetime.datetime.now() + source.last_success = datetime.datetime.utcnow() source.save() diff --git a/py-i2phosts-maint b/py-i2phosts-maint index 35a162c..9beb5e6 100755 --- a/py-i2phosts-maint +++ b/py-i2phosts-maint @@ -63,7 +63,7 @@ all_hosts = i2phost.objects.all() log.info('starting maintaince') for host in all_hosts: # how long host was added - dl = datetime.datetime.now() - host.date_added + dl = datetime.datetime.utcnow() - host.date_added if host.last_seen == None: # delete external hosts which we never seen after X days of inactivity if host.external == True: @@ -88,7 +88,7 @@ for host in all_hosts: # get current host expiration date from database if host.expires == None: # workaround for situation when we updating expires first time - expires_current = datetime.datetime.now().date() + expires_current = datetime.datetime.utcnow().date() else: expires_current = host.expires # calculate new expiration date @@ -100,7 +100,7 @@ for host in all_hosts: host.expires = expires_new # deactivate if expired min_dl = datetime.timedelta(days=config['activate_min_delay']) - if host.expires < datetime.datetime.now().date(): + if host.expires < datetime.datetime.utcnow().date(): log.info('deactivating %s, reason: expired', host.name) host.activated = False # if not expired and added more than X days ago and approved then activate @@ -109,7 +109,7 @@ for host in all_hosts: host.name, config['activate_min_delay']) host.activated = True # if expired X days ago then delete - dl_e = datetime.datetime.now().date() - host.expires + dl_e = datetime.datetime.utcnow().date() - host.expires if dl_e > datetime.timedelta(days=config['keep_expired']): log.info('deleting %s, reason: expired % days ago', host.name, config['keep_expired'])