Skip to content

Commit

Permalink
(NEXMANAGE-744) Remove all references to future library as we do no…
Browse files Browse the repository at this point in the history
…t use Python 2 (#553)
  • Loading branch information
gblewis1 authored Sep 30, 2024
1 parent 38d7870 commit 9701668
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion inbm-lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
license='Intel Proprietary',
packages=['inbm_lib', 'inbm_common_lib'],
include_package_data=True,
install_requires=['paho-mqtt==1.6.0', 'types-paho-mqtt==1.6.0.7', 'dmidecode==0.9.0', 'xmlschema==1.5.3', 'defusedxml==0.7.1', 'future==1.0.0', 'url-normalize==1.4.3', 'snoop==0.4.3', 'types-setuptools==71.1.0.20240813'],
install_requires=['paho-mqtt==1.6.0', 'types-paho-mqtt==1.6.0.7', 'dmidecode==0.9.0', 'xmlschema==1.5.3', 'defusedxml==0.7.1', 'url-normalize==1.4.3', 'snoop==0.4.3', 'types-setuptools==71.1.0.20240813'],
test_suite='pytest',
tests_require=test_deps,
extras_require=extras,
Expand Down
3 changes: 3 additions & 0 deletions inbm/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Updated 'docker' go library version in trtl to 25.0.6, fixing CVE-2024-41110
- Updated 'cryptography' Python library in dispatcher to 43.0.1, fixing GHSA-h4gh-qq45-vh27.

### Changed
- Removed all references to `future` library as we do not use Python 2

## 4.2.5 - 2024-09-04
### Fixed
- Added #!/usr/bin/python3 lines to agents to work in source install mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .adapter import Adapter
from base64 import b64encode, b64decode
from hashlib import sha256
from future.moves.urllib.request import quote
from urllib.parse import quote
from hmac import HMAC
from time import time, sleep
from typing import Optional, Any, Dict, Callable, Tuple
Expand Down Expand Up @@ -220,11 +220,11 @@ def _generate_sas_token(self,
sha256).digest())
except ValueError as e:
raise AdapterConfigureError(f"Error generating SAS Token: {str(e)}")
signature = quote(signature)
signature_quoted = quote(signature)

return "SharedAccessSignature sr={!s}&sig={!s}&se={}".format(
resource,
signature,
signature_quoted,
expiration
)

Expand Down
15 changes: 8 additions & 7 deletions inbm/cloudadapter-agent/cloudadapter/cloud/client/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
OP_NO_RENEGOTIATION, TLSVersion, OP_NO_SSLv2, OP_NO_SSLv3
from typing import Union, Tuple, Optional, Dict, Any

from future.moves.urllib.request import getproxies
from urllib.request import getproxies

logger = logging.getLogger(__name__)

Expand All @@ -26,6 +26,7 @@ def __init__(self, hostname: Optional[str] = None, port: Optional[int] = None) -
@param hostname: (str) Hostname for proxy without http://
@param port: (int) Port for proxy
"""
self._endpoint: tuple[str, int] | None
logger.debug("")
if hostname and port:
logger.debug(
Expand All @@ -43,22 +44,22 @@ def endpoint(self) -> Union[Tuple[str, int], None]:
"""
return self._endpoint

def _get_http_proxy(self) -> Tuple[str, int]:
def _get_http_proxy(self) -> Tuple[str, int] | None:
"""Obtain HTTP proxy information from the given arguments"""
proxy = getproxies().get("http")

logger.debug("Independent getproxies_environment call: {}".format(str(getproxies())))

if proxy:
logger.debug("Got proxy: {}".format(str(proxy)))
proxy = proxy.split(':')[1:] # Ignore 'http'
endpoint = proxy[0].strip("/")
port = int(proxy[1].strip("/"))
proxy = (endpoint, port)
proxy_parts = proxy.split(':')[1:] # Ignore 'http'
endpoint = proxy_parts[0].strip("/")
port = int(proxy_parts[1].strip("/"))
return (endpoint, port)
else:
logger.debug("Could not get HTTP proxy")
return None

return proxy


