Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/rsconnect/version.py
htmlcov
/tests/testdata/**/rsconnect-python/
test-home/
/docs/docs/index.md
/docs/docs/changelog.md
/rsconnect-build
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ click>=7.0.0
coverage
flake8
funcsigs
httpretty==1.1.4
importlib-metadata
ipykernel
ipython
Expand Down
53 changes: 14 additions & 39 deletions rsconnect/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,6 @@ def test_server(connect_server):
raise RSConnectException("\n".join(failures))


def test_shinyapps_server(server: api.ShinyappsServer):
with api.ShinyappsClient(server) as client:
try:
result = client.get_current_user()
server.handle_bad_response(result)
except RSConnectException as exc:
raise RSConnectException("Failed to verify with shinyapps.io ({}).".format(exc))


def test_api_key(connect_server):
"""
Test that an API Key may be used to authenticate with the given RStudio Connect server.
Expand Down Expand Up @@ -322,7 +313,7 @@ def check_server_capabilities(connect_server, capability_functions, details_sour
raise RSConnectException(message)


def _make_deployment_name(remote_server: api.TargetableServer, title: str, force_unique: bool) -> str:
def _make_deployment_name(connect_server, title, force_unique) -> str:
"""
Produce a name for a deployment based on its title. It is assumed that the
title is already defaulted and validated as appropriate (meaning the title
Expand All @@ -333,7 +324,7 @@ def _make_deployment_name(remote_server: api.TargetableServer, title: str, force
that we collapse repeating underscores and, if the name is too short, it is
padded to the left with underscores.

:param remote_server: the information needed to interact with the Connect server.
:param connect_server: the information needed to interact with the Connect server.
:param title: the title to start with.
:param force_unique: a flag noting whether the generated name must be forced to be
unique.
Expand All @@ -347,7 +338,7 @@ def _make_deployment_name(remote_server: api.TargetableServer, title: str, force

# Now, make sure it's unique, if needed.
if force_unique:
name = api.find_unique_name(remote_server, name)
name = api.find_unique_name(connect_server, name)

return name

Expand Down Expand Up @@ -1456,7 +1447,7 @@ def _generate_gather_basic_deployment_info_for_python(app_mode: AppMode) -> typi
"""

def gatherer(
remote_server: api.TargetableServer,
connect_server: api.RSConnectServer,
app_store: AppStore,
directory: str,
entry_point: str,
Expand All @@ -1465,7 +1456,7 @@ def gatherer(
title: str,
) -> typing.Tuple[str, int, str, str, bool, AppMode]:
return _gather_basic_deployment_info_for_framework(
remote_server,
connect_server,
app_store,
directory,
entry_point,
Expand All @@ -1486,7 +1477,7 @@ def gatherer(


def _gather_basic_deployment_info_for_framework(
remote_server: api.TargetableServer,
connect_server: api.RSConnectServer,
app_store: AppStore,
directory: str,
entry_point: str,
Expand All @@ -1498,7 +1489,7 @@ def _gather_basic_deployment_info_for_framework(
"""
Helps to gather the necessary info for performing a deployment.

:param remote_server: the server information.
:param connect_server: the Connect server information.
:param app_store: the store for the specified directory.
:param directory: the primary file being deployed.
:param entry_point: the entry point for the API in '<module>:<object> format. if
Expand All @@ -1523,19 +1514,13 @@ def _gather_basic_deployment_info_for_framework(
if app_id is None:
# Possible redeployment - check for saved metadata.
# Use the saved app information unless overridden by the user.
app_id, existing_app_mode = app_store.resolve(remote_server.url, app_id, app_mode)
app_id, existing_app_mode = app_store.resolve(connect_server.url, app_id, app_mode)
logger.debug("Using app mode from app %s: %s" % (app_id, app_mode))
elif app_id is not None:
# Don't read app metadata if app-id is specified. Instead, we need
# to get this from Connect.
if isinstance(remote_server, api.RSConnectServer):
app = api.get_app_info(remote_server, app_id)
existing_app_mode = AppModes.get_by_ordinal(app.get("app_mode", 0), True)
elif isinstance(remote_server, api.ShinyappsServer):
app = api.get_shinyapp_info(remote_server, app_id)
existing_app_mode = AppModes.get_by_cloud_name(app.json_data["mode"])
else:
raise RSConnectException("Unable to infer Connect client.")
app = api.get_app_info(connect_server, app_id)
existing_app_mode = AppModes.get_by_ordinal(app.get("app_mode", 0), True)
if existing_app_mode and app_mode != existing_app_mode:
msg = (
"Deploying with mode '%s',\n"
Expand All @@ -1553,7 +1538,7 @@ def _gather_basic_deployment_info_for_framework(
return (
entry_point,
app_id,
_make_deployment_name(remote_server, title, app_id is None),
_make_deployment_name(connect_server, title, app_id is None),
title,
default_title,
app_mode,
Expand Down Expand Up @@ -1712,7 +1697,7 @@ def create_quarto_deployment_bundle(


def deploy_bundle(
remote_server: api.TargetableServer,
connect_server: api.RSConnectServer,
app_id: int,
name: str,
title: str,
Expand All @@ -1723,7 +1708,7 @@ def deploy_bundle(
"""
Deploys the specified bundle.

:param remote_server: the server information.
:param connect_server: the Connect server information.
:param app_id: the ID of the app to deploy, if this is a redeploy.
:param name: the name for the deploy.
:param title: the title for the deploy.
Expand All @@ -1733,17 +1718,7 @@ def deploy_bundle(
:return: application information about the deploy. This includes the ID of the
task that may be queried for deployment progress.
"""
ce = RSConnectExecutor(
server=remote_server,
app_id=app_id,
name=name,
title=title,
title_is_default=title_is_default,
bundle=bundle,
env_vars=env_vars,
)
ce.deploy_bundle()
return ce.state["deployed_info"]
return api.do_bundle_deploy(connect_server, app_id, name, title, title_is_default, bundle, env_vars)


def spool_deployment_log(connect_server, app, log_callback):
Expand Down
14 changes: 8 additions & 6 deletions rsconnect/actions_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import json
import time
import traceback

from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime, timedelta

import semver

from .api import RSConnectClient, emit_task_log
from .api import RSConnect, emit_task_log
from .log import logger
from .models import BuildStatus, ContentGuidWithBundle
from .metadata import ContentBuildStore
Expand All @@ -35,7 +37,7 @@ def build_add_content(connect_server, content_guids_with_bundle):
+ "please wait for it to finish before adding new content."
)

with RSConnectClient(connect_server, timeout=120) as client:
with RSConnect(connect_server, timeout=120) as client:
if len(content_guids_with_bundle) == 1:
all_content = [client.content_get(content_guids_with_bundle[0].guid)]
else:
Expand Down Expand Up @@ -226,7 +228,7 @@ def _monitor_build(connect_server, content_items):

def _build_content_item(connect_server, content, poll_wait):
init_content_build_store(connect_server)
with RSConnectClient(connect_server) as client:
with RSConnect(connect_server) as client:
# Pending futures will still try to execute when ThreadPoolExecutor.shutdown() is called
# so just exit immediately if the current build has been aborted.
# ThreadPoolExecutor.shutdown(cancel_futures=) isnt available until py3.9
Expand Down Expand Up @@ -290,7 +292,7 @@ def download_bundle(connect_server, guid_with_bundle):
"""
:param guid_with_bundle: models.ContentGuidWithBundle
"""
with RSConnectClient(connect_server, timeout=120) as client:
with RSConnect(connect_server, timeout=120) as client:
# bundle_id not provided so grab the latest
if not guid_with_bundle.bundle_id:
content = client.get_content(guid_with_bundle.guid)
Expand All @@ -309,7 +311,7 @@ def get_content(connect_server, guid):
:param guid: a single guid as a string or list of guids.
:return: a list of content items.
"""
with RSConnectClient(connect_server, timeout=120) as client:
with RSConnect(connect_server, timeout=120) as client:
if isinstance(guid, str):
result = [client.get_content(guid)]
else:
Expand All @@ -320,7 +322,7 @@ def get_content(connect_server, guid):
def search_content(
connect_server, published, unpublished, content_type, r_version, py_version, title_contains, order_by
):
with RSConnectClient(connect_server, timeout=120) as client:
with RSConnect(connect_server, timeout=120) as client:
result = client.search_content()
result = _apply_content_filters(
result, published, unpublished, content_type, r_version, py_version, title_contains
Expand Down
Loading