wowool-build 0.0.3.dev1__py3-none-any.whl → 0.0.3.dev2__py3-none-any.whl

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.
@@ -7,7 +7,7 @@ from subprocess import run
7
7
  import hashlib
8
8
  import json
9
9
  import re
10
- from wowool.build.exceptions import UploadError
10
+ from wowool.build.exceptions import UploadError, DownloadError
11
11
 
12
12
 
13
13
  @dataclass
@@ -141,7 +141,7 @@ def run_codeartifact(
141
141
  raise UploadError(f"AWS CodeArtifact generic cmd failed: {error}")
142
142
 
143
143
 
144
- def download_raw(
144
+ def download_raw_aws_cli(
145
145
  output: Union[str, Path],
146
146
  namespace: str,
147
147
  package: str,
@@ -163,6 +163,70 @@ def download_raw(
163
163
  raise UploadError(f"AWS CodeArtifact generic upload failed: {error}")
164
164
 
165
165
 
166
+ def download_raw(
167
+ output: Union[str, Path],
168
+ namespace: str,
169
+ package: str,
170
+ version: str,
171
+ aws: Optional[AwsCredentials] = None,
172
+ codeartifact: Optional[CodeArtifactCredentials] = None,
173
+ ):
174
+ output = Path(output)
175
+ try:
176
+ import boto3
177
+ except ImportError:
178
+ raise UploadError("boto3 is not installed. Please install it to use this function.")
179
+
180
+ aws = aws or AwsCredentials.from_environment()
181
+ codeartifact = codeartifact or CodeArtifactCredentials.from_environment()
182
+
183
+ # Check if credentials are valid
184
+ sts_client = boto3.client("sts")
185
+ try:
186
+ identity = sts_client.get_caller_identity()
187
+ print(f"Using AWS Account: {identity['Account']}")
188
+ except Exception as e:
189
+ print(f"AWS credential error: {e}")
190
+
191
+ # Get auth token
192
+ client = boto3.client("codeartifact", region_name=aws.region)
193
+ try:
194
+ # Get the asset
195
+ response = client.get_package_version_asset(
196
+ domain=aws.domain,
197
+ domainOwner=str(aws.domain_owner),
198
+ repository=codeartifact.repository,
199
+ format="generic",
200
+ namespace=namespace,
201
+ package=package,
202
+ packageVersion=version,
203
+ asset=output.name,
204
+ )
205
+
206
+ # Save to file
207
+ with open(output, "wb") as f:
208
+ f.write(response["asset"].read())
209
+
210
+ print(f"Successfully downloaded {output}")
211
+
212
+ except Exception as e:
213
+ raise DownloadError(f"Error downloading asset: {str(e)} {output=}")
214
+
215
+ output = Path(output)
216
+
217
+ aws = aws or AwsCredentials.from_environment()
218
+ codeartifact = codeartifact or CodeArtifactCredentials.from_environment()
219
+ try:
220
+ cmd = f"""aws codeartifact get-package-version-asset --package-version {version} --domain {aws.domain} --domain-owner {aws.domain_owner} --region {aws.region} --repository {codeartifact.repository} --format generic --namespace {namespace} --package {package} --asset {output.name} {output}"""
221
+ result = run(cmd, shell=True, check=False, capture_output=True)
222
+ print(result.stdout.decode())
223
+ if result.returncode != 0:
224
+ print(result.stderr.decode(), file=stderr)
225
+ raise DownloadError(f"AWS CodeArtifact generic upload failed {cmd=}")
226
+ except Exception as error:
227
+ raise DownloadError(f"AWS CodeArtifact generic upload failed: {error}")
228
+
229
+
166
230
  def iter_packages(expression=".*", aws: Optional[AwsCredentials] = None, codeartifact: Optional[CodeArtifactCredentials] = None):
167
231
 
168
232
  exp_ = re.compile(expression)
@@ -1,2 +1,6 @@
1
1
  class UploadError(RuntimeError):
2
2
  pass
3
+
4
+
5
+ class DownloadError(RuntimeError):
6
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wowool-build
3
- Version: 0.0.3.dev1
3
+ Version: 0.0.3.dev2
4
4
  Summary: Wowool Build System
5
5
  Home-page: https://www.wowool.com/
6
6
  Author: Wowool
@@ -1,5 +1,5 @@
1
- wowool/build/codeartifact.py,sha256=tPbxSUk_HkbdJMkknS-Lrl2LYIexzb7F8RJS_aQDWc0,7262
2
- wowool/build/exceptions.py,sha256=GFWI0F_nTEpDid8dMjMQCDQ66muzTvfLzRm-KSJ1-Uw,42
1
+ wowool/build/codeartifact.py,sha256=ZOCqYwEdt1vW0g-jSwJMd6UFJZvNWqvLduhu0-jC04Y,9658
2
+ wowool/build/exceptions.py,sha256=04fMZc_bRMdinIqKCOqiwfO_xqwp_ZqO_SUgXfq4i58,88
3
3
  wowool/build/git.py,sha256=D3CGusjza6bkdI0YbKk-7HumbaPwNYxRWu9M0kT-rHc,3253
4
4
  wowool/build/logging.py,sha256=4ycT471N7V6vrEBXURF0-lho1hbmWA7PJyCHhfHVjeA,4988
5
5
  wowool/build/platform.py,sha256=dYEr4Pw0VyChQRnd0ZXwETXZsLVQ0tC9aC4Mu9KJZcc,901
@@ -8,7 +8,7 @@ wowool/build/pypi.py,sha256=fdPRdbPq2ZxWy3AdncL0qTWmUn_dA62NMWamwpC2Tto,921
8
8
  wowool/build/pytask.py,sha256=wlwnQGfVkEUiA_IcRYnz9_BM7hNmzpT_1turmwYHFEM,2879
9
9
  wowool/build/pytest.py,sha256=8F1ZklSvpTAnwODXZvzhF6qcND-MlDVbl-e4F1Pf3mI,5304
10
10
  wowool/build/utility.py,sha256=q5RwGFD5O9pewuIUxbYt5sA7lj6u1CjWi6PVWQwCxnQ,890
11
- wowool_build-0.0.3.dev1.dist-info/METADATA,sha256=B4L5nWTjUDHk4euo2OafW238foGITJEFLbikFmqOXy8,355
12
- wowool_build-0.0.3.dev1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
13
- wowool_build-0.0.3.dev1.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
14
- wowool_build-0.0.3.dev1.dist-info/RECORD,,
11
+ wowool_build-0.0.3.dev2.dist-info/METADATA,sha256=DfwuEatWo5eILABLTtFG9Msqom5fq-U_POXqk-XGCz0,355
12
+ wowool_build-0.0.3.dev2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
13
+ wowool_build-0.0.3.dev2.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
14
+ wowool_build-0.0.3.dev2.dist-info/RECORD,,