Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

gooey.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. """DataLad GUI"""
  2. __docformat__ = 'restructuredtext'
  3. from datalad.interface.base import Interface
  4. from datalad.interface.base import build_doc
  5. from datalad.support.param import Parameter
  6. from datalad.distribution.dataset import datasetmethod
  7. from datalad.interface.utils import eval_results
  8. from datalad.interface.results import get_status_dict
  9. import logging
  10. lgr = logging.getLogger('datalad.ext.gooey.gooey')
  11. import sys
  12. # decoration auto-generates standard help
  13. @build_doc
  14. # all commands must be derived from Interface
  15. class Gooey(Interface):
  16. # first docstring line is used a short description in the cmdline help
  17. # the rest is put in the verbose help and manpage
  18. """DataLad GUI
  19. Long description of arbitrary volume.
  20. """
  21. # usage examples
  22. _examples_ = [
  23. dict(
  24. text=(
  25. "Launch the DataLad Graphical User Interface (GUI, a.k.a Gooey) "
  26. "at the specified location."
  27. ),
  28. code_py="gooey(path='path/to/root/explorer/directory')",
  29. code_cmd="datalad gooey --path 'path/to/root/explorer/directory'",
  30. ),
  31. ]
  32. # parameters of the command, must be exhaustive
  33. _params_ = dict(
  34. # name of the parameter, must match argument name
  35. path=Parameter(
  36. # cmdline argument definitions, incl aliases
  37. args=("-p", "--path"),
  38. # documentation
  39. doc="""The root location from which the Gooey file explorer will be
  40. launched (default is current working directory)""",
  41. ),
  42. postinstall=Parameter(
  43. args=("--postinstall",),
  44. doc="Perform post-installation tasks",
  45. action="store_true",
  46. # default=False,
  47. ),
  48. )
  49. @staticmethod
  50. # decorator binds the command to the Dataset class as a method
  51. @datasetmethod(name='gooey')
  52. # generic handling of command results (logging, rendering, filtering, ...)
  53. @eval_results
  54. # signature must match parameter list above
  55. # additional generic arguments are added by decorators
  56. def __call__(path: str = None, postinstall: bool = False):
  57. # local import to keep entrypoint import independent of PySide
  58. # availability
  59. from .app import GooeyApp, QApplication
  60. # if requested, perform post-install tasks and exit
  61. if postinstall:
  62. # prevent top-level import of Qt stuff
  63. from .postinstall import perform_post_install_tasks
  64. perform_post_install_tasks()
  65. return
  66. qtapp = QApplication(sys.argv)
  67. gooey = GooeyApp(path)
  68. gooey.main_window.show()
  69. # capture Qt's own exit code for error reporting
  70. qt_exitcode = qtapp.exec()
  71. # tell the app to undo its modifications (UI redirection etc.)
  72. gooey.deinit()
  73. yield get_status_dict(
  74. action='gooey',
  75. path=str(gooey.rootpath),
  76. status='ok' if not qt_exitcode else 'error',
  77. # no message when everything was OK
  78. message='Qt UI errored ' if qt_exitcode else None)