Prepare the command string

def _cmd_str(self):
        '''
        Prepare the command string
        '''
        sudo = 'sudo' if self.target['sudo'] else ''
        sudo_user = self.target['sudo_user']
        if '_caller_cachedir' in self.opts:
            cachedir = self.opts['_caller_cachedir']
        else:
            cachedir = self.opts['cachedir']
        thin_code_digest, thin_sum = salt.utils.thin.thin_sum(cachedir, 'sha1')
        debug = ''
        if not self.opts.get('log_level'):
            self.opts['log_level'] = 'info'
        if salt.log.LOG_LEVELS['debug'] >= salt.log.LOG_LEVELS[self.opts.get('log_level', 'info')]:
            debug = '1'
        arg_str = '''
OPTIONS.config = \
"""
{config}
"""
OPTIONS.delimiter = '{delimeter}'
OPTIONS.saltdir = '{saltdir}'
OPTIONS.checksum = '{checksum}'
OPTIONS.hashfunc = '{hashfunc}'
OPTIONS.version = '{version}'
OPTIONS.ext_mods = '{ext_mods}'
OPTIONS.wipe = {wipe}
OPTIONS.tty = {tty}
OPTIONS.cmd_umask = {cmd_umask}
OPTIONS.code_checksum = {code_checksum}
ARGS = {arguments}\n'''.format(config=self.minion_config,
                               delimeter=RSTR,
                               saltdir=self.thin_dir,
                               checksum=thin_sum,
                               hashfunc='sha1',
                               version=salt.version.__version__,
                               ext_mods=self.mods.get('version', ''),
                               wipe=self.wipe,
                               tty=self.tty,
                               cmd_umask=self.cmd_umask,
                               code_checksum=thin_code_digest,
                               arguments=self.argv)
        py_code = SSH_PY_SHIM.replace('#%%OPTS', arg_str)
        if six.PY2:
            py_code_enc = py_code.encode('base64')
        else:
            py_code_enc = base64.encodebytes(py_code.encode('utf-8')).decode('utf-8')
        if not self.winrm:
            cmd = SSH_SH_SHIM.format(
                DEBUG=debug,
                SUDO=sudo,
                SUDO_USER=sudo_user,
                SSH_PY_CODE=py_code_enc,
                HOST_PY_MAJOR=sys.version_info[0],
            )
        else:
            cmd = saltwinshell.gen_shim(py_code_enc)

        return cmd