NGPIris 5.3.0__tar.gz → 5.4.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.
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/cli/__init__.py +3 -34
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hcp/hcp.py +109 -50
- {ngpiris-5.3.0 → ngpiris-5.4.0/NGPIris.egg-info}/PKG-INFO +1 -1
- {ngpiris-5.3.0/NGPIris.egg-info → ngpiris-5.4.0}/PKG-INFO +1 -1
- {ngpiris-5.3.0 → ngpiris-5.4.0}/pyproject.toml +1 -1
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/test_hcp.py +36 -12
- {ngpiris-5.3.0 → ngpiris-5.4.0}/LICENSE +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/MANIFEST.in +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/__init__.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hci/__init__.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hci/exceptions.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hci/hci.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hci/helpers.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hcp/__init__.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hcp/exceptions.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hcp/helpers.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/hcp/statistics.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/parse_credentials/__init__.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/parse_credentials/parse_credentials.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/utils/__init__.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris/utils/utils.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris.egg-info/SOURCES.txt +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris.egg-info/dependency_links.txt +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris.egg-info/entry_points.txt +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris.egg-info/requires.txt +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/NGPIris.egg-info/top_level.txt +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/README.md +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/IRIS_5_changelog.md +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/Makefile +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.cli.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.hci.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.hcp.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.parse_credentials.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/NGPIris.utils.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/Tutorial.md +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/conf.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/index.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/make.bat +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/docs/modules.rst +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/setup.cfg +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/80MB_test_file +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/a folder of data/80MB_test_file_0 +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/a folder of data/80MB_test_file_1 +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/complete_creds_0.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/complete_creds_1.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/complete_creds_2.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/incomplete_creds_0.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/incomplete_creds_1.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/incomplete_creds_2.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/incomplete_creds_3.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/data/incomplete_creds_4.json +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/test_hci.py +0 -0
- {ngpiris-5.3.0 → ngpiris-5.4.0}/tests/test_parse_credentials.py +0 -0
|
@@ -4,11 +4,7 @@ from click.core import Context
|
|
|
4
4
|
from json import dump
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from boto3 import set_stream_logger
|
|
7
|
-
from botocore.paginate import PageIterator, Paginator
|
|
8
7
|
from typing import Any, Generator
|
|
9
|
-
from os import get_terminal_size
|
|
10
|
-
from math import floor
|
|
11
|
-
from tabulate import tabulate
|
|
12
8
|
from bitmath import Byte, TiB
|
|
13
9
|
|
|
14
10
|
from NGPIris.hcp import HCPHandler
|
|
@@ -26,36 +22,9 @@ def _list_objects_generator(hcph : HCPHandler, path : str, name_only : bool, fil
|
|
|
26
22
|
different from `list_objects` in `hcp.py` in order to make the output
|
|
27
23
|
printable in a terminal
|
|
28
24
|
"""
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
max_width = floor(nb_of_cols / 5)
|
|
33
|
-
if (not name_only):
|
|
34
|
-
yield tabulate(
|
|
35
|
-
[],
|
|
36
|
-
headers = ["Key", "LastModified", "ETag", "Size", "StorageClass"],
|
|
37
|
-
tablefmt = "plain",
|
|
38
|
-
stralign = "center"
|
|
39
|
-
) + "\n" + "-"*nb_of_cols + "\n"
|
|
40
|
-
if files_only:
|
|
41
|
-
filter_string = "Contents[?!ends_with(Key, '/')][]" # filter objects that does not end with "/"
|
|
42
|
-
else:
|
|
43
|
-
filter_string = "Contents[*][]"
|
|
44
|
-
for object in pages.search(filter_string):
|
|
45
|
-
if name_only:
|
|
46
|
-
yield str(object["Key"]) + "\n"
|
|
47
|
-
else:
|
|
48
|
-
yield tabulate(
|
|
49
|
-
[
|
|
50
|
-
[str(object["Key"]),
|
|
51
|
-
str(object["LastModified"]),
|
|
52
|
-
str(object["ETag"]),
|
|
53
|
-
str(object["Size"]),
|
|
54
|
-
str(object["StorageClass"])]
|
|
55
|
-
],
|
|
56
|
-
maxcolwidths = max_width,
|
|
57
|
-
tablefmt = "plain"
|
|
58
|
-
) + "\n" + "-"*nb_of_cols + "\n"
|
|
25
|
+
objects = hcph.list_objects(path, name_only, files_only)
|
|
26
|
+
for obj in objects:
|
|
27
|
+
yield str(obj) + "\n"
|
|
59
28
|
|
|
60
29
|
def object_is_folder(object_path : str, hcph : HCPHandler) -> bool:
|
|
61
30
|
return (object_path[-1] == "/") and (hcph.get_object(object_path)["ContentLength"] == 0)
|
|
@@ -256,51 +256,64 @@ class HCPHandler:
|
|
|
256
256
|
response = self.get_response("/namespaces")
|
|
257
257
|
list_of_buckets : list[str] = response["name"]
|
|
258
258
|
return list_of_buckets
|
|
259
|
-
|
|
259
|
+
|
|
260
260
|
@check_mounted
|
|
261
261
|
def list_objects(self, path_key : str = "", name_only : bool = False, files_only : bool = False) -> Generator:
|
|
262
262
|
"""
|
|
263
263
|
List all objects in the mounted bucket as a generator. If one wishes to
|
|
264
264
|
get the result as a list, use :py:function:`list` to type cast the generator
|
|
265
265
|
|
|
266
|
-
:param path_key: Filter string for which keys to list, specifically for finding objects in certain folders.
|
|
266
|
+
:param path_key: Filter string for which keys to list, specifically for finding objects in certain folders. Defaults to \"the root\" of the bucket
|
|
267
267
|
:type path_key: str, optional
|
|
268
268
|
:param name_only: If True, yield only a the object names. If False, yield the full metadata about each object. Defaults to False.
|
|
269
269
|
:type name_only: bool, optional
|
|
270
270
|
:param files_only: If true, only yield file objects. Defaults to False
|
|
271
271
|
:type files_only: bool, optional
|
|
272
|
-
:yield: A generator of all objects in a bucket
|
|
272
|
+
:yield: A generator of all objects in specified folder in a bucket
|
|
273
273
|
:rtype: Generator
|
|
274
274
|
"""
|
|
275
275
|
paginator : Paginator = self.s3_client.get_paginator("list_objects_v2")
|
|
276
|
-
pages : PageIterator = paginator.paginate(Bucket = self.bucket_name, Prefix = path_key)
|
|
277
|
-
|
|
278
|
-
if files_only:
|
|
279
|
-
filter_string = "Contents[?!ends_with(Key, '/')][]"
|
|
280
|
-
else:
|
|
281
|
-
filter_string = "Contents[*][]"
|
|
276
|
+
pages : PageIterator = paginator.paginate(Bucket = self.bucket_name, Prefix = path_key, Delimiter = "/")
|
|
282
277
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
# If there are no objects in the bucket, then `object` will be None,
|
|
288
|
-
# which means that we should break out of the for loop
|
|
289
|
-
if not object:
|
|
278
|
+
for page in pages:
|
|
279
|
+
page : dict | None
|
|
280
|
+
# Check if `page` is None
|
|
281
|
+
if not page:
|
|
290
282
|
break
|
|
291
283
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
284
|
+
if files_only:
|
|
285
|
+
for file_object in page.get("Contents", []):
|
|
286
|
+
file_object : dict
|
|
287
|
+
if file_object["Key"] != path_key:
|
|
288
|
+
file_object["IsFile"] = True
|
|
289
|
+
if name_only:
|
|
290
|
+
yield file_object["Key"]
|
|
291
|
+
else:
|
|
292
|
+
yield file_object
|
|
293
|
+
else:
|
|
294
|
+
for folder_object in page.get("CommonPrefixes", []):
|
|
295
|
+
folder_object : dict
|
|
296
|
+
folder_object_metadata = self.get_object(folder_object["Prefix"])
|
|
297
|
+
|
|
298
|
+
if name_only:
|
|
299
|
+
yield folder_object["Prefix"]
|
|
300
|
+
else:
|
|
301
|
+
yield {
|
|
302
|
+
"Key" : folder_object["Prefix"],
|
|
303
|
+
"LastModified" : folder_object_metadata["LastModified"],
|
|
304
|
+
"ETag" : folder_object_metadata["ETag"],
|
|
305
|
+
"IsFile" : False,
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
for file_object in page.get("Contents", []):
|
|
309
|
+
file_object : dict
|
|
310
|
+
if file_object["Key"] != path_key:
|
|
311
|
+
file_object["IsFile"] = True
|
|
312
|
+
if name_only:
|
|
313
|
+
yield file_object["Key"]
|
|
314
|
+
else:
|
|
315
|
+
yield file_object
|
|
316
|
+
|
|
304
317
|
|
|
305
318
|
@check_mounted
|
|
306
319
|
def get_object(self, key : str) -> dict:
|
|
@@ -340,7 +353,7 @@ class HCPHandler:
|
|
|
340
353
|
return False
|
|
341
354
|
|
|
342
355
|
@check_mounted
|
|
343
|
-
def download_file(self, key : str, local_file_path : str) -> None:
|
|
356
|
+
def download_file(self, key : str, local_file_path : str, show_progress_bar : bool = True) -> None:
|
|
344
357
|
"""
|
|
345
358
|
Download one object file from the mounted bucket
|
|
346
359
|
|
|
@@ -349,25 +362,38 @@ class HCPHandler:
|
|
|
349
362
|
|
|
350
363
|
:param local_file_path: Path to a file on your local system where the contents of the object file can be put
|
|
351
364
|
:type local_file_path: str
|
|
365
|
+
|
|
366
|
+
:param show_progress_bar: Boolean choice of displaying a progress bar. Defaults to True
|
|
367
|
+
:type show_progress_bar: bool, optional
|
|
368
|
+
|
|
369
|
+
:raises ObjectDoesNotExist: If the object does not exist in the bucket
|
|
352
370
|
"""
|
|
353
371
|
try:
|
|
354
372
|
self.get_object(key)
|
|
355
373
|
except:
|
|
356
374
|
raise ObjectDoesNotExist("Could not find object", "\"" + key + "\"", "in bucket", "\"" + str(self.bucket_name) + "\"")
|
|
357
375
|
try:
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
376
|
+
if show_progress_bar:
|
|
377
|
+
file_size : int = self.s3_client.head_object(Bucket = self.bucket_name, Key = key)["ContentLength"]
|
|
378
|
+
with tqdm(
|
|
379
|
+
total = file_size,
|
|
380
|
+
unit = "B",
|
|
381
|
+
unit_scale = True,
|
|
382
|
+
desc = key
|
|
383
|
+
) as pbar:
|
|
384
|
+
self.s3_client.download_file(
|
|
385
|
+
Bucket = self.bucket_name,
|
|
386
|
+
Key = key,
|
|
387
|
+
Filename = local_file_path,
|
|
388
|
+
Config = self.transfer_config,
|
|
389
|
+
Callback = lambda bytes_transferred : pbar.update(bytes_transferred)
|
|
390
|
+
)
|
|
391
|
+
else:
|
|
365
392
|
self.s3_client.download_file(
|
|
366
393
|
Bucket = self.bucket_name,
|
|
367
394
|
Key = key,
|
|
368
395
|
Filename = local_file_path,
|
|
369
396
|
Config = self.transfer_config,
|
|
370
|
-
Callback = lambda bytes_transferred : pbar.update(bytes_transferred)
|
|
371
397
|
)
|
|
372
398
|
except ClientError as e0:
|
|
373
399
|
print(str(e0))
|
|
@@ -376,7 +402,14 @@ class HCPHandler:
|
|
|
376
402
|
raise Exception(e)
|
|
377
403
|
|
|
378
404
|
@check_mounted
|
|
379
|
-
def download_folder(
|
|
405
|
+
def download_folder(
|
|
406
|
+
self,
|
|
407
|
+
folder_key : str,
|
|
408
|
+
local_folder_path : str,
|
|
409
|
+
use_download_limit : bool = False,
|
|
410
|
+
download_limit_in_bytes : Byte = TiB(1).to_Byte(),
|
|
411
|
+
show_progress_bar : bool = True
|
|
412
|
+
) -> None:
|
|
380
413
|
"""
|
|
381
414
|
Download multiple objects from a folder in the mounted bucket
|
|
382
415
|
|
|
@@ -392,7 +425,13 @@ class HCPHandler:
|
|
|
392
425
|
:param download_limit_in_bytes: The optional download limit in Byte (from the package `bitmath`). Defaults to 1 TB (`TiB(1).to_Byte()`)
|
|
393
426
|
:type download_limit_in_bytes: Byte, optional
|
|
394
427
|
|
|
428
|
+
:param show_progress_bar: Boolean choice of displaying a progress bar. Defaults to True
|
|
429
|
+
:type show_progress_bar: bool, optional
|
|
430
|
+
|
|
431
|
+
:raises ObjectDoesNotExist: If the object does not exist in the bucket
|
|
432
|
+
|
|
395
433
|
:raises DownloadLimitReached: If download limit was reached while downloading files
|
|
434
|
+
|
|
396
435
|
:raises NotADirectory: If local_folder_path is not a directory
|
|
397
436
|
"""
|
|
398
437
|
try:
|
|
@@ -409,12 +448,12 @@ class HCPHandler:
|
|
|
409
448
|
current_download_size_in_bytes += Byte(object["Size"])
|
|
410
449
|
if current_download_size_in_bytes >= download_limit_in_bytes and use_download_limit:
|
|
411
450
|
raise DownloadLimitReached("The download limit was reached when downloading files")
|
|
412
|
-
self.download_file(object["Key"], p.as_posix())
|
|
451
|
+
self.download_file(object["Key"], p.as_posix(), show_progress_bar = show_progress_bar)
|
|
413
452
|
else:
|
|
414
453
|
raise NotADirectory(local_folder_path + " is not a directory")
|
|
415
454
|
|
|
416
455
|
@check_mounted
|
|
417
|
-
def upload_file(self, local_file_path : str, key : str = "") -> None:
|
|
456
|
+
def upload_file(self, local_file_path : str, key : str = "", show_progress_bar : bool = True) -> None:
|
|
418
457
|
"""
|
|
419
458
|
Upload one file to the mounted bucket
|
|
420
459
|
|
|
@@ -423,6 +462,13 @@ class HCPHandler:
|
|
|
423
462
|
|
|
424
463
|
:param key: An optional new name for the file object on the bucket. Defaults to the same name as the file
|
|
425
464
|
:type key: str, optional
|
|
465
|
+
|
|
466
|
+
:param show_progress_bar: Boolean choice of displaying a progress bar. Defaults to True
|
|
467
|
+
:type show_progress_bar: bool, optional
|
|
468
|
+
|
|
469
|
+
:raises RuntimeError: If the \"\\\" is used in the file path
|
|
470
|
+
|
|
471
|
+
:raises ObjectAlreadyExist: If the object already exist on the mounted bucket
|
|
426
472
|
"""
|
|
427
473
|
raise_path_error(local_file_path)
|
|
428
474
|
|
|
@@ -436,30 +482,43 @@ class HCPHandler:
|
|
|
436
482
|
if self.object_exists(key):
|
|
437
483
|
raise ObjectAlreadyExist("The object \"" + key + "\" already exist in the mounted bucket")
|
|
438
484
|
else:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
485
|
+
if show_progress_bar:
|
|
486
|
+
file_size : int = stat(local_file_path).st_size
|
|
487
|
+
with tqdm(
|
|
488
|
+
total = file_size,
|
|
489
|
+
unit = "B",
|
|
490
|
+
unit_scale = True,
|
|
491
|
+
desc = local_file_path
|
|
492
|
+
) as pbar:
|
|
493
|
+
self.s3_client.upload_file(
|
|
494
|
+
Filename = local_file_path,
|
|
495
|
+
Bucket = self.bucket_name,
|
|
496
|
+
Key = key,
|
|
497
|
+
Config = self.transfer_config,
|
|
498
|
+
Callback = lambda bytes_transferred : pbar.update(bytes_transferred)
|
|
499
|
+
)
|
|
500
|
+
else:
|
|
446
501
|
self.s3_client.upload_file(
|
|
447
502
|
Filename = local_file_path,
|
|
448
503
|
Bucket = self.bucket_name,
|
|
449
504
|
Key = key,
|
|
450
505
|
Config = self.transfer_config,
|
|
451
|
-
Callback = lambda bytes_transferred : pbar.update(bytes_transferred)
|
|
452
506
|
)
|
|
453
507
|
|
|
508
|
+
|
|
454
509
|
@check_mounted
|
|
455
|
-
def upload_folder(self, local_folder_path : str, key : str = "") -> None:
|
|
510
|
+
def upload_folder(self, local_folder_path : str, key : str = "", show_progress_bar : bool = True) -> None:
|
|
456
511
|
"""
|
|
457
512
|
Upload the contents of a folder to the mounted bucket
|
|
458
513
|
|
|
459
514
|
:param local_folder_path: Path to the folder to be uploaded
|
|
460
515
|
:type local_folder_path: str
|
|
516
|
+
|
|
461
517
|
:param key: An optional new name for the folder path on the bucket. Defaults to the same name as the local folder path
|
|
462
518
|
:type key: str, optional
|
|
519
|
+
|
|
520
|
+
:param show_progress_bar: Boolean choice of displaying a progress bar. Defaults to True
|
|
521
|
+
:type show_progress_bar: bool, optional
|
|
463
522
|
"""
|
|
464
523
|
raise_path_error(local_folder_path)
|
|
465
524
|
|
|
@@ -468,7 +527,7 @@ class HCPHandler:
|
|
|
468
527
|
filenames = listdir(local_folder_path)
|
|
469
528
|
|
|
470
529
|
for filename in filenames:
|
|
471
|
-
self.upload_file(local_folder_path + filename, key + filename)
|
|
530
|
+
self.upload_file(local_folder_path + filename, key + filename, show_progress_bar = show_progress_bar)
|
|
472
531
|
|
|
473
532
|
@check_mounted
|
|
474
533
|
def delete_objects(self, keys : list[str], verbose : bool = True) -> None:
|
|
@@ -56,7 +56,19 @@ def test_list_objects_without_mounting(custom_config : CustomConfig) -> None:
|
|
|
56
56
|
|
|
57
57
|
def test_upload_file(custom_config : CustomConfig) -> None:
|
|
58
58
|
test_mount_bucket(custom_config)
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
# With progress bar
|
|
61
|
+
custom_config.hcp_h.upload_file(
|
|
62
|
+
custom_config.test_file_path,
|
|
63
|
+
custom_config.test_file_path
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Without progress bar
|
|
67
|
+
custom_config.hcp_h.upload_file(
|
|
68
|
+
custom_config.test_file_path,
|
|
69
|
+
custom_config.test_file_path + "_no_progress_bar",
|
|
70
|
+
show_progress_bar = False
|
|
71
|
+
)
|
|
60
72
|
|
|
61
73
|
def test_upload_file_without_mounting(custom_config : CustomConfig) -> None:
|
|
62
74
|
_hcp_h = custom_config.hcp_h
|
|
@@ -104,16 +116,29 @@ def test_get_folder_without_mounting(custom_config : CustomConfig) -> None:
|
|
|
104
116
|
|
|
105
117
|
def test_get_file_in_sub_directory(custom_config : CustomConfig) -> None:
|
|
106
118
|
test_mount_bucket(custom_config)
|
|
107
|
-
|
|
108
|
-
assert custom_config.hcp_h.
|
|
109
|
-
|
|
119
|
+
assert custom_config.hcp_h.object_exists(custom_config.test_file_path)
|
|
120
|
+
assert custom_config.hcp_h.get_object(custom_config.test_file_path)
|
|
121
|
+
|
|
122
|
+
from icecream import ic
|
|
110
123
|
|
|
111
124
|
def test_download_file(custom_config : CustomConfig) -> None:
|
|
112
125
|
test_mount_bucket(custom_config)
|
|
113
|
-
Path(custom_config.result_path).mkdir()
|
|
114
|
-
|
|
115
|
-
custom_config.
|
|
116
|
-
|
|
126
|
+
Path(custom_config.result_path).mkdir()
|
|
127
|
+
|
|
128
|
+
test_folder_path = str(custom_config.test_file_path).rsplit("/", maxsplit = 1)[0] + "/"
|
|
129
|
+
Path(custom_config.result_path + test_folder_path).mkdir(parents = True, exist_ok = True)
|
|
130
|
+
|
|
131
|
+
# With progress bar
|
|
132
|
+
custom_config.hcp_h.download_file(custom_config.test_file_path, custom_config.result_path + custom_config.test_file_path)
|
|
133
|
+
assert cmp(custom_config.result_path + custom_config.test_file_path, custom_config.test_file_path)
|
|
134
|
+
|
|
135
|
+
# Without progress bar
|
|
136
|
+
custom_config.hcp_h.download_file(
|
|
137
|
+
custom_config.test_file_path + "_no_progress_bar",
|
|
138
|
+
custom_config.result_path + custom_config.test_file_path + "_no_progress_bar",
|
|
139
|
+
show_progress_bar = False
|
|
140
|
+
)
|
|
141
|
+
assert cmp(custom_config.result_path + custom_config.test_file_path, custom_config.test_file_path)
|
|
117
142
|
|
|
118
143
|
def test_download_file_without_mounting(custom_config : CustomConfig) -> None:
|
|
119
144
|
_hcp_h = custom_config.hcp_h
|
|
@@ -152,8 +177,7 @@ def test_fuzzy_search_in_bucket_without_mounting(custom_config : CustomConfig) -
|
|
|
152
177
|
|
|
153
178
|
def test_get_object_acl(custom_config : CustomConfig) -> None:
|
|
154
179
|
test_mount_bucket(custom_config)
|
|
155
|
-
|
|
156
|
-
custom_config.hcp_h.get_object_acl(test_file)
|
|
180
|
+
custom_config.hcp_h.get_object_acl(custom_config.test_file_path)
|
|
157
181
|
|
|
158
182
|
def test_get_object_acl_without_mounting(custom_config : CustomConfig) -> None:
|
|
159
183
|
_hcp_h = custom_config.hcp_h
|
|
@@ -189,8 +213,8 @@ def test_get_bucket_acl_without_mounting(custom_config : CustomConfig) -> None:
|
|
|
189
213
|
|
|
190
214
|
def test_delete_file(custom_config : CustomConfig) -> None:
|
|
191
215
|
test_mount_bucket(custom_config)
|
|
192
|
-
|
|
193
|
-
custom_config.hcp_h.delete_object(
|
|
216
|
+
custom_config.hcp_h.delete_object(custom_config.test_file_path)
|
|
217
|
+
custom_config.hcp_h.delete_object(custom_config.test_file_path + "_no_progress_bar")
|
|
194
218
|
custom_config.hcp_h.delete_object("a_sub_directory/a_file")
|
|
195
219
|
custom_config.hcp_h.delete_object("a_sub_directory")
|
|
196
220
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|