File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 3
3
import peewee_async
4
4
import os .path
5
5
import geoip2 .database
6
+ import logging
7
+
8
+ log = logging .getLogger ("proxy_py/main" )
6
9
7
10
raw_db = peewee_async .PooledPostgresqlDatabase (
8
11
* settings .DATABASE_CONNECTION_ARGS ,
@@ -60,7 +63,7 @@ def get_raw_protocol(self):
60
63
61
64
@property
62
65
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 ):
64
67
reader = geoip2 .database .Reader (settings .GEOLITE2_CITY_FILE_LOCATION )
65
68
response = reader .city (domain )
66
69
@@ -70,13 +73,13 @@ def location(self):
70
73
'country_code' : response .country .iso_code ,
71
74
'country' : response .country .name ,
72
75
'city' : response .city .name ,
73
- }
76
+ }
74
77
else :
75
- print ('ff' )
76
78
'''
77
79
DB doesn`t exists
78
80
'''
79
- return {}
81
+ log .warning ("Public IP Database has been absent" )
82
+ return None
80
83
81
84
@property
82
85
def address (self ):
You can’t perform that action at this time.
0 commit comments