Skip to content

Commit 536ef6a

Browse files
author
Stewerio De Santo
committed
add errors logging
1 parent 81efb97 commit 536ef6a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import peewee_async
44
import os.path
55
import geoip2.database
6+
import logging
7+
8+
log = logging.getLogger("proxy_py/main")
69

710
raw_db = peewee_async.PooledPostgresqlDatabase(
811
*settings.DATABASE_CONNECTION_ARGS,
@@ -60,7 +63,7 @@ def get_raw_protocol(self):
6063

6164
@property
6265
def location(self):
63-
if os.path.exists(settings.GEOLITE2_CITY_FILE_LOCATION) and os.path.isfile(settings.GEOLITE2_CITY_FILE_LOCATION):
66+
if os.path.isfile(settings.GEOLITE2_CITY_FILE_LOCATION):
6467
reader = geoip2.database.Reader(settings.GEOLITE2_CITY_FILE_LOCATION)
6568
response = reader.city(domain)
6669

@@ -70,13 +73,13 @@ def location(self):
7073
'country_code': response.country.iso_code,
7174
'country': response.country.name,
7275
'city': response.city.name,
73-
}
76+
}
7477
else:
75-
print('ff')
7678
'''
7779
DB doesn`t exists
7880
'''
79-
return {}
81+
log.warning("Public IP Database has been absent")
82+
return None
8083

8184
@property
8285
def address(self):

0 commit comments

Comments
 (0)