add a mode to update country codes of all known IPs
This commit is contained in:
parent
40ddd264fb
commit
f0e6f2d6da
|
@ -165,6 +165,11 @@ class RespoDB:
|
||||||
execution.completed = completed
|
execution.completed = completed
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
def all_ips(self):
|
||||||
|
assert self._conn is not None
|
||||||
|
addresses = self._conn.find(TAddress)
|
||||||
|
return [addr.str for addr in addresses]
|
||||||
|
|
||||||
def next_record_id(self):
|
def next_record_id(self):
|
||||||
from storm.expr import Add, Max, Coalesce
|
from storm.expr import Add, Max, Coalesce
|
||||||
expr = Add(Coalesce(Max(TRecord.record_id), 0), 1)
|
expr = Add(Coalesce(Max(TRecord.record_id), 0), 1)
|
||||||
|
|
|
@ -265,6 +265,14 @@ async def main(db, filepaths, checks, opts: Options):
|
||||||
async for ip in reader:
|
async for ip in reader:
|
||||||
await process(ip, reader.total)
|
await process(ip, reader.total)
|
||||||
|
|
||||||
|
if seen == 0:
|
||||||
|
# no IPs were provided. refresh all the country codes instead.
|
||||||
|
all_ips = db.all_ips()
|
||||||
|
for i, ip in enumerate(all_ips):
|
||||||
|
if opts.progress:
|
||||||
|
print(f"#{i + 1}/{len(all_ips)}: {ip}", file=stderr)
|
||||||
|
await opts.ips.put(ip)
|
||||||
|
|
||||||
await pooler()
|
await pooler()
|
||||||
await syncing
|
await syncing
|
||||||
await opts.ips.put(None) # end of queue
|
await opts.ips.put(None) # end of queue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user