How to use the sarge.shell_quote function in sarge

To help you get started, we’ve selected a few sarge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SFDO-Tooling / CumulusCI / cumulusci / core / sfdx.py View on Github external
access_token=None,
    args=None,
    env=None,
    capture_output=True,
    check_return=False,
):
    """Call an sfdx command and capture its output.

    Be sure to quote user input that is part of the command using `sarge.shell_format`.

    Returns a `sarge` Command instance with returncode, stdout, stderr
    """
    command = "sfdx {}".format(command)
    if args is not None:
        for arg in args:
            command += " " + sarge.shell_quote(arg)
    if username:
        command += sarge.shell_format(" -u {0}", username)
    if log_note:
        logger.info("{} with command: {}".format(log_note, command))
    # Avoid logging access token
    if access_token:
        command += sarge.shell_format(" -u {0}", access_token)
    p = sarge.Command(
        command,
        stdout=sarge.Capture(buffer_size=-1) if capture_output else None,
        stderr=sarge.Capture(buffer_size=-1) if capture_output else None,
        shell=True,
        env=env,
    )
    p.run()
    if capture_output:
github westurner / dotfiles / scripts / pyrpo.py View on Github external
def shell_quote_single(cmdstr):
    return sarge.shell_quote(cmdstr)
github westurner / dotfiles / scripts / pyrpo.py View on Github external
def shell_quote_double(cmdstr):
    _singlequoted = sarge.shell_quote(cmdstr)
    if (_singlequoted[0], _singlequoted[-1]) == ("'", "'"):
        return '"%s"' % _singlequoted[1:-1]
    else:
        return _singlequoted

sarge

A wrapper for subprocess which provides command pipeline functionality.

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis