dds-cli 0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. dds_cli-0.0/LICENSE +21 -0
  2. dds_cli-0.0/PKG-INFO +74 -0
  3. dds_cli-0.0/README.md +51 -0
  4. dds_cli-0.0/dds_cli/__init__.py +144 -0
  5. dds_cli-0.0/dds_cli/__main__.py +1290 -0
  6. dds_cli-0.0/dds_cli/account_manager.py +236 -0
  7. dds_cli-0.0/dds_cli/auth.py +50 -0
  8. dds_cli-0.0/dds_cli/base.py +233 -0
  9. dds_cli-0.0/dds_cli/cli_decorators.py +193 -0
  10. dds_cli-0.0/dds_cli/data_getter.py +239 -0
  11. dds_cli-0.0/dds_cli/data_lister.py +604 -0
  12. dds_cli-0.0/dds_cli/data_putter.py +408 -0
  13. dds_cli-0.0/dds_cli/data_remover.py +177 -0
  14. dds_cli-0.0/dds_cli/directory.py +48 -0
  15. dds_cli-0.0/dds_cli/exceptions.py +97 -0
  16. dds_cli-0.0/dds_cli/file_compressor.py +154 -0
  17. dds_cli-0.0/dds_cli/file_encryptor.py +268 -0
  18. dds_cli-0.0/dds_cli/file_handler.py +97 -0
  19. dds_cli-0.0/dds_cli/file_handler_local.py +298 -0
  20. dds_cli-0.0/dds_cli/file_handler_remote.py +165 -0
  21. dds_cli-0.0/dds_cli/options.py +310 -0
  22. dds_cli-0.0/dds_cli/project_creator.py +84 -0
  23. dds_cli-0.0/dds_cli/project_status.py +135 -0
  24. dds_cli-0.0/dds_cli/s3_connector.py +121 -0
  25. dds_cli-0.0/dds_cli/status.py +58 -0
  26. dds_cli-0.0/dds_cli/text_handler.py +83 -0
  27. dds_cli-0.0/dds_cli/timestamp.py +52 -0
  28. dds_cli-0.0/dds_cli/user.py +324 -0
  29. dds_cli-0.0/dds_cli/utils.py +124 -0
  30. dds_cli-0.0/dds_cli.egg-info/PKG-INFO +74 -0
  31. dds_cli-0.0/dds_cli.egg-info/SOURCES.txt +41 -0
  32. dds_cli-0.0/dds_cli.egg-info/dependency_links.txt +1 -0
  33. dds_cli-0.0/dds_cli.egg-info/entry_points.txt +3 -0
  34. dds_cli-0.0/dds_cli.egg-info/not-zip-safe +1 -0
  35. dds_cli-0.0/dds_cli.egg-info/requires.txt +20 -0
  36. dds_cli-0.0/dds_cli.egg-info/top_level.txt +2 -0
  37. dds_cli-0.0/pyproject.toml +3 -0
  38. dds_cli-0.0/setup.cfg +4 -0
  39. dds_cli-0.0/setup.py +50 -0
  40. dds_cli-0.0/tests/__init__.py +0 -0
  41. dds_cli-0.0/tests/conftest.py +38 -0
  42. dds_cli-0.0/tests/test_add_user.py +118 -0
  43. dds_cli-0.0/tests/test_list.py +428 -0
