How to use the sarge.Command 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 / tasks / View on Github external
def _run_ant_target(self, target, env):
        verbose = self.task_config.options__verbose in ('True','true')
        # Execute the command
        if verbose:
            cmd = 'ant %s' % target
            cmd = '%s/ci/ %s' % (CUMULUSCI_PATH, target)
        p = sarge.Command(cmd, stdout=sarge.Capture(buffer_size=-1), env=env)
        # Print the stdout buffer until the command completes and capture all lines in log for reference in exceptions
        log = []
        while p.returncode is None:
            for line in p.stdout:
        # Check the return code, raise the appropriate exception if needed
        if p.returncode:
            logtxt = '\n'.join(log)
                if logtxt.find('All Component Failures:') != -1:
                    raise DeploymentException(logtxt)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / View on Github external
def _call_salesforce_dx(self, command, options=None):
        full_command = 'heroku ' + command
        if options:
            full_command += ' {}'.format(options)

        full_command += ' -u {}'.format(self.org_config.username)
       'Running: {}'.format(full_command))
        p = sarge.Command(full_command, stdout=sarge.Capture(buffer_size=-1))

        output = []
        for line in p.stdout:

        if p.returncode:
            message = '{}: {}'.format(p.returncode, p.stdout)
            raise SalesforceDXException(message)
github SFDO-Tooling / CumulusCI / cumulusci / core / View on Github external
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:"{} with command: {}".format(log_note, command))
    # Avoid logging access token
    if access_token:
        command += sarge.shell_format(" -u {0}", access_token)
    p = sarge.Command(
        stdout=sarge.Capture(buffer_size=-1) if capture_output else None,
        stderr=sarge.Capture(buffer_size=-1) if capture_output else None,
    if capture_output:
        p.stdout_text = io.TextIOWrapper(p.stdout, encoding=sys.stdout.encoding)
        p.stderr_text = io.TextIOWrapper(p.stderr, encoding=sys.stdout.encoding)
    if check_return and p.returncode:
        raise Exception(f"Command exited with return code {p.returncode}")
    return p
github SFDO-Tooling / CumulusCI / cumulusci / View on Github external
def get_git_config(config_key):
    p = sarge.Command(
        sarge.shell_format('git config --get "{0!s}"', config_key),
    config_value = (
        io.TextIOWrapper(p.stdout, encoding=sys.stdout.encoding).read().strip()

    return config_value if config_value and not p.returncode else None


A wrapper for subprocess which provides command pipeline functionality.

Latest version published 2 years ago

Package Health Score

49 / 100
Full package analysis