Package: httpie
Followup-For: Bug #1041792
Control: tags -1 patch
quick patch attached
>From 3ce3cacb8d3f7beff8d684a088ac4ecc016cc9c1 Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 2 Aug 2023 11:23:38 +
Subject: [PATCH] disable updates
---
httpie/core.py| 2 -
httpie/internal/daemon_runner.py | 2 -
httpie/internal/update_warnings.py| 171 ---
httpie/manager/tasks/__init__.py | 2 -
httpie/manager/tasks/check_updates.py | 10 --
tests/test_update_warnings.py | 237 --
6 files changed, 424 deletions(-)
delete mode 100644 httpie/internal/update_warnings.py
delete mode 100644 httpie/manager/tasks/check_updates.py
delete mode 100644 tests/test_update_warnings.py
diff --git a/httpie/core.py b/httpie/core.py
index d0c26dc..0755e6d 100644
--- a/httpie/core.py
+++ b/httpie/core.py
@@ -24,7 +24,6 @@ from .output.writer import write_message, write_stream,
write_raw_data, MESSAGE_
from .plugins.registry import plugin_manager
from .status import ExitStatus, http_status_to_exit_status
from .utils import unwrap_context
-from .internal.update_warnings import check_updates
from .internal.daemon_runner import is_daemon_mode, run_daemon_task
@@ -95,7 +94,6 @@ def raw_main(
raise
exit_status = ExitStatus.ERROR
else:
-check_updates(env)
try:
exit_status = main_program(
args=parsed_args,
diff --git a/httpie/internal/daemon_runner.py b/httpie/internal/daemon_runner.py
index ec20b50..b2d3fb1 100644
--- a/httpie/internal/daemon_runner.py
+++ b/httpie/internal/daemon_runner.py
@@ -3,7 +3,6 @@ from contextlib import redirect_stderr, redirect_stdout
from typing import List
from httpie.context import Environment
-from httpie.internal.update_warnings import _fetch_updates,
_get_suppress_context
from httpie.status import ExitStatus
STATUS_FILE = '.httpie-test-daemon-status'
@@ -23,7 +22,6 @@ def _check_status(env):
DAEMONIZED_TASKS = {
'check_status': _check_status,
-'fetch_updates': _fetch_updates,
}
diff --git a/httpie/internal/update_warnings.py
b/httpie/internal/update_warnings.py
deleted file mode 100644
index a4b80d4..000
--- a/httpie/internal/update_warnings.py
+++ /dev/null
@@ -1,171 +0,0 @@
-import json
-from contextlib import nullcontext, suppress
-from datetime import datetime, timedelta
-from pathlib import Path
-from typing import Any, Optional, Callable
-
-import requests
-
-import httpie
-from httpie.context import Environment, LogLevel
-from httpie.internal.__build_channel__ import BUILD_CHANNEL
-from httpie.internal.daemons import spawn_daemon
-from httpie.utils import is_version_greater, open_with_lockfile
-
-# Automatically updated package version index.
-PACKAGE_INDEX_LINK = 'https://packages.httpie.io/latest.json'
-
-FETCH_INTERVAL = timedelta(weeks=2)
-WARN_INTERVAL = timedelta(weeks=1)
-
-UPDATE_MESSAGE_FORMAT = """\
-A new HTTPie release ({last_released_version}) is available.
-To see how you can update, please visit
https://httpie.io/docs/cli/{installation_method}
-"""
-
-ALREADY_UP_TO_DATE_MESSAGE = """\
-You are already up-to-date.
-"""
-
-
-def _read_data_error_free(file: Path) -> Any:
-# If the file is broken / non-existent, ignore it.
-try:
-with open(file) as stream:
-return json.load(stream)
-except (ValueError, OSError):
-return {}
-
-
-def _fetch_updates(env: Environment) -> str:
-file = env.config.version_info_file
-data = _read_data_error_free(file)
-
-response = requests.get(PACKAGE_INDEX_LINK, verify=False)
-response.raise_for_status()
-
-data.setdefault('last_warned_date', None)
-data['last_fetched_date'] = datetime.now().isoformat()
-data['last_released_versions'] = response.json()
-
-with open_with_lockfile(file, 'w') as stream:
-json.dump(data, stream)
-
-
-def fetch_updates(env: Environment, lazy: bool = True):
-if lazy:
-spawn_daemon('fetch_updates')
-else:
-_fetch_updates(env)
-
-
-def maybe_fetch_updates(env: Environment) -> None:
-if env.config.get('disable_update_warnings'):
-return None
-
-data = _read_data_error_free(env.config.version_info_file)
-
-if data:
-current_date = datetime.now()
-last_fetched_date = datetime.fromisoformat(data['last_fetched_date'])
-earliest_fetch_date = last_fetched_date + FETCH_INTERVAL
-if current_date < earliest_fetch_date:
-return None
-
-fetch_updates(env)
-
-
-def _get_suppress_context(env: Environment) -> Any:
-"""Return a context manager that suppress
-all possible errors.
-
-Note: if you have set the developer_mode=True in
-your config, then it will show all errors for easier
-debugging."""
-if env.config.developer_mode:
-return nullcontext()
-else:
-return suppress(BaseException)
-
-
-def _update_checker(
-