def process(self, path, file_list):
     """
     Run the rsync process after being notified of a change in the filesystem.
     path: The source path for the rsync process
     file_list: The list of files that should be rsynced
     """
     start_time = time.time()
     conf = Settings()
     
     # build the source and target paths for rsync
     try:
         source, target = syncutils.build_sync_paths(path)
         self._logger.info("%s => %s"%(source, target))
     except Exception, e:
         if self._raven_client != None:
             self._raven_client.captureException()
         else:
             self._logger.error(e)
         return
def folders():
    """
    Return a list of the source and their associated target folders together
    with a flag that indicates if the target folder exists.
    """
    result = {}
    conf = Settings()

    # get the list of source folders
    src_folders = syncutils.get_source_folders()

    # connect to the remote server
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    try:
        client.connect(conf['target']['host'],
                       username=conf['target']['user'], timeout=10)

        # iterate over the source folders
        for src_folder in src_folders:
            source, target = syncutils.build_sync_paths(src_folder)

            # check if the target folder exists
            target_exists = False
            cmd = "[ -d \"%s\" ] && echo \"True\" || echo \"False\""%target
            _, stdout, stderr = client.exec_command(cmd)
            err = stderr.read()
            if err:
                logger.error("Couldn't check target folder: %s"%err.rstrip())
            else:
                if stdout.read().rstrip() == "True":
                    target_exists = True

            result[source] = {'target': target,
                              'exists': target_exists}
    
    except (paramiko.SSHException, socket.error), e:
        logger.error("Can't connect to target host: %s"%e)