Extensions: New status message when checking for update #122378
@ -168,6 +168,7 @@ def sync_status_generator(repos_notify):
|
||||
cmd_batch_partial.append(partial(
|
||||
bl_extension_utils.repo_sync,
|
||||
directory=repo_item.directory,
|
||||
remote_name=repo_item.name,
|
||||
remote_url=bl_extension_ops.url_params_append_defaults(repo_item.remote_url),
|
||||
online_user_agent=bl_extension_ops.online_user_agent_from_blender(),
|
||||
access_token=repo_item.access_token if repo_item.use_access_token else "",
|
||||
|
@ -1007,6 +1007,7 @@ class BlPkgRepoSync(Operator, _BlPkgCmdMixIn):
|
||||
partial(
|
||||
bl_extension_utils.repo_sync,
|
||||
directory=directory,
|
||||
remote_name=repo_item.name,
|
||||
remote_url=url_params_append_defaults(repo_item.remote_url),
|
||||
online_user_agent=online_user_agent_from_blender(),
|
||||
access_token=repo_item.access_token,
|
||||
@ -1084,6 +1085,7 @@ class BlPkgRepoSyncAll(Operator, _BlPkgCmdMixIn):
|
||||
cmd_batch.append(partial(
|
||||
bl_extension_utils.repo_sync,
|
||||
directory=repo_item.directory,
|
||||
remote_name=repo_item.name,
|
||||
remote_url=url_params_append_defaults(repo_item.remote_url),
|
||||
online_user_agent=online_user_agent_from_blender(),
|
||||
access_token=repo_item.access_token,
|
||||
|
@ -350,6 +350,7 @@ def url_params_append_for_blender(url: str, blender_version: Tuple[int, int, int
|
||||
def repo_sync(
|
||||
*,
|
||||
directory: str,
|
||||
remote_name: str,
|
||||
remote_url: str,
|
||||
online_user_agent: str,
|
||||
access_token: str,
|
||||
@ -364,6 +365,7 @@ def repo_sync(
|
||||
yield from command_output_from_json_0([
|
||||
"sync",
|
||||
"--local-dir", directory,
|
||||
"--remote-name", remote_name,
|
||||
"--remote-url", remote_url,
|
||||
"--online-user-agent", online_user_agent,
|
||||
"--access-token", access_token,
|
||||
|
@ -1645,6 +1645,7 @@ def repo_local_private_dir_ensure_with_subdir(*, local_dir: str, subdir: str) ->
|
||||
def repo_sync_from_remote(
|
||||
*,
|
||||
msg_fn: MessageFn,
|
||||
remote_name: str,
|
||||
remote_url: str,
|
||||
local_dir: str,
|
||||
online_user_agent: str,
|
||||
@ -1656,7 +1657,7 @@ def repo_sync_from_remote(
|
||||
Load package information into the local path.
|
||||
"""
|
||||
request_exit = False
|
||||
request_exit |= message_status(msg_fn, "Sync repo: {:s}".format(remote_url))
|
||||
request_exit |= message_status(msg_fn, "Checking repository \"{:s}\" for updates...".format(remote_name))
|
||||
dfelinto marked this conversation as resolved
Outdated
|
||||
if request_exit:
|
||||
return False
|
||||
|
||||
@ -1675,7 +1676,7 @@ def repo_sync_from_remote(
|
||||
|
||||
with CleanupPathsContext(files=(local_json_path_temp,), directories=()):
|
||||
# TODO: time-out.
|
||||
request_exit |= message_status(msg_fn, "Sync downloading remote data")
|
||||
request_exit |= message_status(msg_fn, "Refreshing extensions list for \"{:s}\"...".format(remote_name))
|
||||
if request_exit:
|
||||
return False
|
||||
|
||||
@ -1706,11 +1707,15 @@ def repo_sync_from_remote(
|
||||
|
||||
error_msg = repo_json_is_valid_or_error(local_json_path_temp)
|
||||
if error_msg is not None:
|
||||
message_error(msg_fn, "sync: invalid manifest ({:s}) reading {!r}!".format(error_msg, remote_url))
|
||||
message_error(
|
||||
msg_fn,
|
||||
"Repository error: invalid manifest ({:s}) for repository \"{:s}\"!".format(
|
||||
error_msg,
|
||||
remote_name))
|
||||
return False
|
||||
del error_msg
|
||||
|
||||
request_exit |= message_status(msg_fn, "Sync complete: {:s}".format(remote_url))
|
||||
request_exit |= message_status(msg_fn, "Extensions list for \"{:s}\" updated".format(remote_name))
|
||||
if request_exit:
|
||||
return False
|
||||
|
||||
@ -1838,6 +1843,19 @@ def generic_arg_repo_dir(subparse: argparse.ArgumentParser) -> None:
|
||||
)
|
||||
|
||||
|
||||
def generic_arg_remote_name(subparse: argparse.ArgumentParser) -> None:
|
||||
subparse.add_argument(
|
||||
"--remote-name",
|
||||
dest="remote_name",
|
||||
type=str,
|
||||
help=(
|
||||
"The remote repository name."
|
||||
),
|
||||
default="",
|
||||
required=False,
|
||||
)
|
||||
|
||||
|
||||
def generic_arg_remote_url(subparse: argparse.ArgumentParser) -> None:
|
||||
subparse.add_argument(
|
||||
"--remote-url",
|
||||
@ -2167,6 +2185,7 @@ class subcmd_client:
|
||||
msg_fn: MessageFn,
|
||||
*,
|
||||
remote_url: str,
|
||||
remote_name: str,
|
||||
local_dir: str,
|
||||
online_user_agent: str,
|
||||
access_token: str,
|
||||
@ -2179,6 +2198,7 @@ class subcmd_client:
|
||||
|
||||
success = repo_sync_from_remote(
|
||||
msg_fn=msg_fn,
|
||||
remote_name=remote_name,
|
||||
remote_url=remote_url,
|
||||
local_dir=local_dir,
|
||||
online_user_agent=online_user_agent,
|
||||
@ -3022,6 +3042,7 @@ def argparse_create_client_sync(subparsers: "argparse._SubParsersAction[argparse
|
||||
)
|
||||
|
||||
generic_arg_remote_url(subparse)
|
||||
generic_arg_remote_name(subparse)
|
||||
generic_arg_local_dir(subparse)
|
||||
generic_arg_online_user_agent(subparse)
|
||||
generic_arg_access_token(subparse)
|
||||
@ -3035,6 +3056,7 @@ def argparse_create_client_sync(subparsers: "argparse._SubParsersAction[argparse
|
||||
func=lambda args: subcmd_client.sync(
|
||||
msg_fn_from_args(args),
|
||||
remote_url=args.remote_url,
|
||||
remote_name=args.remote_name if args.remote_name else remote_url_params_strip(args.remote_url),
|
||||
local_dir=args.local_dir,
|
||||
online_user_agent=args.online_user_agent,
|
||||
access_token=args.access_token,
|
||||
|
@ -79,6 +79,23 @@ STATUS_NON_ERROR = {'STATUS', 'PROGRESS'}
|
||||
# Generic Utilities
|
||||
#
|
||||
|
||||
def remote_url_params_strip(url: str) -> str:
|
||||
import urllib
|
||||
# Parse the URL to get its scheme, domain, and query parameters.
|
||||
parsed_url = urllib.parse.urlparse(url)
|
||||
|
||||
# Combine the scheme, netloc, path without any other parameters, stripping the URL.
|
||||
new_url = urllib.parse.urlunparse((
|
||||
parsed_url.scheme,
|
||||
parsed_url.netloc,
|
||||
parsed_url.path,
|
||||
None, # `parsed_url.params,`
|
||||
None, # `parsed_url.query,`
|
||||
None, # `parsed_url.fragment,`
|
||||
))
|
||||
|
||||
return new_url
|
||||
|
||||
def path_to_url(path: str) -> str:
|
||||
from urllib.parse import urljoin
|
||||
from urllib.request import pathname2url
|
||||
@ -341,6 +358,7 @@ class TestCLI_WithRepo(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_client_install_and_uninstall(self) -> None:
|
||||
stripped_url = remote_url_params_strip(self.dirpath_url)
|
||||
with tempfile.TemporaryDirectory(dir=TEMP_DIR_LOCAL) as temp_dir_local:
|
||||
# TODO: only run once.
|
||||
self.test_server_generate()
|
||||
@ -352,9 +370,9 @@ class TestCLI_WithRepo(unittest.TestCase):
|
||||
], exclude_types={"PROGRESS"})
|
||||
self.assertEqual(
|
||||
output_json, [
|
||||
('STATUS', 'Sync repo: ' + self.dirpath_url),
|
||||
('STATUS', 'Sync downloading remote data'),
|
||||
('STATUS', 'Sync complete: ' + self.dirpath_url),
|
||||
('STATUS', "Checking repository \"{:s}\" for updates...".format(stripped_url)),
|
||||
('STATUS', "Refreshing extensions list for \"{:s}\"...".format(stripped_url)),
|
||||
('STATUS', "Extensions list for \"{:s}\" updated".format(stripped_url)),
|
||||
]
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
Prefer to use
str.format
over f-strings. Also oter strings in this PR.