Skip to content

Commit

Permalink
cli: upload multiple files
Browse files Browse the repository at this point in the history
closes: cernanalysispreservation#79

Signed-off-by: Ana Trisovic <ana.trisovic@gmail.com>
  • Loading branch information
atrisovic committed Jul 24, 2018
1 parent 1d91d31 commit abac740
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
20 changes: 12 additions & 8 deletions cap_client/cli/files_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def files():
default=None,
required=True
)
@click.argument('file', type=click.Path(exists=False))
@click.argument('files', type=click.Path(exists=False), nargs=-1)
@click.option(
'--output-file',
'-o',
Expand All @@ -63,17 +63,21 @@ def files():
help="Uploads docker image."
)
@click.pass_context
def upload(ctx, pid, file, yes, output_file=None, docker=False):
def upload(ctx, pid, files, yes, output_file=None, docker=False):
"""Upload file to deposit with given pid."""
try:
if docker:
ctx.obj.cap_api.upload_docker_img(pid=pid, img_name=file,
output_img_name=output_file)
for _file in files:
ctx.obj.cap_api.upload_docker_img(
pid=pid, img_name=_file,
output_img_name=output_file)
click.echo("Docker image " + _file + " uploaded successfully.")
else:
ctx.obj.cap_api.upload_file(
pid=pid, filepath=file,
output_filename=output_file, yes=yes)
click.echo("File uploaded successfully.")
for _file in files:
ctx.obj.cap_api.upload_file(
pid=pid, filepath=_file,
output_filename=output_file, yes=yes)
click.echo(_file + " uploaded successfully.")

except BadStatusCode as e:
logging.error(str(e))
Expand Down
24 changes: 20 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ You need to specify
Upload file
-----------

You can upload a file to an analysis only if you have at least read access to it.
You can upload a file (or multiple files) to an analysis only if you have at least read access to it.

You need to specify

Expand All @@ -566,13 +566,21 @@ You need to specify
$ cap-client files upload file.json -p 89b593c498874ec8bcafc88944c458a7
File uploaded successfully.
file.json uploaded successfully.
$ cap-client files upload config.txt history.txt dict.json -p bf6b8501822c4d2ba46028611354df7e
config.txt uploaded successfully.
history.txt uploaded successfully.
dict.json uploaded successfully.
Upload Docker image
-----------

With the client, you can upload a Docker image that is associated to the analysis. Make sure that the image is present in the system by running the command `docker images` in the command line. The image name should be in the list. In the examples below we use an image called `hello-world`.
With the client, you can upload Docker images that are associated to the analysis. Make sure that the image is present in the system by running the command `docker images` in the command line. The image name should be in the list. In the examples below we use an image called `hello-world`.

You need to specify

Expand All @@ -585,9 +593,17 @@ To upload the image use the command:
$ cap-client files upload hello-world --docker --pid 1ed645539e08435ea1bd4aad1360e87b
Docker image hello-world uploaded successfully.
$ cap-client files upload hello-world centos --docker -p bf6b8501822c4d2ba46028611354df7e
Docker image hello-world uploaded successfully.
Docker image centos uploaded successfully.
Optionally you can specify

--output-file the output file name of the image; by default it is the same as the original image name
--output-file the output file name of an image; by default it is the same as the original image name

To upload the image with an output file name use the command:

Expand Down

0 comments on commit abac740

Please sign in to comment.