mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-07 00:13:59 -04:00
Tools: scripts: run_lua_language_check: grab and install latest release
This commit is contained in:
parent
3a7bf8dd7d
commit
5e52c7021a
@ -12,6 +12,7 @@ import os
|
|||||||
import pathlib
|
import pathlib
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
|
import platform
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +65,29 @@ if __name__ == '__main__':
|
|||||||
if os.path.exists(logs) and len(os.listdir(logs)) != 0:
|
if os.path.exists(logs) and len(os.listdir(logs)) != 0:
|
||||||
raise Exception("lualogs not empty")
|
raise Exception("lualogs not empty")
|
||||||
|
|
||||||
|
install_path = (ap_root / "lua-language-server").resolve()
|
||||||
|
|
||||||
|
# See if there is a new version (only try on Linux)
|
||||||
|
if platform.system() == "Linux":
|
||||||
|
from github_release_downloader import check_and_download_updates, GitHubRepo
|
||||||
|
import re
|
||||||
|
asset_re = re.compile(r".*linux-x64\.tar\.gz")
|
||||||
|
check_and_download_updates(
|
||||||
|
GitHubRepo("LuaLS", "lua-language-server"),
|
||||||
|
assets_mask=asset_re,
|
||||||
|
downloads_dir=ap_root,
|
||||||
|
)
|
||||||
|
for filename in os.listdir(ap_root):
|
||||||
|
if asset_re.match(filename):
|
||||||
|
pack_path = (ap_root / filename).resolve()
|
||||||
|
shutil.unpack_archive(pack_path, install_path)
|
||||||
|
os.remove(pack_path)
|
||||||
|
|
||||||
|
run_path = (install_path / "bin/lua-language-server")
|
||||||
|
if not os.path.isfile(run_path):
|
||||||
|
# Try and use version from path
|
||||||
|
run_path = "lua-language-server"
|
||||||
|
|
||||||
# Can't get the lua-language-server to find docs outside of workspace, so just copy in and then delete
|
# Can't get the lua-language-server to find docs outside of workspace, so just copy in and then delete
|
||||||
docs_check_path = (pathlib.Path(os.getcwd()) / check_path).resolve()
|
docs_check_path = (pathlib.Path(os.getcwd()) / check_path).resolve()
|
||||||
if os.path.isfile(docs_check_path):
|
if os.path.isfile(docs_check_path):
|
||||||
@ -78,7 +102,7 @@ if __name__ == '__main__':
|
|||||||
shutil.copyfile(docs, docs_copy)
|
shutil.copyfile(docs, docs_copy)
|
||||||
|
|
||||||
# Run check
|
# Run check
|
||||||
os.system("lua-language-server --configpath %s --logpath %s --check %s" % (setup, logs, check_path))
|
os.system("%s --configpath %s --logpath %s --check %s" % (run_path, setup, logs, check_path))
|
||||||
|
|
||||||
if docs_copy is not None:
|
if docs_copy is not None:
|
||||||
# remove copy of docs
|
# remove copy of docs
|
||||||
@ -93,9 +117,10 @@ if __name__ == '__main__':
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Print output
|
if len(data) > 0:
|
||||||
for key, value in data.items():
|
# Print output if there are any errors
|
||||||
errors += print_failures(key, value)
|
for key, value in data.items():
|
||||||
|
errors += print_failures(key, value)
|
||||||
|
|
||||||
# Remove output
|
# Remove output
|
||||||
shutil.rmtree(logs)
|
shutil.rmtree(logs)
|
||||||
|
Loading…
Reference in New Issue
Block a user