diff --git a/.gitignore b/.gitignore index ad86052..de0f580 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -SOURCES/requests-ftp-0.3.1.tar.gz -/requests-ftp-0.3.1.tar.gz +requests-ftp-0.3.1.tar.gz diff --git a/0001-Remove-use-of-the-cgi-module.patch b/0001-Remove-use-of-the-cgi-module.patch new file mode 100644 index 0000000..1405b7f --- /dev/null +++ b/0001-Remove-use-of-the-cgi-module.patch @@ -0,0 +1,94 @@ +diff -purN requests-ftp-0.3.1.orig/requests_ftp/ftp.py requests-ftp-0.3.1/requests_ftp/ftp.py +--- requests-ftp-0.3.1.orig/requests_ftp/ftp.py 2023-10-02 11:37:02.265791589 -0400 ++++ requests-ftp-0.3.1/requests_ftp/ftp.py 2023-10-02 11:38:01.070198328 -0400 +@@ -6,7 +6,6 @@ from requests.compat import urlparse + from requests.hooks import dispatch_hook + from requests import Response, codes + from io import BytesIO +-import cgi + import os + import socket + import logging +@@ -30,12 +29,6 @@ class FTPSession(requests.Session): + content field contains the binary data.''' + return self.request('RETR', url, **kwargs) + +- def stor(self, url, files=None, **kwargs): +- '''Sends an FTP STOR to a given URL. Returns a Response object. Expects +- to be given one file by the standard Requests method. The remote +- filename will be given by the URL provided.''' +- return self.request('STOR', url, files=files, **kwargs) +- + def nlst(self, url, **kwargs): + '''Sends an FTP NLST. Returns a Response object.''' + return self.request('NLST', url, **kwargs) +@@ -54,30 +47,6 @@ def monkeypatch_session(): + return + + +-def parse_multipart_files(request): +- '''Given a prepared reqest, return a file-like object containing the +- original data. This is pretty hacky.''' +- # Start by grabbing the pdict. +- _, pdict = cgi.parse_header(request.headers['Content-Type']) +- +- # Now, wrap the multipart data in a BytesIO buffer. This is annoying. +- buf = BytesIO() +- buf.write(request.body) +- buf.seek(0) +- +- # Parse the data. Simply take the first file. +- data = cgi.parse_multipart(buf, pdict) +- _, filedata = data.popitem() +- buf.close() +- +- # Get a BytesIO now, and write the file into it. +- buf = BytesIO() +- buf.write(''.join(filedata)) +- buf.seek(0) +- +- return buf +- +- + def data_callback_factory(variable): + '''Returns a callback suitable for use by the FTP library. This callback + will repeatedly save data into the variable provided to this function. This +@@ -180,7 +149,6 @@ class FTPAdapter(requests.adapters.BaseA + # send the specific queries. + self.func_table = {'LIST': self.list, + 'RETR': self.retr, +- 'STOR': self.stor, + 'NLST': self.nlst, + 'SIZE': self.size, + 'HEAD': self.head, +@@ -359,30 +327,6 @@ class FTPAdapter(requests.adapters.BaseA + response.status_code = codes.ok + return response + +- def stor(self, path, request): +- '''Executes the FTP STOR command on the given path.''' +- +- # First, get the file handle. We assume (bravely) +- # that there is only one file to be sent to a given URL. We also +- # assume that the filename is sent as part of the URL, not as part of +- # the files argument. Both of these assumptions are rarely correct, +- # but they are easy. +- data = parse_multipart_files(request) +- +- # Split into the path and the filename. +- path, filename = os.path.split(path) +- +- # Switch directories and upload the data. +- self.conn.cwd(path) +- code = self.conn.storbinary('STOR ' + filename, data) +- +- # Close the connection and build the response. +- self.conn.close() +- +- response = build_binary_response(request, BytesIO(), code) +- +- return response +- + def nlst(self, path, request): + '''Executes the FTP NLST command on the given path.''' + data = BytesIO() diff --git a/python-requests-ftp.spec b/python-requests-ftp.spec index ab5dd5b..1150e7e 100644 --- a/python-requests-ftp.spec +++ b/python-requests-ftp.spec @@ -16,10 +16,10 @@ Name: python-%{srcname} Version: 0.3.1 -Release: 11%{?dist} +Release: 35%{?dist} Summary: FTP transport adapter for python-requests -License: ASL 2.0 +License: Apache-2.0 URL: https://github.com/Lukasa/requests-ftp Source0: https://pypi.python.org/packages/source/r/%{srcname}/%{srcname}-%{version}.tar.gz @@ -34,8 +34,10 @@ Patch2: PR28-02-Adding-code-3-to-retr4ieve-status_code.patch Patch3: PR28-03-fix-warning-in-interpreting-ftp-status-codes-minor-d.patch # 2caa427 is only test updates, tests not in pypi tarball # from 7321ab3 -Patch5: PR28-05-Improve-logging-in-status-code-extraction.patch +Patch5: PR28-05-Improve-logging-in-status-code-extraction.patch +# Remove use of the cgi module, which is only used to implement STOR +Patch6: 0001-Remove-use-of-the-cgi-module.patch %description Requests-FTP is an implementation of a very stupid FTP transport adapter for @@ -114,9 +116,81 @@ rm -rf requests_ftp.egg-info %endif %changelog -* Mon Aug 13 2018 David Shea - 0.3.1-11 +* Tue Oct 29 2024 Troy Dawson - 0.3.1-35 +- Bump release for October 2024 mass rebuild: + Resolves: RHEL-64018 + +* Mon Jun 24 2024 Troy Dawson - 0.3.1-34 +- Bump release for June 2024 mass rebuild + +* Mon Jan 29 2024 David Shea - 0.3.1-33 +- Migrate to SPDX license + +* Fri Jan 26 2024 Fedora Release Engineering - 0.3.1-32 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Mon Jan 22 2024 Fedora Release Engineering - 0.3.1-31 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Mon Oct 2 2023 David Shea - 0.3.1-30 +- Remove use of the cgi module + +* Fri Jul 21 2023 Fedora Release Engineering - 0.3.1-29 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Tue Jun 13 2023 Python Maint - 0.3.1-28 +- Rebuilt for Python 3.12 + +* Fri Jan 20 2023 Fedora Release Engineering - 0.3.1-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Fri Jul 22 2022 Fedora Release Engineering - 0.3.1-26 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon Jun 13 2022 Python Maint - 0.3.1-25 +- Rebuilt for Python 3.11 + +* Fri Jan 21 2022 Fedora Release Engineering - 0.3.1-24 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Fri Jul 23 2021 Fedora Release Engineering - 0.3.1-23 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Jun 03 2021 Python Maint - 0.3.1-22 +- Rebuilt for Python 3.10 + +* Wed Jan 27 2021 Fedora Release Engineering - 0.3.1-21 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Jul 29 2020 Fedora Release Engineering - 0.3.1-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Sat May 23 2020 Miro Hrončok - 0.3.1-19 +- Rebuilt for Python 3.9 + +* Thu Jan 30 2020 Fedora Release Engineering - 0.3.1-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Oct 03 2019 Miro Hrončok - 0.3.1-17 +- Rebuilt for Python 3.8.0rc1 (#1748018) + +* Fri Aug 16 2019 Miro Hrončok - 0.3.1-16 +- Rebuilt for Python 3.8 + +* Fri Jul 26 2019 Fedora Release Engineering - 0.3.1-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sat Feb 02 2019 Fedora Release Engineering - 0.3.1-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Thu Aug 2 2018 David Shea - 0.3.1-13 - Fix handling of multi-line FTP responses - Resolves: rhbz#1591065 + +* Sat Jul 14 2018 Fedora Release Engineering - 0.3.1-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Jun 15 2018 Miro Hrončok - 0.3.1-11 +- Rebuilt for Python 3.7 * Tue Apr 24 2018 David Shea - 0.3.1-10 - Conditionalize the python2 and python3 builds