askpass.py 772 B

1234567891011121314151617181920212223242526272829303132333435
  1. """DataLad GUI password entry helper"""
  2. __docformat__ = 'restructuredtext'
  3. import logging
  4. import sys
  5. from datalad.interface.base import Interface
  6. from datalad.interface.base import build_doc
  7. lgr = logging.getLogger('datalad.ext.gooey.askpass')
  8. @build_doc
  9. class GooeyAskPass(Interface):
  10. """Internal helper for datalad-gooey"""
  11. @staticmethod
  12. def __call__():
  13. # internal import to keep unconditional dependencies low
  14. from PySide6.QtWidgets import (
  15. QApplication,
  16. QInputDialog,
  17. )
  18. QApplication(sys.argv)
  19. cred, ok = QInputDialog.getText(
  20. None,
  21. 'DataLad Gooey',
  22. sys.argv[1],
  23. )
  24. if not ok:
  25. sys.exit(2)
  26. sys.stdout.write(cred)