def put(self, path, contents=None, chmod=None):
        sftp = self.client.open_sftp()
        # less than ideal, but we need to mkdir stuff otherwise file() fails
        head, tail = psplit(path)
        if path[0] == "/":
            sftp.chdir("/")
        for part in head.split("/"):
            if part != "":
                try:
                    sftp.mkdir(part)
                except __HOLE__:
                    # so, there doesn't seem to be a way to
                    # catch EEXIST consistently *sigh*
                    pass
                sftp.chdir(part)
        ak = sftp.file(tail,  mode='w')
        ak.write(contents)
        if chmod is not None:
            ak.chmod(chmod)
        ak.close()
        sftp.close()
dataset/ETHPy150Open cloudkick/libcloud/libcloud/compute/ssh.py/ParamikoSSHClient.put