|
17 | 17 | else: |
18 | 18 | from typing_extensions import ParamSpec |
19 | 19 |
|
| 20 | +if sys.version_info >= (3, 11): |
| 21 | + from typing import Never |
| 22 | +else: |
| 23 | + from typing_extensions import Never |
| 24 | + |
20 | 25 | from rsconnect.certificates import read_certificate_file |
21 | 26 |
|
22 | 27 | from . import VERSION, api, validation |
|
101 | 106 | def cli_exception_handler(func: Callable[P, T]) -> Callable[P, T]: |
102 | 107 | @wraps(func) |
103 | 108 | def wrapper(*args: P.args, **kwargs: P.kwargs): |
104 | | - def failed(err: str): |
| 109 | + def failed(err: str) -> Never: |
105 | 110 | click.secho(str(err), fg="bright_red", err=False) |
106 | 111 | sys.exit(1) |
107 | 112 |
|
@@ -643,6 +648,8 @@ def details( |
643 | 648 | set_verbosity(verbose) |
644 | 649 |
|
645 | 650 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert).validate_server() |
| 651 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 652 | + raise RSConnectException("`rsconnect details` requires a Posit Connect server.") |
646 | 653 |
|
647 | 654 | click.echo(" Posit Connect URL: %s" % ce.remote_server.url) |
648 | 655 |
|
@@ -2102,13 +2109,6 @@ def _write_framework_manifest( |
2102 | 2109 | write_environment_file(environment, directory) |
2103 | 2110 |
|
2104 | 2111 |
|
2105 | | -def _validate_build_rm_args(guid: str, all: bool, purge: bool): |
2106 | | - if guid and all: |
2107 | | - raise RSConnectException("You must specify only one of -g/--guid or --all, not both.") |
2108 | | - if not guid and not all: |
2109 | | - raise RSConnectException("You must specify one of -g/--guid or --all.") |
2110 | | - |
2111 | | - |
2112 | 2112 | @cli.group(no_args_is_help=True, help="Interact with Posit Connect's content API.") |
2113 | 2113 | def content(): |
2114 | 2114 | pass |
@@ -2217,6 +2217,8 @@ def content_describe( |
2217 | 2217 | output_params(ctx, locals().items()) |
2218 | 2218 | with cli_feedback("", stderr=True): |
2219 | 2219 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2220 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2221 | + raise RSConnectException("`rsconnect content describe` requires a Posit Connect server.") |
2220 | 2222 | result = get_content(ce.remote_server, guid) |
2221 | 2223 | json.dump(result, sys.stdout, indent=2) |
2222 | 2224 |
|
@@ -2264,6 +2266,8 @@ def content_bundle_download( |
2264 | 2266 | output_params(ctx, locals().items()) |
2265 | 2267 | with cli_feedback("", stderr=True): |
2266 | 2268 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2269 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2270 | + raise RSConnectException("`rsconnect content download-bundle` requires a Posit Connect server.") |
2267 | 2271 | if exists(output) and not overwrite: |
2268 | 2272 | raise RSConnectException("The output file already exists: %s" % output) |
2269 | 2273 |
|
@@ -2306,6 +2310,8 @@ def add_content_build( |
2306 | 2310 | output_params(ctx, locals().items()) |
2307 | 2311 | with cli_feedback("", stderr=True): |
2308 | 2312 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2313 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2314 | + raise RSConnectException("`rsconnect content build add` requires a Posit Connect server.") |
2309 | 2315 | build_add_content(ce.remote_server, guid) |
2310 | 2316 | if len(guid) == 1: |
2311 | 2317 | logger.info('Added "%s".' % guid[0]) |
@@ -2356,7 +2362,8 @@ def remove_content_build( |
2356 | 2362 | output_params(ctx, locals().items()) |
2357 | 2363 | with cli_feedback("", stderr=True): |
2358 | 2364 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
2359 | | - _validate_build_rm_args(guid, all, purge) |
| 2365 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2366 | + raise RSConnectException("`rsconnect content build rm` requires a Posit Connect server.") |
2360 | 2367 | guids = build_remove_content(ce.remote_server, guid, all, purge) |
2361 | 2368 | if len(guids) == 1: |
2362 | 2369 | logger.info('Removed "%s".' % guids[0]) |
@@ -2400,6 +2407,8 @@ def list_content_build( |
2400 | 2407 | output_params(ctx, locals().items()) |
2401 | 2408 | with cli_feedback("", stderr=True): |
2402 | 2409 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2410 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2411 | + raise RSConnectException("`rsconnect content build ls` requires a Posit Connect server.") |
2403 | 2412 | result = build_list_content(ce.remote_server, guid, status) |
2404 | 2413 | json.dump(result, sys.stdout, indent=2) |
2405 | 2414 |
|
@@ -2432,6 +2441,8 @@ def get_build_history( |
2432 | 2441 | with cli_feedback("", stderr=True): |
2433 | 2442 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert) |
2434 | 2443 | ce.validate_server() |
| 2444 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2445 | + raise RSConnectException("`rsconnect content build history` requires a Posit Connect server.") |
2435 | 2446 | result = build_history(ce.remote_server, guid) |
2436 | 2447 | json.dump(result, sys.stdout, indent=2) |
2437 | 2448 |
|
@@ -2481,6 +2492,8 @@ def get_build_logs( |
2481 | 2492 | output_params(ctx, locals().items()) |
2482 | 2493 | with cli_feedback("", stderr=True): |
2483 | 2494 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2495 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2496 | + raise RSConnectException("`rsconnect content build logs` requires a Posit Connect server.") |
2484 | 2497 | for line in emit_build_log(ce.remote_server, guid, format, task_id): |
2485 | 2498 | sys.stdout.write(line) |
2486 | 2499 |
|
@@ -2548,6 +2561,8 @@ def start_content_build( |
2548 | 2561 | logger.set_log_output_format(format) |
2549 | 2562 | with cli_feedback("", stderr=True): |
2550 | 2563 | ce = RSConnectExecutor(ctx, name, server, api_key, insecure, cacert, logger=None).validate_server() |
| 2564 | + if not isinstance(ce.remote_server, RSConnectServer): |
| 2565 | + raise RSConnectException("rsconnect content build run` requires a Posit Connect server.") |
2551 | 2566 | build_start(ce.remote_server, parallelism, aborted, error, running, retry, all, poll_wait, debug) |
2552 | 2567 |
|
2553 | 2568 |
|
|
0 commit comments