diff --git a/component-library/util/util-cos.ipynb b/component-library/util/util-cos.ipynb index 30b94d26..2e12ceac 100644 --- a/component-library/util/util-cos.ipynb +++ b/component-library/util/util-cos.ipynb @@ -45,7 +45,7 @@ "\n", "#os.environ['create_image']='True'\n", "os.environ['repository']='docker.io/romeokienzler'\n", - "os.environ['version']='0.2'\n", + "os.environ['version']='0.3'\n", "os.environ['name']='claimed-util-cos'" ] }, @@ -72,6 +72,7 @@ " RUN apt update && apt install -y python3-pip procps default-jre\n", " RUN pip install ipython nbformat aiobotocore botocore s3fs\n", " ADD util-cos.ipynb .\n", + " CMD [\"ipython\", \"util-cos.ipynb\"]\n", " \"\"\"\n", " with open(\"Dockerfile\", \"w\") as text_file:\n", " text_file.write(docker_file)\n", @@ -135,6 +136,9 @@ "# cos bucket name\n", "bucket_name = os.environ.get('bucket_name')\n", "\n", + "# path\n", + "path = os.environ.get('path','')\n", + "\n", "# operation\n", "operation = os.environ.get('operation')" ] @@ -170,6 +174,18 @@ " exec(parameter)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "b0e2aec4", + "metadata": {}, + "outputs": [], + "source": [ + "def print_list(l):\n", + " for file in l:\n", + " print(file)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -193,8 +209,12 @@ " client_kwargs={'endpoint_url': endpoint}\n", ")\n", "\n", - "if operation == 'mkbucket':\n", - " s3.mkdir(bucket_name)\n", + "if operation == 'mkdir':\n", + " s3.mkdir(bucket_name+path)\n", + "elif operation == 'ls':\n", + " print_list(s3.ls(bucket_name+path))\n", + "elif operation == 'find':\n", + " print_list(s3.find(bucket_name+path))\n", "else:\n", " print(f'operation unkonwn {operation}')" ]