add warnings to for remote resolving mode

This commit is contained in:
adeadfed 2023-03-29 00:25:45 +02:00
parent 6cd9925a31
commit da442e7a2a
2 changed files with 27 additions and 2 deletions

18
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}\\pipreqs",
"justMyCode": true,
"args": ["C:/Users/Strawberry/Desktop/projects/pipreqs-vulnerable", "--print"]
}
]
}

View File

@ -176,6 +176,7 @@ def get_imports_info(
for item in imports:
try:
logging.warning('Import "%s" not found locally. Trying to resolve it at the PyPI server.', item)
response = requests.get(
"{0}{1}/json".format(pypi_server, item), proxies=proxy)
if response.status_code == 200:
@ -187,9 +188,15 @@ def get_imports_info(
raise HTTPError(status_code=response.status_code,
reason=response.reason)
except HTTPError:
logging.debug(
'Package %s does not exist or network problems', item)
logging.warning(
'Package "%s" does not exist or network problems', item)
continue
logging.warning('Import "%s" was resolved to "%s:%s" package (%s).\nPlease, verify manually the final list of requirements.txt to avoid possible dependency confusions.',
item,
data.name,
data.latest_release_id,
data.pypi_url
)
result.append({'name': item, 'version': data.latest_release_id})
return result