mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Export http.fetch_http_content to "public"
This commit is contained in:
@ -19,7 +19,7 @@ import subprocess
|
||||
import click
|
||||
|
||||
from platformio import VERSION, __install_requires__, __version__, app, exception
|
||||
from platformio.http import fetch_remote_content
|
||||
from platformio.http import fetch_http_content
|
||||
from platformio.package.manager.core import update_core_packages
|
||||
from platformio.proc import get_pythonexe_path
|
||||
|
||||
@ -132,7 +132,7 @@ def get_latest_version():
|
||||
|
||||
def get_develop_latest_version():
|
||||
version = None
|
||||
content = fetch_remote_content(DEVELOP_INIT_SCRIPT_URL)
|
||||
content = fetch_http_content(DEVELOP_INIT_SCRIPT_URL)
|
||||
for line in content.split("\n"):
|
||||
line = line.strip()
|
||||
if not line.startswith("VERSION"):
|
||||
@ -149,5 +149,5 @@ def get_develop_latest_version():
|
||||
|
||||
|
||||
def get_pypi_latest_version():
|
||||
content = fetch_remote_content(PYPI_JSON_URL)
|
||||
content = fetch_http_content(PYPI_JSON_URL)
|
||||
return json.loads(content)["info"]["version"]
|
||||
|
@ -213,9 +213,8 @@ def ensure_internet_on(raise_exception=False):
|
||||
return result
|
||||
|
||||
|
||||
def fetch_remote_content(*args, **kwargs):
|
||||
with HTTPSession() as s:
|
||||
r = s.get(*args, **kwargs)
|
||||
r.raise_for_status()
|
||||
r.close()
|
||||
return r.text
|
||||
def fetch_http_content(*args, **kwargs):
|
||||
with HTTPSession() as session:
|
||||
response = session.get(*args, **kwargs)
|
||||
response.raise_for_status()
|
||||
return response.text
|
||||
|
@ -22,7 +22,7 @@ from urllib.parse import urlparse
|
||||
|
||||
from platformio import util
|
||||
from platformio.compat import get_object_members, string_types
|
||||
from platformio.http import fetch_remote_content
|
||||
from platformio.http import fetch_http_content
|
||||
from platformio.package.exception import ManifestParserError, UnknownManifestError
|
||||
from platformio.project.helpers import is_platformio_project
|
||||
|
||||
@ -103,7 +103,7 @@ class ManifestParserFactory:
|
||||
|
||||
@staticmethod
|
||||
def new_from_url(remote_url):
|
||||
content = fetch_remote_content(remote_url)
|
||||
content = fetch_http_content(remote_url)
|
||||
return ManifestParserFactory.new(
|
||||
content,
|
||||
ManifestFileType.from_uri(remote_url) or ManifestFileType.LIBRARY_JSON,
|
||||
|
@ -22,7 +22,7 @@ import requests
|
||||
import semantic_version
|
||||
from marshmallow import Schema, ValidationError, fields, validate, validates
|
||||
|
||||
from platformio.http import fetch_remote_content
|
||||
from platformio.http import fetch_http_content
|
||||
from platformio.package.exception import ManifestValidationError
|
||||
from platformio.util import memoized
|
||||
|
||||
@ -281,4 +281,4 @@ class ManifestSchema(BaseSchema):
|
||||
"https://raw.githubusercontent.com/spdx/license-list-data/"
|
||||
f"v{version}/json/licenses.json"
|
||||
)
|
||||
return json.loads(fetch_remote_content(spdx_data_url))
|
||||
return json.loads(fetch_http_content(spdx_data_url))
|
||||
|
@ -17,6 +17,7 @@
|
||||
from platformio.device.list.util import list_logical_devices, list_serial_ports
|
||||
from platformio.device.monitor.filters.base import DeviceMonitorFilterBase
|
||||
from platformio.fs import to_unix_path
|
||||
from platformio.http import fetch_http_content
|
||||
from platformio.platform.base import PlatformBase
|
||||
from platformio.project.config import ProjectConfig
|
||||
from platformio.project.helpers import get_project_watch_lib_dirs, load_build_metadata
|
||||
|
Reference in New Issue
Block a user