# Buggy code
def __init__(
    self,
    opts,
    argv,
    id_,
    host,
    user=None,
    port=None,
    passwd=None,
    priv=None,
    timeout=None,
    sudo=False,
    tty=False,
    mods=None,
    fsclient=None,
    **kwargs,
):
    self.opts = opts
    if kwargs.get("wipe"):
        self.wipe = "False"
    else:
        self.wipe = "True" if self.opts.get("wipe_ssh") else "False"
    if kwargs.get("thin_dir"):
        self.thin_dir = kwargs["thin_dir"]
    else:
        if user:
            thin_dir = DEFAULT_THIN_DIR.replace("%%USER%%", user)
        else:
            thin_dir = DEFAULT_THIN_DIR.replace("%%USER%%", "root")
        self.thin_dir = thin_dir.replace(
            "%%FQDNUUID%%",
            uuid.uuid3(uuid.NAMESPACE_DNS, salt.utils.network.get_fqhostname()).hex[:6],
        )
    self.opts["thin_dir"] = self.thin_dir
    self.fsclient = fsclient
    self.context = {"master_opts": self.opts, "fileclient": self.fsclient}

    if isinstance(argv, string_types):
        self.argv = [argv]
    else:
        self.argv = argv

    self.fun, self.args, self.kwargs = self.__arg_comps()
    self.id = id_

    self.mods = mods if isinstance(mods, dict) else {}
    args = {
        "host": host,
        "user": user,
        "port": port,
        "passwd": passwd,
        "priv": priv,
        "timeout": timeout,
        "sudo": sudo,
        "tty": tty,
        "mods": self.mods,
    }
    self.minion_config = yaml.dump(
        {
            "root_dir": os.path.join(self.thin_dir, "running_data"),
            "id": self.id,
            "sock_dir": "/",
        },
        width=1000,
    ).strip()
    self.target = kwargs
    self.target.update(args)
    self.serial = salt.payload.Serial(opts)
    self.wfuncs = salt.loader.ssh_wrapper(opts, None, self.context)
    self.shell = salt.client.ssh.shell.Shell(opts, **args)


# Traceback (IOError)
Process Process-8:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 315, in handle_routine
stdout, stderr, retcode = single.run()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 630, in run
stdout = self.run_wfunc()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 675, in run_wfunc
opts_pkg = pre_wrapper['test.opts_pkg']()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/wrapper/__init__.py", line 62, in caller
stdout, stderr, _ = single.cmd_block()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 818, in cmd_block
cmd_str = self._cmd_str()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 755, in _cmd_str
thin_sum = salt.utils.thin.thin_sum(cachedir, 'sha1')
File "/usr/lib/python2.7/dist-packages/salt/utils/thin.py", line 182, in thin_sum
thintar = gen_thin(cachedir)
File "/usr/lib/python2.7/dist-packages/salt/utils/thin.py", line 172, in gen_thin
tfp.add('version')
File "/usr/lib/python2.7/tarfile.py", line 1995, in add
self.addfile(tarinfo, f)
File "/usr/lib/python2.7/tarfile.py", line 2024, in addfile
copyfileobj(fileobj, self.fileobj, tarinfo.size)
File "/usr/lib/python2.7/tarfile.py", line 279, in copyfileobj
raise IOError("end of file reached")
IOError: end of file reached

Traceback (most recent call last):
File "./install.py", line 415, in <module>
for output in run():
File "./install.py", line 331, in run
for output in bootstrap('*'):
File "./install.py", line 181, in bootstrap
yield check_output(['salt-ssh', minion_id, 'state.sls', 'bootstrap'])
File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['salt-ssh', '*', 'state.sls', 'bootstrap']' returned non-zero exit status -15

# Fixed code
def __init__(
    self,
    opts,
    argv,
    id_,
    host,
    user=None,
    port=None,
    passwd=None,
    priv=None,
    timeout=None,
    sudo=False,
    tty=False,
    mods=None,
    fsclient=None,
    thin=None,
    **kwargs,
):
    self.opts = opts
    if kwargs.get("wipe"):
        self.wipe = "False"
    else:
        self.wipe = "True" if self.opts.get("wipe_ssh") else "False"
    if kwargs.get("thin_dir"):
        self.thin_dir = kwargs["thin_dir"]
    else:
        if user:
            thin_dir = DEFAULT_THIN_DIR.replace("%%USER%%", user)
        else:
            thin_dir = DEFAULT_THIN_DIR.replace("%%USER%%", "root")
        self.thin_dir = thin_dir.replace(
            "%%FQDNUUID%%",
            uuid.uuid3(uuid.NAMESPACE_DNS, salt.utils.network.get_fqhostname()).hex[:6],
        )
    self.opts["thin_dir"] = self.thin_dir
    self.fsclient = fsclient
    self.context = {"master_opts": self.opts, "fileclient": self.fsclient}

    if isinstance(argv, string_types):
        self.argv = [argv]
    else:
        self.argv = argv

    self.fun, self.args, self.kwargs = self.__arg_comps()
    self.id = id_

    self.mods = mods if isinstance(mods, dict) else {}
    args = {
        "host": host,
        "user": user,
        "port": port,
        "passwd": passwd,
        "priv": priv,
        "timeout": timeout,
        "sudo": sudo,
        "tty": tty,
        "mods": self.mods,
    }
    self.minion_config = yaml.dump(
        {
            "root_dir": os.path.join(self.thin_dir, "running_data"),
            "id": self.id,
            "sock_dir": "/",
        },
        width=1000,
    ).strip()
    self.target = kwargs
    self.target.update(args)
    self.serial = salt.payload.Serial(opts)
    self.wfuncs = salt.loader.ssh_wrapper(opts, None, self.context)
    self.shell = salt.client.ssh.shell.Shell(opts, **args)
    self.thin = self.thin if self.thin else salt.utils.thin.thin_path(opts["cachedir"])