Changes Made
1. bin/db-selector-gui (bin/db-selector-gui:30-33)
- Added --gh_mrva_output command-line option
- Default path: ~/work-gh/mrva/gh-mrva/gh-mrva-selection.json
- The path is expanded and passed to the GUI
2. mrvahepc/db_selector_ui.py (mrvahepc/db_selector_ui.py:27-29)
- Modified DatabaseSelector.__init__ to accept gh_mrva_output_path parameter
- Stores the output path as an instance variable
3. mrvahepc/db_selector_ui.py (mrvahepc/db_selector_ui.py:399-423)
- Modified _export_gh_mrva method to:
- Create the parent directory if it doesn't exist
- Write the JSON output to the specified file
- Show appropriate success/error messages
- Still copies to clipboard and shows the popup dialog (backward compatible)
Usage
With default output path:
./bin/db-selector-gui --metadata_db_path db-collection-host.tmp/metadata.sql
When you click "Export GH-MRVA Format" in the UI, it will automatically write to:
~/work-gh/mrva/gh-mrva/gh-mrva-selection.json
With custom output path:
./bin/db-selector-gui \
--metadata_db_path db-collection-host.tmp/metadata.sql \
--gh_mrva_output /custom/path/to/output.json
Updated Workflow, now simplified:
Before:
mkdir -p ~/work-gh/mrva/gh-mrva
cat > ~/work-gh/mrva/gh-mrva/gh-mrva-selection.json <<eof
{
"mirva-list": [...]
}
eof
Now:
./bin/db-selector-gui --metadata_db_path db-collection-host.tmp/metadata.sql
The GUI will automatically create the directory and write the file when you:
1. Apply your filters (e.g., primary language: cpp, project name filter: oo)
2. Click the "Export GH-MRVA Format" button
3. The file is written to ~/work-gh/mrva/gh-mrva/gh-mrva-selection.json
63 lines
2.0 KiB
Python
Executable File
63 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env -S uv run python
|
|
# -*- python -*-
|
|
"""
|
|
Database Selector GUI for MRVA HEPC
|
|
|
|
A Tkinter-based interface for browsing and selecting CodeQL databases
|
|
from the SQLite metadata database created by host-hepc-init.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
from plumbum import cli
|
|
from mrvahepc.db_selector_ui import create_gui
|
|
|
|
|
|
class DatabaseSelectorApp(cli.Application):
|
|
"""
|
|
Launch a GUI for browsing and selecting CodeQL databases from metadata.sql.
|
|
|
|
Provides dropdown filters for all metadata columns and displays matching
|
|
results in a text widget. Click on result lines to copy file paths to clipboard.
|
|
Export buttons generate repository lists in GH-MRVA and VS Code formats.
|
|
"""
|
|
|
|
metadata_db_path = cli.SwitchAttr(
|
|
"--metadata_db_path", str, mandatory=True,
|
|
help="Path to the metadata.sql SQLite database file"
|
|
)
|
|
|
|
gh_mrva_output = cli.SwitchAttr(
|
|
"--gh_mrva_output", str, mandatory=False,
|
|
help="Path to write GH-MRVA selection JSON file (default: ~/work-gh/mrva/gh-mrva/gh-mrva-selection.json)"
|
|
)
|
|
|
|
def main(self):
|
|
"""Launch the database selector GUI."""
|
|
db_path = Path(self.metadata_db_path).expanduser().resolve()
|
|
|
|
if not db_path.exists():
|
|
print(f"Error: Database file does not exist: {db_path}", file=sys.stderr)
|
|
return 1
|
|
|
|
if not db_path.is_file():
|
|
print(f"Error: Path is not a file: {db_path}", file=sys.stderr)
|
|
return 1
|
|
|
|
# Set default output path if not specified
|
|
if self.gh_mrva_output:
|
|
output_path = Path(self.gh_mrva_output).expanduser().resolve()
|
|
else:
|
|
output_path = Path.home() / "work-gh" / "mrva" / "gh-mrva" / "gh-mrva-selection.json"
|
|
|
|
try:
|
|
create_gui(str(db_path), str(output_path))
|
|
except Exception as e:
|
|
print(f"Error launching GUI: {e}", file=sys.stderr)
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
DatabaseSelectorApp.run() |