'Recursively uploads a directory onto the remote server
Arguments:
local: Local directory
remote: Remote directory'

def upload_dir(self, local, remote=None):

    remote = (remote or self.cwd)
    local = os.path.expanduser(local)
    dirname = os.path.dirname(local)
    basename = os.path.basename(local)
    if (not os.path.isdir(local)):
        self.error(('%r    is    not    a    directory' % local))
    msg = ('Uploading    %r    to    %r' % (basename, remote))
    with self.waitfor(msg) as w:
        local_tar = tempfile.mktemp()
        with tarfile.open(local_tar, 'w:gz') as tar:
            tar.add(local, basename)
        with context.local(log_level='error'):
            remote_tar = self.mktemp('--suffix=.tar.gz')
            self.upload_file(local_tar, remote_tar)
            untar = self.run(('cd    %s    &&    tar    -xzf    %s' % (remote, remote_tar)))
            message = untar.recvrepeat(2)
            if (untar.wait() != 0):
                self.error(('Could    not    untar    %r    on    the    remote    end\n%s' % (remote_tar, message)))
