🐛 pmgr: Fix error detection
Errors during install, e.g. due to dependency issues, that happened while a "Requirement already installed" message was present in the output as well, were wrongly read as a "reinstall needed" case if there was no failure line present for some reason. The logic has now been adjusted so that a reinstall will only be triggered if there was no `Error:` line in the output. A test case has been added as well. Closes #4703
This commit is contained in:
1 parent
7c42913205
commit
923c2e14be
3 files changed
+27
-3
No files matched your search
@@ -27,6 +27,9 @@ OUTPUT_SUCCESS = "Successfully installed"
|
||||
OUTPUT_FAILURE = "Could not install"
|
||||
"""Start of failure result line"""
|
||||
|
||||
OUTPUT_ERROR = "ERROR:"
|
||||
"""Start of error line"""
|
||||
|
||||
OUTPUT_ALREADY_INSTALLED = "Requirement already satisfied"
|
||||
"""Start of a line indicating some package was already installed in this version"""
|
||||
|
||||
@@ -58,8 +61,10 @@ def is_already_installed(lines):
|
||||
bool: True if detected, False otherwise
|
||||
"""
|
||||
result_line = get_result_line(lines) # neither success nor failure reported
|
||||
return not result_line and any(
|
||||
line.strip().startswith(OUTPUT_ALREADY_INSTALLED) for line in lines
|
||||
return (
|
||||
not result_line
|
||||
and not any(line.strip().startswith(OUTPUT_ERROR) for line in lines)
|
||||
and any(line.strip().startswith(OUTPUT_ALREADY_INSTALLED) for line in lines)
|
||||
)
|
||||
|
||||
|
||||
@@ -114,7 +119,7 @@ def get_result_line(lines):
|
||||
|
||||
pip might generate more lines after the actual result line, which is why
|
||||
we can't just take the final line. So instead we look for the last line
|
||||
starting with either "Successfully installed" or "Could not installed".
|
||||
starting with either "Successfully installed" or "Could not install".
|
||||
If neither can be found, an empty string will be returned, which should also
|
||||
be considered a failure to install.
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
|
||||
Processing /tmp/tmprvq8z421.zip
|
||||
Preparing metadata (setup.py): started
|
||||
Preparing metadata (setup.py): finished with status 'done'
|
||||
Requirement already satisfied: OctoPrint in /home/pi/oprint/lib/python3.9/site-packages (from OctoEverywhere==1.11.2) (1.8.6)
|
||||
Requirement already satisfied: certifi in /home/pi/oprint/lib/python3.9/site-packages (from OctoEverywhere==1.11.2) (2022.9.24)
|
||||
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453a30>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x754a4a18>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x754a4568>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x754a4028>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x754a4be0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453c40>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453d90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453e80>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453f70>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75453fe8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/dnspython/
|
||||
ERROR: Could not find a version that satisfies the requirement dnspython (from octoeverywhere) (from versions: none)
|
||||
ERROR: No matching distribution found for dnspython
|
||||
@@ -165,6 +165,7 @@ class PipUtilTest(unittest.TestCase):
|
||||
("already_installed_1.txt", True),
|
||||
("already_installed_2.txt", True),
|
||||
("successful_install_1.txt", False),
|
||||
("dependency_error.txt", False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_is_already_installed(self, file, expected):
|
||||
|
||||
Reference in new issue
Block a user