Skip to content

feat: add --cli mode to p2pp for headless/CI processing #107

Closed

Description

@markballew

Problem

p2pp is a PyQt GUI application. When run in CI (headless, no display), it hangs indefinitely even with xvfb-run + image_rc mock. The GUI modules (p2pp/gui.py, image_rc) initialize Qt widgets and wait for user interaction.

Solution

Add a --cli flag to P2PP.py that:

  1. Skips all GUI initialization (no PyQt, no image_rc, no QWidget creation)
  2. Imports only the processing modules (mcf.py, psconfig.py, omega.py, formatnumbers.py)
  3. Reads input/output file paths from CLI args (already supported: P2PP.py input.gcode output.gcode)
  4. Processes the G-code and exits with code 0 on success, 1 on failure
  5. Prints a summary (splices, pings, Omega header) to stdout

Implementation

# P2PP.py
import sys
if "--cli" in sys.argv:
    # Headless mode: skip GUI
    sys.argv.remove("--cli")
    from p2pp.mcf import p2pp_process_file
    # ... direct call, no gui
else:
    # GUI mode (existing behavior)
    import p2pp.gui

Or better: make the gui import lazy in mcf.py so p2pp can run without Qt:

# p2pp/mcf.py — replace unconditional import
try:
    import p2pp.gui as gui
except (ImportError, ModuleNotFoundError):
    gui = None

Acceptance criteria

  • python3 P2PP.py --cli input.gcode output.gcode works without PyQt installed
  • No GUI widgets created in --cli mode
  • Exits with code 0 on success, 1 on error
  • Prints processing summary to stdout
  • CI e2e-slice job passes with --cli flag

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions