eulaurarien/feed_dns.py

44 lines
1.1 KiB
Python
Raw Normal View History

#!/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()