mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 03:58:45 +00:00
Adjust ipcachewrite to account for region addition
This commit is contained in:
parent
c7d3b32d53
commit
2ebdb15398
1 changed files with 7 additions and 2 deletions
|
@ -90,10 +90,15 @@ def geolocator(location):
|
|||
|
||||
|
||||
def ipcachewrite(ip_addr, location):
|
||||
cached = os.path.join(IP2LCACHE, ip_addr)
|
||||
""" Write a retrieved ip+location into cache
|
||||
Can stress some filesystems after long term use, see
|
||||
https://stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory
|
||||
"""
|
||||
cachefile = os.path.join(IP2LCACHE, ip_addr)
|
||||
if not os.path.exists(IP2LCACHE):
|
||||
os.makedirs(IP2LCACHE)
|
||||
with open(cached, 'w') as file:
|
||||
|
||||
with open(cachefile, 'w') as file:
|
||||
file.write(location[0] + ';' + location[1] + ';' + location[2])
|
||||
# like ip2location format, but reversed
|
||||
|
||||
|
|
Loading…
Reference in a new issue