Draft
Conversation
24da256 to
53cb97f
Compare
53cb97f to
e9baeba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two new modules for common behavior across all PyMca applications:
PyMca5.PyMcaGui.PyMcaAppInit: common behavior for multiprocessing, Qt, HDF5, matplotlib, logging.Common calls at these stages of the application start-up:
PyMca5.PyMcaMisc.CliUtils: common CLI behavior in terms of logging, common arguments.Uses
argparseinstead ofgetoptwhich provides proper--helpfor users.The docstring of the two modules show the usage pattern.
Currently we have 28 CLI's of which 20 are Qt apps. There are many more files with a
__main__, many of which usingsys.argvdirectly, but I only handled the once that already had a CLI by usinggetoptorargparse.In addition I added unit tests for the CLI:
python -m PyMca5.tests.CliTestMain CLI as an example
pymca --help usage: pymca [-h] [--debug DEBUG] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--version] [--qt {5,6}] [--binding {pyqt5,pyqt6,pyside2,pyside6}] [--backend {matplotlib,mpl,gl,opengl,glut,osmesa,mesa,silx,silx-mpl,silxmpl,silx-gl,silxgl}] [--spec SPEC] [--shm SHM] [--fresh] [--nativefiledialogs NATIVEFILEDIALOGS] [--profiling] [--test] [files ...] Main PyMca GUI positional arguments: files Optional list of data files to open (default: None) options: -h, --help show this help message and exit --debug DEBUG Enable debug mode (default: 0) --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL} Logging level (default: WARNING) --version Show version and exit (default: False) --qt {5,6} Force Qt version (default: None) --binding {pyqt5,pyqt6,pyside2,pyside6} Qt binding (default: None) --backend {matplotlib,mpl,gl,opengl,glut,osmesa,mesa,silx,silx-mpl,silxmpl,silx-gl,silxgl} The plot backend to use: Matplotlib, OpenGL 2.1 (requires appropriate OpenGL drivers), or Off-screen Mesa OpenGL software pipeline (requires OSMesa library). (default: mpl) --spec SPEC Spec file (default: None) --shm SHM Shared memory spec (default: None) --fresh, -f Clear configuration (default: False) --nativefiledialogs NATIVEFILEDIALOGS Use native file dialogs (default: 0) --profiling Run main loop under profiler (default: False) --test Run unit tests (default: False)