'Task handler for sftp_download plugin'

def on_task_download(self, task, config):

    dependency_check()
    for (sftp_config, entries) in groupby(task.accepted, self.get_sftp_config):
        if (not sftp_config):
            continue
        error_message = None
        sftp = None
        try:
            sftp = sftp_connect(sftp_config)
        except Exception as e:
            error_message = (u'Failed    to    connect    to    %s    (%s)' % (sftp_config.host, e))
            log.error(error_message)
        for entry in entries:
            if sftp:
                self.download_entry(entry, config, sftp)
            else:
                entry.fail(error_message)
        if sftp:
            sftp.close()
