populate.py 575 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python3
  2. import os
  3. import lc.config as c
  4. import lc.model as m
  5. import lc.request as r
  6. def main():
  7. c.app.init_db()
  8. m.create_tables()
  9. u = m.User.get_or_none(name="gdritter")
  10. if not u:
  11. u = m.User.from_request(
  12. r.User(
  13. name="gdritter",
  14. password=os.getenv("PASSWORD", "behest").strip(),
  15. )
  16. )
  17. u.set_as_admin()
  18. c.log(f"created user {u.name}")
  19. with open("scripts/aisamanra.json") as f:
  20. u.import_pinboard_data(f)
  21. if __name__ == "__main__":
  22. main()