add export cmd

This commit is contained in:
lza_menace 2020-10-21 22:13:20 -07:00
parent 1e65e52e27
commit 44acad3854
1 changed files with 11 additions and 0 deletions

View File

@ -153,6 +153,17 @@ def validate():
logging.info("failed for reasons unknown")
node.delete_instance()
@app.cli.command("export")
def export():
all_nodes = []
export_dir = f"{config.DATA_DIR}/export.txt"
nodes = Node.select().where(Node.validated == True)
for node in nodes:
all_nodes.append(node.url)
with open(export_dir, "w") as f:
f.write("\n".join(all_nodes))
logging.info(f"{nodes.count()} nodes written to {export_dir}")
@app.template_filter("humanize")
def humanize(d):
t = arrow.get(d, "UTC")