Exemple #1
0
    def process(self):
        '''Process.

        Coroutine.
        '''
        verdict = self._fetch_rule.check_ftp_request(
            self._url_item.url_info, self._url_item.url_record)[0]

        if not verdict:
            self._url_item.skip()
            return

        request = Request(self._url_item.url_info.url)  # TODO: dependency inject

        if self._fetch_rule.ftp_login:
            request.username, request.password = self._fetch_rule.ftp_login

        dir_name, filename = self._url_item.url_info.split_path()
        if self._processor.fetch_params.glob and frozenset(filename) & GLOB_CHARS:
            directory_url = to_dir_path_url(request.url_info)
            directory_request = copy.deepcopy(request)
            directory_request.url = directory_url
            request = directory_request
            is_file = False
            self._glob_pattern = urllib.parse.unquote(filename)
        else:
            is_file = yield From(self._prepare_request_file_vs_dir(request))

            self._file_writer_session.process_request(request)

        wait_time = yield From(self._fetch(request, is_file))

        if wait_time:
            _logger.debug('Sleeping {0}.'.format(wait_time))
            yield From(trollius.sleep(wait_time))
Exemple #2
0
    def test_login_no_password_required(self):
        client = Client()
        file = io.BytesIO()

        with client.session() as session:
            request = Request(self.get_url('/example (copy).txt'))
            request.username = '******'
            yield From(session.fetch(request))
            yield From(session.read_content(file))
Exemple #3
0
    def test_login_no_password_required(self):
        client = Client()
        file = io.BytesIO()

        with client.session() as session:
            request = Request(self.get_url('/example (copy).txt'))
            request.username = '******'
            yield From(session.fetch(request))
            yield From(session.read_content(file))