-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""The Posit SDK.""" | ||
|
||
from . import connect as connect | ||
from .cli import main as main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import io | ||
import tarfile | ||
|
||
import click | ||
|
||
from . import connect | ||
|
||
|
||
@click.group() | ||
def main(): | ||
"""The Posit command line interface.""" | ||
pass | ||
|
||
|
||
@main.group(name="connect") | ||
def _connect(): | ||
"""Work with Posit Connect.""" | ||
pass | ||
|
||
|
||
@_connect.command() | ||
@click.argument("content") | ||
@click.option("--output", "-o", default=".", help="Output directory for the downloaded content.") | ||
def download(content, output): | ||
"""Download content from Connect.""" | ||
client = connect.Client() | ||
bundle = client.content.get(content).bundles.find_one() | ||
|
||
if bundle is None: | ||
return | ||
|
||
buffer = io.BytesIO() | ||
bundle.download(buffer) | ||
buffer.seek(0) | ||
with tarfile.open(fileobj=buffer, mode="r:gz") as tar: | ||
tar.extractall(path=output, filter="data") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters