'Uploads some data into a file on the remote server.
Arguments:
data(str): The data to upload.
remote(str): The filename to upload it to.
Example:
>>> s =  ssh(host=\'example.pwnme\',
...         user=\'travis\',
...         password=\'demopass\')
>>> s.upload_data(\'Hello, world\', \'/tmp/upload_foo\')
>>> print file(\'/tmp/upload_foo\').read()
Hello, world
>>> s._sftp = False
>>> s._tried_sftp = True
>>> s.upload_data(\'Hello, world\', \'/tmp/upload_bar\')
>>> print file(\'/tmp/upload_bar\').read()
Hello, world'

def upload_data(self, data, remote):

    if (os.path.normpath(remote) == os.path.basename(remote)):
        remote = os.path.join(self.cwd, remote)
    if self.sftp:
        with tempfile.NamedTemporaryFile() as f:
            f.write(data)
            f.flush()
            self.sftp.put(f.name, remote)
            return
    with context.local(log_level='ERROR'):
        cmd = ('cat    >    ' + sh_string(remote))
        s = self.run(cmd, tty=False)
        s.send(data)
        s.shutdown('send')
        data = s.recvall()
        result = s.wait()
        if (result != 0):
            self.error(('Could    not    upload    file    %r    (%r)\n%s' % (remote, result, data)))
