Skip to content

Commit 7651c31

Browse files
committed
small updates
1 parent 6cb7e11 commit 7651c31

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

databusclient/cli.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python3
2+
import json
3+
import os
4+
25
import click
36
from typing import List
47
from databusclient import client
@@ -58,7 +61,7 @@ def download(databusuris: List[str], localdir, databus, token, authurl, clientid
5861
)
5962

6063

61-
@app.command(help="Upload files to Nextcloud and deploy to DBpedia Databus.")
64+
@app.command()
6265
@click.option(
6366
"--webdav-url", "webdav_url",
6467
help="WebDAV URL (e.g., https://cloud.example.com/remote.php/webdav)",
@@ -101,22 +104,19 @@ def download(databusuris: List[str], localdir, databus, token, authurl, clientid
101104
)
102105
def upload_and_deploy(webdav_url, remote, path, no_upload, metadata, version_id, title, abstract, description, license_url, apikey, files: List[str]):
103106
"""
104-
Deploy a dataset version with the provided metadata and distributions.
107+
Upload files to Nextcloud and deploy to DBpedia Databus.
105108
"""
106109

107110
if no_upload:
108111
if not metadata:
109-
click.echo(click.style("Error: --metadata is required when using --no-upload", fg="red"))
110-
sys.exit(1)
112+
raise click.ClickException("--metadata is required when using --no-upload")
111113
if not os.path.isfile(metadata):
112-
click.echo(click.style(f"Error: Metadata file not found: {metadata}", fg="red"))
113-
sys.exit(1)
114+
raise click.ClickException(f"Error: Metadata file not found: {metadata}")
114115
with open(metadata, 'r') as f:
115116
metadata = json.load(f)
116117
else:
117118
if not (webdav_url and remote and path):
118-
click.echo(click.style("Error: --webdav-url, --remote, and --path are required unless --no-upload is used", fg="red"))
119-
sys.exit(1)
119+
raise click.ClickException("Error: --webdav-url, --remote, and --path are required unless --no-upload is used")
120120

121121
click.echo(f"Uploading data to nextcloud: {remote}")
122122
metadata = upload.upload_to_nextcloud(files, remote, path, webdav_url)
@@ -145,7 +145,7 @@ def upload_and_deploy(webdav_url, remote, path, no_upload, metadata, version_id,
145145
compression = parts[-1]
146146

147147
distributions.append(
148-
create_distribution(
148+
client.create_distribution(
149149
url=url,
150150
cvs={"count": f"{counter}"},
151151
file_format=file_format,
@@ -155,7 +155,7 @@ def upload_and_deploy(webdav_url, remote, path, no_upload, metadata, version_id,
155155
)
156156
counter += 1
157157

158-
dataset = create_dataset(
158+
dataset = client.create_dataset(
159159
version_id=version_id,
160160
title=title,
161161
abstract=abstract,
@@ -166,7 +166,7 @@ def upload_and_deploy(webdav_url, remote, path, no_upload, metadata, version_id,
166166

167167
click.echo(f"Deploying dataset version: {version_id}")
168168

169-
deploy(dataset, api_key)
169+
deploy(dataset, apikey)
170170
metadata_string = ",\n".join([entry[-1] for entry in metadata])
171171

172172
click.echo(f"Successfully deployed\n{metadata_string}\nto databus {version_id}")

0 commit comments

Comments
 (0)