1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
From: Denis Danilov <danilovdenis@yandex.ru>
Date: Sun, 16 Oct 2022 10:00:00 +0200
Subject: remove online updater
Forwarded: not-needed
---
fortls/langserver.py | 62 --------------------------------------------------
test/test_interface.py | 23 -------------------
2 files changed, 85 deletions(-)
diff --git a/fortls/langserver.py b/fortls/langserver.py
index c11f60c..ff34afc 100644
--- a/fortls/langserver.py
+++ b/fortls/langserver.py
@@ -203,11 +203,6 @@ class LangServer:
self._config_logger(request)
self._load_intrinsics()
self._add_source_dirs()
- if self._update_version_pypi():
- self.post_message(
- "Please restart the server for the new version to activate",
- Severity.info,
- )
# Initialize workspace
self.workspace_init()
@@ -1776,63 +1771,6 @@ class LangServer:
schar = echar = 0
return uri_json(path_to_uri(obj_file.path), sline, schar, sline, echar)
- def _update_version_pypi(self, test: bool = False):
- """Fetch updates from PyPi for fortls
-
- Parameters
- ----------
- test : bool, optional
- flag used to override exit checks, only for unittesting, by default False
- """
- if self.disable_autoupdate:
- return False
- # Do not run for prerelease and dev release
- if self._version.is_prerelease and not test:
- return False
- try:
- # For security reasons register as Request before opening
- request = urllib.request.Request("https://pypi.org/pypi/fortls/json")
- with urllib.request.urlopen(request) as resp:
- info = json.loads(resp.read().decode("utf-8"))
- remote_v = version.parse(info["info"]["version"])
- # Do not update from remote if it is a prerelease
- if remote_v.is_prerelease:
- return False
- # This is the only reliable way to compare version semantics
- if remote_v > self._version or test:
- self.post_message(
- "A newer version of fortls is available for download",
- Severity.info,
- )
- # Anaconda environments should handle their updates through conda
- if os.path.exists(os.path.join(sys.prefix, "conda-meta")):
- return False
- self.post_message(
- f"Downloading from PyPi fortls {info['info']['version']}",
- Severity.info,
- )
- # Run pip
- result = subprocess.run(
- [
- sys.executable,
- "-m",
- "pip",
- "install",
- "fortls",
- "--upgrade",
- "--user",
- ],
- capture_output=True,
- )
- if result.stdout:
- log.info(result.stdout.decode("utf-8"))
- if result.stderr:
- log.error(result.stderr.decode("utf-8"))
- return True
- # No internet connection exceptions
- except (URLError, KeyError):
- self.post_message("Failed to update the fortls", Severity.warn)
- return False
def update_recursion_limit(limit: int) -> None:
diff --git a/test/test_interface.py b/test/test_interface.py
index 764ac56..e17263a 100644
--- a/test/test_interface.py
+++ b/test/test_interface.py
@@ -163,26 +163,3 @@ def test_config_file_codeactions_options():
server, root = unittest_server_init()
# Code Actions options
assert server.enable_code_actions
-
-
-def test_version_update_pypi():
- from packaging import version
-
- from fortls.jsonrpc import JSONRPC2Connection, ReadWriter
-
- stdin, stdout = sys.stdin.buffer, sys.stdout.buffer
- s, root = unittest_server_init(JSONRPC2Connection(ReadWriter(stdin, stdout)))
- s.disable_autoupdate = False
-
- did_update = s._update_version_pypi(test=True)
- isconda = os.path.exists(os.path.join(sys.prefix, "conda-meta"))
- assert not did_update if isconda else did_update
-
- s.disable_autoupdate = True
- did_update = s._update_version_pypi()
- assert not did_update
-
- s.disable_autoupdate = False
- s._version = version.parse("999.0.0")
- did_update = s._update_version_pypi()
- assert not did_update
|