sima-cli 0.0.11__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 (44) hide show
  1. sima_cli-0.0.11/LICENSE +21 -0
  2. sima_cli-0.0.11/MANIFEST.in +13 -0
  3. sima_cli-0.0.11/PKG-INFO +182 -0
  4. sima_cli-0.0.11/README.md +155 -0
  5. sima_cli-0.0.11/pyproject.toml +36 -0
  6. sima_cli-0.0.11/requirements.txt +5 -0
  7. sima_cli-0.0.11/setup.cfg +38 -0
  8. sima_cli-0.0.11/setup.py +27 -0
  9. sima_cli-0.0.11/sima_cli/__init__.py +12 -0
  10. sima_cli-0.0.11/sima_cli/__main__.py +4 -0
  11. sima_cli-0.0.11/sima_cli/__version__.py +2 -0
  12. sima_cli-0.0.11/sima_cli/app_zoo/__init__.py +0 -0
  13. sima_cli-0.0.11/sima_cli/app_zoo/app.py +0 -0
  14. sima_cli-0.0.11/sima_cli/auth/__init__.py +0 -0
  15. sima_cli-0.0.11/sima_cli/auth/login.py +103 -0
  16. sima_cli-0.0.11/sima_cli/cli.py +173 -0
  17. sima_cli-0.0.11/sima_cli/download/__init__.py +11 -0
  18. sima_cli-0.0.11/sima_cli/download/downloader.py +148 -0
  19. sima_cli-0.0.11/sima_cli/model_zoo/__init__.py +0 -0
  20. sima_cli-0.0.11/sima_cli/model_zoo/model.py +148 -0
  21. sima_cli-0.0.11/sima_cli/update/__init__.py +3 -0
  22. sima_cli-0.0.11/sima_cli/update/local.py +94 -0
  23. sima_cli-0.0.11/sima_cli/update/remote.py +238 -0
  24. sima_cli-0.0.11/sima_cli/update/updater.py +339 -0
  25. sima_cli-0.0.11/sima_cli/utils/__init__.py +0 -0
  26. sima_cli-0.0.11/sima_cli/utils/artifactory.py +63 -0
  27. sima_cli-0.0.11/sima_cli/utils/config.py +58 -0
  28. sima_cli-0.0.11/sima_cli/utils/config_loader.py +30 -0
  29. sima_cli-0.0.11/sima_cli/utils/env.py +172 -0
  30. sima_cli-0.0.11/sima_cli/utils/network.py +42 -0
  31. sima_cli-0.0.11/sima_cli.egg-info/PKG-INFO +182 -0
  32. sima_cli-0.0.11/sima_cli.egg-info/SOURCES.txt +43 -0
  33. sima_cli-0.0.11/sima_cli.egg-info/dependency_links.txt +1 -0
  34. sima_cli-0.0.11/sima_cli.egg-info/entry_points.txt +2 -0
  35. sima_cli-0.0.11/sima_cli.egg-info/requires.txt +5 -0
  36. sima_cli-0.0.11/sima_cli.egg-info/top_level.txt +2 -0
  37. sima_cli-0.0.11/tests/__init__.py +0 -0
  38. sima_cli-0.0.11/tests/test_app_zoo.py +0 -0
  39. sima_cli-0.0.11/tests/test_auth.py +0 -0
  40. sima_cli-0.0.11/tests/test_cli.py +0 -0
  41. sima_cli-0.0.11/tests/test_download.py +115 -0
  42. sima_cli-0.0.11/tests/test_firmware.py +0 -0
  43. sima_cli-0.0.11/tests/test_model_zoo.py +0 -0
  44. sima_cli-0.0.11/tests/test_utils.py +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SiMa.ai
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+
5
+ # Include all Python source files
6
+ recursive-include sima_cli *.py
7
+
8
+ recursive-include tests *.py
9
+
10
+ include pyproject.toml
11
+ include setup.cfg
12
+ include setup.py
13
+ include sima_cli/data/resources.yaml
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: sima-cli
3
+ Version: 0.0.11
4
+ Summary: CLI tool for SiMa Developer Portal to download models, firmware, and apps.
5
+ Home-page: https://developer.sima.ai/
6
+ Author: SiMa.ai
7
+ Author-email: "Sima.ai" <support@sima.ai>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://developer.sima.ai/
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Build Tools
15
+ Classifier: Environment :: Console
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: requests
20
+ Requires-Dist: click
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: pyyaml
23
+ Requires-Dist: paramiko
24
+ Dynamic: author
25
+ Dynamic: license-file
26
+ Dynamic: requires-python
27
+
28
+ # πŸ› οΈ sima-cli – SiMa Developer Portal CLI Tool
29
+
30
+ `sima-cli` is a command-line interface (CLI) utility designed to interact with the SiMa Developer Portal. It supports downloading models and apps from the Model/App Zoo, performing firmware updates, and authenticating against internal or external environments.
31
+
32
+ ---
33
+
34
+ ## πŸ“¦ Installation
35
+
36
+ ```bash
37
+ pip install sima-cli
38
+ ```
39
+
40
+ ---
41
+
42
+ ## πŸš€ Getting Started
43
+
44
+ ```bash
45
+ sima-cli --help
46
+ ```
47
+
48
+ ### Global Option
49
+
50
+ - `--internal`: Use internal Artifactory resources (can also be set via `SIMA_CLI_INTERNAL=1`).
51
+
52
+ Environment detection output will appear like:
53
+
54
+ ```
55
+ πŸ”§ Environment: dev (sandbox) | Internal: True
56
+ ```
57
+
58
+ If external mode is detected and not supported:
59
+
60
+ ```
61
+ external environment is not supported yet..
62
+ ```
63
+
64
+ ---
65
+
66
+ ## πŸ” Authentication
67
+
68
+ ```bash
69
+ sima-cli login
70
+ ```
71
+
72
+ Authenticates with the SiMa Developer Portal. Internal or external login is selected based on context.
73
+
74
+ ---
75
+
76
+ ## πŸ“₯ Download Resources
77
+
78
+ ```bash
79
+ sima-cli download <URL> [-d DEST]
80
+ ```
81
+
82
+ - Downloads a single file or an entire folder from the provided URL.
83
+ - Options:
84
+ - `-d`, `--dest`: Destination folder (default is current directory).
85
+
86
+ ---
87
+
88
+ ## πŸ”§ Firmware Update
89
+
90
+ ```bash
91
+ sima-cli update <version_or_url> [--ip IP] [--board BOARD] [--passwd PASSWORD]
92
+ ```
93
+
94
+ - Updates firmware either locally or over the network.
95
+ - Positional:
96
+ - `<version_or_url>`: Version string (e.g. `1.5.0`) or direct URL.
97
+ - Options:
98
+ - `--ip`: IP address of remote device (for network update).
99
+ - `--board`: Board type, one of `davinci`, `modalix` (default: `davinci`).
100
+ - `--passwd`: SSH password for remote board (default: `edgeai`).
101
+
102
+ ---
103
+
104
+ ## 🧠 Model Zoo
105
+
106
+ ### List Models
107
+
108
+ ```bash
109
+ sima-cli model-zoo list [--ver VERSION]
110
+ ```
111
+
112
+ - Lists available models for a given SDK version.
113
+
114
+ ### Get Model
115
+
116
+ ```bash
117
+ sima-cli model-zoo get <MODEL_NAME> [--ver VERSION]
118
+ ```
119
+
120
+ - Downloads the specified model.
121
+
122
+ ---
123
+
124
+ ## πŸ“± App Zoo
125
+
126
+ ### List Apps
127
+
128
+ ```bash
129
+ sima-cli app-zoo list [--ver VERSION]
130
+ ```
131
+
132
+ - Lists available apps for a given SDK version.
133
+
134
+ ### Get App
135
+
136
+ ```bash
137
+ sima-cli app-zoo get <APP_NAME> [--ver VERSION]
138
+ ```
139
+
140
+ - Downloads the specified app.
141
+
142
+ ---
143
+
144
+ ## 🌍 Environment Variable Support
145
+
146
+ Instead of using `--internal` flag every time, you can set:
147
+
148
+ ```bash
149
+ export SIMA_CLI_INTERNAL=1
150
+ ```
151
+
152
+ ---
153
+
154
+ ## πŸ§ͺ Examples
155
+
156
+ ### Authenticate Internally
157
+
158
+ ```bash
159
+ sima-cli --internal login
160
+ ```
161
+
162
+
163
+ ### Firmware Update on Davinci (MLSOC Gen 1) Board
164
+
165
+ ```bash
166
+ sima-cli update 1.6.0_master_B1611 --ip 192.168.1.20
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 🧩 Requirements
172
+
173
+ - Python 3.8+
174
+ - Internal network access if using `--internal` features
175
+
176
+ ---
177
+
178
+ ## πŸ“ž Support
179
+
180
+ Please reach out to **SiMa Support** (support@sima.ai) if you encounter issues with downloads or updates.
181
+
182
+ ---
@@ -0,0 +1,155 @@
1
+ # πŸ› οΈ sima-cli – SiMa Developer Portal CLI Tool
2
+
3
+ `sima-cli` is a command-line interface (CLI) utility designed to interact with the SiMa Developer Portal. It supports downloading models and apps from the Model/App Zoo, performing firmware updates, and authenticating against internal or external environments.
4
+
5
+ ---
6
+
7
+ ## πŸ“¦ Installation
8
+
9
+ ```bash
10
+ pip install sima-cli
11
+ ```
12
+
13
+ ---
14
+
15
+ ## πŸš€ Getting Started
16
+
17
+ ```bash
18
+ sima-cli --help
19
+ ```
20
+
21
+ ### Global Option
22
+
23
+ - `--internal`: Use internal Artifactory resources (can also be set via `SIMA_CLI_INTERNAL=1`).
24
+
25
+ Environment detection output will appear like:
26
+
27
+ ```
28
+ πŸ”§ Environment: dev (sandbox) | Internal: True
29
+ ```
30
+
31
+ If external mode is detected and not supported:
32
+
33
+ ```
34
+ external environment is not supported yet..
35
+ ```
36
+
37
+ ---
38
+
39
+ ## πŸ” Authentication
40
+
41
+ ```bash
42
+ sima-cli login
43
+ ```
44
+
45
+ Authenticates with the SiMa Developer Portal. Internal or external login is selected based on context.
46
+
47
+ ---
48
+
49
+ ## πŸ“₯ Download Resources
50
+
51
+ ```bash
52
+ sima-cli download <URL> [-d DEST]
53
+ ```
54
+
55
+ - Downloads a single file or an entire folder from the provided URL.
56
+ - Options:
57
+ - `-d`, `--dest`: Destination folder (default is current directory).
58
+
59
+ ---
60
+
61
+ ## πŸ”§ Firmware Update
62
+
63
+ ```bash
64
+ sima-cli update <version_or_url> [--ip IP] [--board BOARD] [--passwd PASSWORD]
65
+ ```
66
+
67
+ - Updates firmware either locally or over the network.
68
+ - Positional:
69
+ - `<version_or_url>`: Version string (e.g. `1.5.0`) or direct URL.
70
+ - Options:
71
+ - `--ip`: IP address of remote device (for network update).
72
+ - `--board`: Board type, one of `davinci`, `modalix` (default: `davinci`).
73
+ - `--passwd`: SSH password for remote board (default: `edgeai`).
74
+
75
+ ---
76
+
77
+ ## 🧠 Model Zoo
78
+
79
+ ### List Models
80
+
81
+ ```bash
82
+ sima-cli model-zoo list [--ver VERSION]
83
+ ```
84
+
85
+ - Lists available models for a given SDK version.
86
+
87
+ ### Get Model
88
+
89
+ ```bash
90
+ sima-cli model-zoo get <MODEL_NAME> [--ver VERSION]
91
+ ```
92
+
93
+ - Downloads the specified model.
94
+
95
+ ---
96
+
97
+ ## πŸ“± App Zoo
98
+
99
+ ### List Apps
100
+
101
+ ```bash
102
+ sima-cli app-zoo list [--ver VERSION]
103
+ ```
104
+
105
+ - Lists available apps for a given SDK version.
106
+
107
+ ### Get App
108
+
109
+ ```bash
110
+ sima-cli app-zoo get <APP_NAME> [--ver VERSION]
111
+ ```
112
+
113
+ - Downloads the specified app.
114
+
115
+ ---
116
+
117
+ ## 🌍 Environment Variable Support
118
+
119
+ Instead of using `--internal` flag every time, you can set:
120
+
121
+ ```bash
122
+ export SIMA_CLI_INTERNAL=1
123
+ ```
124
+
125
+ ---
126
+
127
+ ## πŸ§ͺ Examples
128
+
129
+ ### Authenticate Internally
130
+
131
+ ```bash
132
+ sima-cli --internal login
133
+ ```
134
+
135
+
136
+ ### Firmware Update on Davinci (MLSOC Gen 1) Board
137
+
138
+ ```bash
139
+ sima-cli update 1.6.0_master_B1611 --ip 192.168.1.20
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 🧩 Requirements
145
+
146
+ - Python 3.8+
147
+ - Internal network access if using `--internal` features
148
+
149
+ ---
150
+
151
+ ## πŸ“ž Support
152
+
153
+ Please reach out to **SiMa Support** (support@sima.ai) if you encounter issues with downloads or updates.
154
+
155
+ ---
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sima-cli"
7
+ version = "0.0.11"
8
+ description = "CLI tool for SiMa Developer Portal to download models, firmware, and apps."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name="Sima.ai", email="support@sima.ai" }
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Topic :: Software Development :: Build Tools",
21
+ "Environment :: Console",
22
+ ]
23
+
24
+ dependencies = [
25
+ "requests",
26
+ "click",
27
+ "tqdm",
28
+ "pyyaml",
29
+ "paramiko"
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://developer.sima.ai/"
34
+
35
+ [project.scripts]
36
+ sima-cli = "sima_cli.cli:main"
@@ -0,0 +1,5 @@
1
+ click>=8.0
2
+ requests>=2.25
3
+ tqdm>=4.64
4
+ pyyaml>=6.0
5
+ paramiko>=3.5.1
@@ -0,0 +1,38 @@
1
+ [metadata]
2
+ name = sima-cli
3
+ author = Sima.ai
4
+ author_email = support@sima.ai
5
+ description = CLI tool for SiMa Developer Portal to download models, firmware, and apps.
6
+ long_description = file: README.md
7
+ long_description_content_type = text/markdown
8
+ url = https://developer.sima.ai/
9
+ license = MIT
10
+ classifiers =
11
+ Programming Language :: Python :: 3
12
+ Operating System :: OS Independent
13
+ Development Status :: 3 - Alpha
14
+ Environment :: Console
15
+ Intended Audience :: Developers
16
+ Topic :: Software Development :: Build Tools
17
+
18
+ [options]
19
+ packages = find:
20
+ python_requires = >=3.10
21
+ install_requires =
22
+ click
23
+ requests
24
+
25
+ [options.entry_points]
26
+ console_scripts =
27
+ sima-cli = sima_cli.cli:main
28
+
29
+ [options.package_data]
30
+ * = *.txt, *.md
31
+
32
+ [sdist]
33
+ formats = gztar
34
+
35
+ [egg_info]
36
+ tag_build =
37
+ tag_date = 0
38
+
@@ -0,0 +1,27 @@
1
+ from setuptools import setup, find_packages
2
+ from pathlib import Path
3
+
4
+ # Load version from sima_cli/__version__.py
5
+ version_path = Path(__file__).parent / "sima_cli" / "__version__.py"
6
+ version_ns = {}
7
+ exec(version_path.read_text(), version_ns)
8
+
9
+ setup(
10
+ name="sima-cli",
11
+ version=version_ns["__version__"],
12
+ description="SiMa Developer Portal CLI Tool",
13
+ author="SiMa.ai",
14
+ packages=find_packages(),
15
+ include_package_data=True,
16
+ install_requires=[
17
+ "click>=8.0",
18
+ "requests>=2.25",
19
+ "tqdm>=4.64"
20
+ ],
21
+ entry_points={
22
+ "console_scripts": [
23
+ "sima-cli=sima_cli.__main__:main"
24
+ ]
25
+ },
26
+ python_requires=">=3.10",
27
+ )
@@ -0,0 +1,12 @@
1
+ """
2
+ sima_cli - SiMa Developer CLI Tool
3
+
4
+ This package provides the command-line interface for interacting with
5
+ the SiMa Developer Portal. Functionality includes authentication, model
6
+ and firmware downloads, and device updates.
7
+
8
+ To get started, run: `sima-cli help`
9
+ """
10
+ from .__version__ import __version__
11
+
12
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ from sima_cli.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,2 @@
1
+ # sima_cli/__version__.py
2
+ __version__ = "0.0.11"
File without changes
File without changes
File without changes
@@ -0,0 +1,103 @@
1
+ import click
2
+ import getpass
3
+ import requests
4
+ from sima_cli.utils.config import set_auth_token, get_auth_token
5
+ from sima_cli.utils.config_loader import load_resource_config
6
+ from sima_cli.utils.artifactory import exchange_identity_token, validate_token
7
+
8
+ def login(method: str = "external"):
9
+ """
10
+ Dispatch login based on the specified method.
11
+
12
+ Args:
13
+ method (str): 'external' (public developer portal) or 'internal' (Artifactory).
14
+ """
15
+ if method == "internal":
16
+ return login_internal()
17
+ else:
18
+ return login_external()
19
+
20
+ def login_internal():
21
+ """
22
+ Internal login using a manually provided identity token.
23
+
24
+ Flow:
25
+ 1. Prompt for identity token.
26
+ 2. Validate the token using the configured validation URL.
27
+ 3. If valid, exchange it for a short-lived access token.
28
+ 4. Save the short-lived token to local config.
29
+ """
30
+
31
+ cfg = load_resource_config()
32
+ auth_cfg = cfg.get("internal", {}).get("auth", {})
33
+ base_url = cfg.get("internal", {}).get("artifactory", {}).get("url", {})
34
+ validate_url = f"{base_url}/{auth_cfg.get("validate_url")}"
35
+ exchange_url = f"{base_url}/{auth_cfg.get("internal_url")}"
36
+
37
+ # Check for required config values
38
+ if not validate_url or not exchange_url:
39
+ click.echo("❌ Missing 'validate_url' or 'internal_url' in internal auth config.")
40
+ click.echo("πŸ‘‰ Please check ~/.sima-cli/resources_internal.yaml")
41
+ return
42
+
43
+ # Prompt for identity token
44
+ click.echo("πŸ” Paste your Artifactory identity token below.")
45
+ identity_token = click.prompt("Identity Token", hide_input=True)
46
+
47
+ if not identity_token or len(identity_token.strip()) < 10:
48
+ return click.echo("❌ Invalid or empty token.")
49
+
50
+ # Step 1: Validate the identity token
51
+ is_valid, username = validate_token(identity_token, validate_url)
52
+ if not is_valid:
53
+ return click.echo("❌ Token validation failed. Please check your identity token.")
54
+
55
+ click.echo(f"βœ… Identity token is valid")
56
+
57
+ # Step 2: Exchange for a short-lived access token (default: 7 days)
58
+ access_token, user_name = exchange_identity_token(identity_token, exchange_url, expires_in=604800)
59
+
60
+ if not access_token:
61
+ return click.echo("❌ Failed to acquire short-lived access token.")
62
+
63
+ # Step 3: Save token to internal auth config
64
+ set_auth_token(access_token, internal=True)
65
+ click.echo(f"πŸ’Ύ Short-lived access token saved successfully for {user_name} (valid for 7 days).")
66
+
67
+
68
+ def login_external():
69
+ """
70
+ External login using Developer Portal endpoint defined in the 'public' section of YAML config.
71
+ Prompts for username/password and retrieves access token.
72
+ """
73
+ cfg = load_resource_config()
74
+ auth_url = cfg.get("public", {}).get("auth", {}).get("external_url")
75
+
76
+ if not auth_url:
77
+ click.echo("❌ External auth URL not configured in YAML.")
78
+ return
79
+
80
+ click.echo("🌐 Logging in using external Developer Portal...")
81
+
82
+ # Prompt for credentials
83
+ username = click.prompt("Email or Username")
84
+ password = getpass.getpass("Password: ")
85
+
86
+ data = {
87
+ "username": username,
88
+ "password": password
89
+ }
90
+
91
+ try:
92
+ response = requests.post(auth_url, json=data)
93
+ response.raise_for_status()
94
+
95
+ token = response.json().get("access_token")
96
+ if not token:
97
+ return click.echo("❌ Failed to retrieve access token.")
98
+
99
+ set_auth_token(token)
100
+ click.echo("βœ… External login successful.")
101
+
102
+ except requests.RequestException as e:
103
+ click.echo(f"❌ External login failed: {e}")