Skip to content

Convenience tweaks re: expected failures #627

@bitprophet

Description

@bitprophet
  • quiet kwarg to run/sudo/local which:
    • hides everything

    • sets warn_only=True

    • Use case: interrogative commands, whose result is often used as branching points in-code, where we don't usually want to see the output and do expect frequent failures.

    • Example:

      if run("dpkg --list | grep packagename", quiet=True).failed:
          # install packagename
      
  • maybe also a warn_only() contextmanager shortcut to settings(warn_only=True)?
    • first contextmanager with no parameterization, kinda ugly needing the parens still (unless I'm being dumb)
      • edit: I guess it could be an instance of a contextmanager class. slightly longer definition code, but easier invoke.
    • Maybe add on the output hiding so it's a contextmanager variant of quiet? with quiet():? with silence()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions