cnf-update-db 684 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/python3
  2. import glob
  3. import logging
  4. import os
  5. import sys
  6. from CommandNotFound.db.creator import DbCreator
  7. from CommandNotFound import CommandNotFound
  8. if __name__ == "__main__":
  9. if "--debug" in sys.argv[1:]:
  10. logging.basicConfig(level=logging.DEBUG)
  11. elif "--verbose" in sys.argv[1:]:
  12. logging.basicConfig(level=logging.INFO)
  13. db = CommandNotFound.dbpath
  14. if not os.access(os.path.dirname(db), os.W_OK):
  15. print("datbase directory %s not writable" % db)
  16. sys.exit(0)
  17. command_files = glob.glob("/var/lib/apt/lists/*Commands-*")
  18. if len(command_files) > 0:
  19. col = DbCreator(command_files)
  20. col.create(db)