dds_cli-0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 SciLifeLab Data Centre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dds_cli-0.0/PKG-INFO ADDED
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.1
2
+ Name: dds_cli
3
+ Version: 0.0
4
+ Summary: A command line tool to manage data and projects in the SciLifeLab Data Delivery System.
5
+ Home-page: https://github.com/ScilifelabDataCentre/dds_cli
6
+ Author: SciLifeLab Data Centre
7
+ Author-email: datacentre@scilifelab.se
8
+ License: MIT
9
+ Keywords: data delivery research science scilifelab
10
+ Platform: UNKNOWN
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Software Development :: Build Tools
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+
22
+ # SciLifeLab Data Delivery System - Command line interface
23
+
24
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
25
+ [![install with PyPI](https://img.shields.io/badge/install%20with-PyPI-blue.svg)](https://pypi.org/project/dds_cli/)
26
+
27
+ > **A command line tool `dds` to manage data and projects in the SciLifeLab Data Delivery Service.**
28
+
29
+ This will be used for data delivery within larger projects and/or projects resulting in the production of large amounts of data, for example next-generation sequencing data and imaging.
30
+
31
+ This tool is written and maintained by the [SciLifeLab Data Centre](https://www.scilifelab.se/data).
32
+
33
+ ## Table of contents
34
+
35
+ * [Installation](#installation)
36
+ * [Overview of commands](#overview-of-commands)
37
+
38
+ ## Installation
39
+
40
+ ### Python Package Index
41
+
42
+ > :warning: Not available yet - coming soon after first release :warning:
43
+
44
+ The `dds-cli` package can be installed from [PyPI](https://pypi.python.org/pypi/dds_cli/) using pip as follows:
45
+
46
+ ```bash
47
+ pip install dds_cli
48
+ ```
49
+
50
+ ### Development version
51
+
52
+ If you would like the latest development version of tools, the command is:
53
+
54
+ ```bash
55
+ pip install --upgrade --force-reinstall git+https://github.com/ScilifelabDataCentre/dds_cli.git@dev
56
+ ```
57
+
58
+ If you intend to make edits to the code, first make a fork of the repository and then clone it locally.
59
+ Go to the cloned directory and install with pip (also installs development requirements):
60
+
61
+ ```bash
62
+ pip install --upgrade -r requirements-dev.txt -e .
63
+ ```
64
+
65
+ ## Overview of commands
66
+
67
+ Once installed you can use the command `dds` in a terminal session. This has the following subcommands:
68
+
69
+ * `get` - Download specified files from the cloud and restore the original format.
70
+ * `ls` - List the projects and the files within projects.
71
+ * `put` - Process and upload specified files to the cloud.
72
+ * `rm` - Delete files within a project.
73
+
74
+
dds_cli-0.0/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # SciLifeLab Data Delivery System - Command line interface
2
+
3
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
4
+ [![install with PyPI](https://img.shields.io/badge/install%20with-PyPI-blue.svg)](https://pypi.org/project/dds_cli/)
5
+
6
+ > **A command line tool `dds` to manage data and projects in the SciLifeLab Data Delivery Service.**
7
+
8
+ This will be used for data delivery within larger projects and/or projects resulting in the production of large amounts of data, for example next-generation sequencing data and imaging.
9
+
10
+ This tool is written and maintained by the [SciLifeLab Data Centre](https://www.scilifelab.se/data).
11
+
12
+ ## Table of contents
13
+
14
+ * [Installation](#installation)
15
+ * [Overview of commands](#overview-of-commands)
16
+
17
+ ## Installation
18
+
19
+ ### Python Package Index
20
+
21
+ > :warning: Not available yet - coming soon after first release :warning:
22
+
23
+ The `dds-cli` package can be installed from [PyPI](https://pypi.python.org/pypi/dds_cli/) using pip as follows:
24
+
25
+ ```bash
26
+ pip install dds_cli
27
+ ```
28
+
29
+ ### Development version
30
+
31
+ If you would like the latest development version of tools, the command is:
32
+
33
+ ```bash
34
+ pip install --upgrade --force-reinstall git+https://github.com/ScilifelabDataCentre/dds_cli.git@dev
35
+ ```
36
+
37
+ If you intend to make edits to the code, first make a fork of the repository and then clone it locally.
38
+ Go to the cloned directory and install with pip (also installs development requirements):
39
+
40
+ ```bash
41
+ pip install --upgrade -r requirements-dev.txt -e .
42
+ ```
43
+
44
+ ## Overview of commands
45
+
46
+ Once installed you can use the command `dds` in a terminal session. This has the following subcommands:
47
+
48
+ * `get` - Download specified files from the cloud and restore the original format.
49
+ * `ls` - List the projects and the files within projects.
50
+ * `put` - Process and upload specified files to the cloud.
51
+ * `rm` - Delete files within a project.
@@ -0,0 +1,144 @@
1
+ """DDS CLI."""
2
+
3
+ import datetime
4
+ import os
5
+ import pathlib
6
+ import pkg_resources
7
+ import prompt_toolkit
8
+ import rich.console
9
+
10
+
11
+ ###############################################################################
12
+ # PROJECT SPEC ################################################# PROJECT SPEC #
13
+ ###############################################################################
14
+
15
+ __title__ = "Data Delivery System"
16
+ __version__ = pkg_resources.get_distribution("dds_cli").version
17
+ __url__ = "https://www.scilifelab.se/data"
18
+ __author__ = "SciLifeLab Data Centre"
19
+ __author_email__ = "datacentre@scilifelab.se"
20
+ __license__ = "MIT"
21
+ __all__ = [
22
+ "DDS_METHODS",
23
+ "DDS_DIR_REQUIRED_METHODS",
24
+ "DDS_KEYS_REQUIRED_METHODS",
25
+ "DDSEndpoint",
26
+ "FileSegment",
27
+ "dds_questionary_styles",
28
+ ]
29
+
30
+
31
+ ###############################################################################
32
+ # VARIABLES ####################################################### VARIABLES #
33
+ ###############################################################################
34
+
35
+ # Keep track of all allowed methods
36
+ DDS_METHODS = ["put", "get", "ls", "rm", "create", "add", "delete"]
37
+
38
+ # Methods to which a directory created by DDS
39
+ DDS_DIR_REQUIRED_METHODS = ["put", "get"]
40
+
41
+ # Methods which require a project ID
42
+ DDS_KEYS_REQUIRED_METHODS = ["put", "get"]
43
+
44
+ # Token related variables
45
+ TOKEN_FILE = pathlib.Path(os.path.expanduser("~/.dds_cli_token"))
46
+ TOKEN_MAX_AGE = datetime.timedelta(days=2)
47
+ TOKEN_WARNING_AGE = datetime.timedelta(days=1, hours=18)
48
+
49
+
50
+ ###############################################################################
51
+ # CLASSES ########################################################### CLASSES #
52
+ ###############################################################################
53
+
54
+
55
+ class DDSEndpoint:
56
+ """Defines all DDS urls."""
57
+
58
+ # Base url - local or remote
59
+ BASE_ENDPOINT_LOCAL = "http://127.0.0.1:5000/api/v1"
60
+ BASE_ENDPOINT_REMOTE = "https://dds.dckube.scilifelab.se/api/v1"
61
+ BASE_ENDPOINT = (
62
+ BASE_ENDPOINT_LOCAL if os.getenv("DDS_CLI_ENV") == "development" else BASE_ENDPOINT_REMOTE
63
+ )
64
+
65
+ # User management
66
+ USER_ADD = BASE_ENDPOINT + "/user/add"
67
+ USER_DELETE = BASE_ENDPOINT + "/user/delete"
68
+ USER_DELETE_SELF = BASE_ENDPOINT + "/user/delete_self"
69
+ REVOKE_PROJECT_ACCESS = BASE_ENDPOINT + "/user/access/revoke"
70
+ DISPLAY_USER_INFO = BASE_ENDPOINT + "/user/info"
71
+ USER_ACTIVATION = BASE_ENDPOINT + "/user/activation"
72
+
73
+ # Authentication - user and project
74
+ ENCRYPTED_TOKEN = BASE_ENDPOINT + "/user/encrypted_token"
75
+ SECOND_FACTOR = BASE_ENDPOINT + "/user/second_factor"
76
+
77
+ # S3Connector keys
78
+ S3KEYS = BASE_ENDPOINT + "/s3/proj"
79
+
80
+ # File related urls
81
+ FILE_NEW = BASE_ENDPOINT + "/file/new"
82
+ FILE_MATCH = BASE_ENDPOINT + "/file/match"
83
+ FILE_INFO = BASE_ENDPOINT + "/file/info"
84
+ FILE_INFO_ALL = BASE_ENDPOINT + "/file/all/info"
85
+ FILE_UPDATE = BASE_ENDPOINT + "/file/update"
86
+
87
+ # Project specific urls
88
+
89
+ # Listing urls
90
+ LIST_PROJ = BASE_ENDPOINT + "/proj/list"
91
+ LIST_FILES = BASE_ENDPOINT + "/files/list"
92
+ LIST_PROJ_USERS = BASE_ENDPOINT + "/proj/users"
93
+
94
+ # Deleting urls
95
+ REMOVE_PROJ_CONT = BASE_ENDPOINT + "/proj/rm"
96
+ REMOVE_FILE = BASE_ENDPOINT + "/file/rm"
97
+ REMOVE_FOLDER = BASE_ENDPOINT + "/file/rmdir"
98
+
99
+ # Encryption keys
100
+ PROJ_PUBLIC = BASE_ENDPOINT + "/proj/public"
101
+ PROJ_PRIVATE = BASE_ENDPOINT + "/proj/private"
102
+
103
+ # Display facility usage
104
+ USAGE = BASE_ENDPOINT + "/usage"
105
+ INVOICE = BASE_ENDPOINT + "/invoice"
106
+
107
+ # Project creation urls
108
+ CREATE_PROJ = BASE_ENDPOINT + "/proj/create"
109
+
110
+ # Project status updation
111
+ UPDATE_PROJ_STATUS = BASE_ENDPOINT + "/proj/status"
112
+
113
+ TIMEOUT = 5
114
+
115
+
116
+ class FileSegment:
117
+ """Defines information on signatures, file chunks, etc."""
118
+
119
+ DDS_SIGNATURE = b"DelSys"
120
+ SEGMENT_SIZE_RAW = 65536 # Size of chunk to read from raw file
121
+ SEGMENT_SIZE_CIPHER = SEGMENT_SIZE_RAW + 16 # Size of chunk to read from encrypted file
122
+
123
+
124
+ # Custom styles for questionary
125
+ dds_questionary_styles = prompt_toolkit.styles.Style(
126
+ [
127
+ ("qmark", "fg:ansiblue bold"), # token in front of the question
128
+ ("question", "bold"), # question text
129
+ ("answer", "fg:ansigreen nobold bg:"), # submitted answer text behind the question
130
+ ("pointer", "fg:ansiyellow bold"), # pointer used in select and checkbox prompts
131
+ ("highlighted", "fg:ansiblue bold"), # pointed-at choice in select and checkbox prompts
132
+ ("selected", "fg:ansiyellow noreverse bold"), # style for a selected item of a checkbox
133
+ ("separator", "fg:ansiblack"), # separator in lists
134
+ ("instruction", ""), # user instructions for select, rawselect, checkbox
135
+ ("text", ""), # plain text
136
+ ("disabled", "fg:gray italic"), # disabled choices for select and checkbox prompts
137
+ ("choice-default", "fg:ansiblack"),
138
+ ("choice-default-changed", "fg:ansiyellow"),
139
+ ("choice-required", "fg:ansired"),
140
+ ]
141
+ )
142
+
143
+ # Determine if the user is on an old terminal without proper Unicode support
144
+ dds_on_legacy_console = rich.console.detect_legacy_windows()