|
46 | 46 | # they should both come from the same typing module.
|
47 | 47 | # https://peps.python.org/pep-0655/#usage-in-python-3-11
|
48 | 48 | if sys.version_info >= (3, 11):
|
49 |
| - from typing import NotRequired, TypedDict |
| 49 | + from typing import TypedDict |
50 | 50 | else:
|
51 |
| - from typing_extensions import NotRequired, TypedDict |
| 51 | + from typing_extensions import TypedDict |
52 | 52 |
|
53 | 53 | from . import validation
|
54 | 54 | from .bundle import _default_title
|
@@ -331,10 +331,11 @@ def __init__(self, url: str):
|
331 | 331 |
|
332 | 332 |
|
333 | 333 | class RSConnectClientDeployResult(TypedDict):
|
334 |
| - task_id: NotRequired[str] |
| 334 | + task_id: str | None |
335 | 335 | app_id: str
|
336 |
| - app_guid: str |
| 336 | + app_guid: str | None |
337 | 337 | app_url: str
|
| 338 | + preview_url: str | None |
338 | 339 | title: str | None
|
339 | 340 |
|
340 | 341 |
|
@@ -569,11 +570,17 @@ def deploy(
|
569 | 570 |
|
570 | 571 | task = self.content_deploy(app_guid, app_bundle["id"], activate=activate)
|
571 | 572 |
|
| 573 | + # http://ADDRESS/preview/APP_GUID/BUNDLE_ID |
| 574 | + # Using replace makes this a bit more robust to changes in the URL structure |
| 575 | + # like connect being served on a subpath. |
| 576 | + preview_url = app["url"].replace("/content/", "/preview/") + f"/{app_bundle['id']}" |
| 577 | + |
572 | 578 | return {
|
573 | 579 | "task_id": task["task_id"],
|
574 | 580 | "app_id": app_id,
|
575 | 581 | "app_guid": app["guid"],
|
576 | 582 | "app_url": app["url"],
|
| 583 | + "preview_url": preview_url if not activate else None, |
577 | 584 | "title": app["title"],
|
578 | 585 | }
|
579 | 586 |
|
@@ -1079,12 +1086,14 @@ def deploy_bundle(self, activate: bool = True):
|
1079 | 1086 | print("Application successfully deployed to {}".format(prepare_deploy_result.app_url))
|
1080 | 1087 | webbrowser.open_new(prepare_deploy_result.app_url)
|
1081 | 1088 |
|
1082 |
| - self.deployed_info = { |
1083 |
| - "app_url": prepare_deploy_result.app_url, |
1084 |
| - "app_id": prepare_deploy_result.app_id, |
1085 |
| - "app_guid": None, |
1086 |
| - "title": self.title, |
1087 |
| - } |
| 1089 | + self.deployed_info = RSConnectClientDeployResult( |
| 1090 | + app_url=prepare_deploy_result.app_url, |
| 1091 | + app_id=str(prepare_deploy_result.app_id), |
| 1092 | + app_guid=None, |
| 1093 | + task_id=None, |
| 1094 | + preview_url=None, |
| 1095 | + title=self.title, |
| 1096 | + ) |
1088 | 1097 | return self
|
1089 | 1098 |
|
1090 | 1099 | def emit_task_log(
|
@@ -1127,7 +1136,9 @@ def emit_task_log(
|
1127 | 1136 | app_dashboard_url = app_config.get("config_url")
|
1128 | 1137 | log_callback.info("Deployment completed successfully.")
|
1129 | 1138 | log_callback.info("\t Dashboard content URL: %s", app_dashboard_url)
|
1130 |
| - log_callback.info("\t Direct content URL: %s", self.deployed_info["app_url"]) |
| 1139 | + log_callback.info( |
| 1140 | + "\t Direct content URL: %s", self.deployed_info["preview_url"] or self.deployed_info["app_url"] |
| 1141 | + ) |
1131 | 1142 |
|
1132 | 1143 | return self
|
1133 | 1144 |
|
|
0 commit comments