populate.py 555 B

123456789101112131415161718192021222324252627282930
  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. m.create_tables()
  8. u = m.User.get_or_none(name="gdritter")
  9. if not u:
  10. u = m.User.from_request(
  11. r.User(
  12. name="gdritter",
  13. password=os.getenv("PASSWORD", "behest").strip(),
  14. )
  15. )
  16. u.set_as_admin()
  17. c.log(f"created user {u.name}")
  18. with open("scripts/aisamanra.json") as f:
  19. u.import_pinboard_data(f)
  20. if __name__ == "__main__":
  21. main()