@staticmethod<EOL><INDENT>def _exec(cmd, cwd=None, env=None, ignored_error_codes=None,<EOL>encoding='<STR_LIT:utf-8>'):<DEDENT>
if ignored_error_codes is None:<EOL><INDENT>ignored_error_codes = []<EOL><DEDENT>logger.debug("<STR_LIT>",<EOL>'<STR_LIT:U+0020>'.join(cmd), cwd, str(env))<EOL>try:<EOL><INDENT>proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,<EOL>stderr=subprocess.PIPE,<EOL>cwd=cwd, env=env)<EOL>(outs, errs) = proc.communicate()<EOL><DEDENT>except OSError as e:<EOL><INDENT>raise RepositoryError(cause=str(e))<EOL><DEDENT>if proc.returncode != <NUM_LIT:0> and proc.returncode not in ignored_error_codes:<EOL><INDENT>err = errs.decode(encoding, errors='<STR_LIT>')<EOL>cause = "<STR_LIT>" % err<EOL>raise RepositoryError(cause=cause)<EOL><DEDENT>else:<EOL><INDENT>logger.debug(errs.decode(encoding, errors='<STR_LIT>'))<EOL><DEDENT>return outs<EOL>
Run a command.

        Execute `cmd` command in the directory set by `cwd`. Environment
        variables can be set using the `env` dictionary. The output
        data is returned as encoded bytes.

        Commands which their returning status codes are non-zero will
        be treated as failed. Error codes considered as valid can be
        ignored giving them in the `ignored_error_codes` list.

        :returns: the output of the command as encoded bytes

        :raises RepositoryError: when an error occurs running the command