Workflow: Base for new one
While I'm automating this you'll need to download the A set from https://opendata.rapid7.com/sonar.fdns_v2/ to the file a.json.gz.
This commit is contained in:
parent
62e6c9005b
commit
7937496882
6 changed files with 389 additions and 0 deletions
43
feed_dns.py
Executable file
43
feed_dns.py
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import database
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
FUNCTION_MAP = {
|
||||
'a': database.feed_a,
|
||||
'cname': database.feed_cname,
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# Parsing arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
description="TODO")
|
||||
parser.add_argument(
|
||||
'-i', '--input', type=argparse.FileType('r'), default=sys.stdin,
|
||||
help="TODO")
|
||||
args = parser.parse_args()
|
||||
|
||||
database.open_db()
|
||||
|
||||
try:
|
||||
database.time_step('iowait')
|
||||
for line in args.input:
|
||||
database.time_step('feed_json_parse')
|
||||
split = line.split('"')
|
||||
name = split[7]
|
||||
dtype = split[11]
|
||||
value = split[15]
|
||||
# data = json.loads(line)
|
||||
# assert dtype == data['type']
|
||||
# assert name == data['name']
|
||||
# assert value == data['value']
|
||||
database.time_step('feed_switch')
|
||||
FUNCTION_MAP[dtype](name, value)
|
||||
database.time_step('iowait')
|
||||
except KeyboardInterrupt:
|
||||
print("Interupted.")
|
||||
pass
|
||||
|
||||
database.close_db()
|
||||
Loading…
Add table
Add a link
Reference in a new issue