'A function to check if the rsync_remotepath,
exists or not. Returns TRUE rpath is a directory
and exists, else FALSE'

def check_rpath_exists(self):

    ruser = self.cleaned_data.get('rsync_user')
    rhost = str(self.cleaned_data.get('rsync_remotehost'))
    if ('@' in rhost):
        remote = rhost
    else:
        remote = ('"%s"@%s' % (ruser, rhost))
    rport = str(self.cleaned_data.get('rsync_remoteport'))
    rpath = self.cleaned_data.get('rsync_remotepath')
    proc = subprocess.Popen(('su    -m    "%s"    -c    \'ssh    -p    %s    -o    "BatchMode    yes"    -o    "ConnectTimeout=5"    %s    test    -d    \\""%s"\\"\'    ' % (ruser, rport, remote, rpath)), shell=True)
    proc.wait()
    return (proc.returncode == 0)