# ========== Provides TLS configuration
Expand Down
2 changes: 1 addition & 1 deletion inbm/cloudadapter-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
license='Intel Proprietary (see \'licenses\' directory)',
packages=find_packages(exclude=['*.*', 'mqttclient']),
include_package_data=True,
install_requires=['pytest', 'pytest-cov', 'pytest-mock', 'packaging', 'future'],
install_requires=['pytest', 'pytest-cov', 'pytest-mock', 'packaging'],
test_suite='pytest',
tests_require=['pytest', 'pytest-cov', 'pytest-mock'])
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_sas_configure_succeeds(
assert mock_build_client_with_config.call_count == 1

@mock.patch('base64.b64encode', autospec=True)
@mock.patch('future.moves.urllib.request.quote', autospec=True)
@mock.patch('urllib.parse.quote', autospec=True)
def test_generate_sas_token(self, mock_quote, mock_base64encode) -> None:
res = self.azure_adapter._generate_sas_token('registration', 'sas_token=', int(time()))
self.assertRegex(res, "SharedAccessSignature")
Expand Down
2 changes: 1 addition & 1 deletion inbm/configuration-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
license='Intel Proprietary (see \'licenses\' directory)',
packages=find_packages(exclude=['*.*', 'mqttclient']),
include_package_data=True,
install_requires=['pytest', 'pytest-cov', 'pytest-mock', 'packaging', 'future'],
install_requires=['pytest', 'pytest-cov', 'pytest-mock', 'packaging'],
test_suite='pytest',
tests_require=['pytest', 'pytest-cov', 'pytest-mock'])
2 changes: 1 addition & 1 deletion inbm/diagnostic-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
license='Intel Proprietary (see \'licenses\' directory)',
packages=find_packages(exclude=['*.*', 'mqttclient']),
include_package_data=True,
install_requires=['mock', 'pytest', 'pytest-cov', 'pytest-mock', 'packaging', 'future'],
install_requires=['mock', 'pytest', 'pytest-cov', 'pytest-mock', 'packaging'],
test_suite='pytest',
tests_require=['pytest', 'pytest-cov', 'pytest-mock']
)
2 changes: 1 addition & 1 deletion inbm/dispatcher-agent/dispatcher/fota/fota.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from threading import Timer
from typing import Any, Optional, Mapping

from future.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from dispatcher.packagemanager.constants import DEFAULT_HASH_ALGORITHM
from dispatcher.update_logger import UpdateLogger
from inbm_lib.constants import OTA_PENDING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.x509 import load_pem_x509_certificate
from future.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from inbm_common_lib.utility import CanonicalUri, canonicalize_uri
from inbm_common_lib.utility import get_canonical_representation_of_path
from inbm_lib.count_down_latch import CountDownLatch
Expand Down
2 changes: 1 addition & 1 deletion inbm/dispatcher-agent/inbm-dispatcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ a = Analysis(['dispatcher/dispatcher.py'],
pathex=['/src/dispatcher-agent', '/src/inbm-lib'],
binaries=[],
datas=[(path.join(site_packages,'xmlschema'), './xmlschema')],
hiddenimports=['inbm_lib.mqttclient', 'inbm_lib', 'UserList', 'UserString', 'commands', 'future.backports.urllib', 'jsonschema'],
hiddenimports=['inbm_lib.mqttclient', 'inbm_lib', 'UserList', 'UserString', 'commands', 'jsonschema'],
hookspath=['../packaging/pyinstaller-hooks'],
runtime_hooks=[],
excludes=[],
Expand Down
1 change: 0 additions & 1 deletion inbm/dispatcher-agent/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ urllib3==1.26.19
certifi==2024.07.04
pyinstaller==5.13.1
setuptools==70.0.0
future==1.0.0
untangle==1.2.1
APScheduler==3.10.4
2 changes: 1 addition & 1 deletion inbm/dispatcher-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
packages=find_packages(exclude=['tests.*', '*.tests.*', 'tests', '*.tests', 'test_*']),
include_package_data=True,
install_requires=['mock', 'pytest', 'pytest-cov', 'pytest-mock', 'packaging',
'future', 'paho-mqtt', 'jsonschema', 'cryptography'],
'paho-mqtt', 'jsonschema', 'cryptography'],
test_suite='pytest',
tests_require=['pytest', 'pytest-cov', 'pytest-mock']
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'UserDict',
'itertools',
'collections',
'future.backports.misc',
'commands',
'base64',
'__builtin__',
Expand Down
2 changes: 1 addition & 1 deletion inbm/telemetry-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
packages=find_packages(exclude=('tests', 'doc')),
include_package_data=True,
install_requires=['pytest', 'pytest-cov', 'pytest-mock',
'packaging', 'future', 'paho-mqtt', 'psutil'],
'packaging', 'paho-mqtt', 'psutil'],
test_suite='pytest',
tests_require=['pytest', 'pytest-cov', 'pytest-mock']
)
3 changes: 0 additions & 3 deletions third-party-programs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ cffi
elementpath
Copyright (c), 2018-2022, SISSA (Scuola Internazionale Superiore di Studi Avanzati)

future
Copyright 2013-2019 Python Charmers Pty Ltd, Australia.

six
Copyright (c) 2010-2020 Benjamin Peterson

Expand Down

0 comments on commit 9701668

Please sign in to comment.