pyPreservica 3.0.2__py3-none-any.whl → 3.0.5__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.
- pyPreservica/__init__.py +1 -1
- pyPreservica/uploadAPI.py +34 -37
- {pyPreservica-3.0.2.dist-info → pyPreservica-3.0.5.dist-info}/METADATA +2 -2
- {pyPreservica-3.0.2.dist-info → pyPreservica-3.0.5.dist-info}/RECORD +7 -7
- {pyPreservica-3.0.2.dist-info → pyPreservica-3.0.5.dist-info}/LICENSE.txt +0 -0
- {pyPreservica-3.0.2.dist-info → pyPreservica-3.0.5.dist-info}/WHEEL +0 -0
- {pyPreservica-3.0.2.dist-info → pyPreservica-3.0.5.dist-info}/top_level.txt +0 -0
pyPreservica/__init__.py
CHANGED
|
@@ -23,6 +23,6 @@ from .mdformsAPI import MetadataGroupsAPI, Group, GroupField, GroupFieldType
|
|
|
23
23
|
__author__ = "James Carr (drjamescarr@gmail.com)"
|
|
24
24
|
|
|
25
25
|
# Version of the pyPreservica package
|
|
26
|
-
__version__ = "3.0.
|
|
26
|
+
__version__ = "3.0.5"
|
|
27
27
|
|
|
28
28
|
__license__ = "Apache License Version 2.0"
|
pyPreservica/uploadAPI.py
CHANGED
|
@@ -1659,57 +1659,59 @@ class UploadAPI(AuthenticatedAPI):
|
|
|
1659
1659
|
|
|
1660
1660
|
def crawl_filesystem(self, filesystem_path, bucket_name, preservica_parent, callback: bool = False,
|
|
1661
1661
|
security_tag: str = "open",
|
|
1662
|
-
delete_after_upload: bool = True, max_MB_ingested: int = -1
|
|
1663
|
-
"""
|
|
1664
|
-
Crawl a filesystem and upload the contents to Preservica, the filesystem structure is mirrored in Preservica
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
:param str filesystem_path: The path to the filesystem to crawl
|
|
1668
|
-
:param str bucket_name: The name of the bucket to upload to, use None to send directly to Preservica
|
|
1669
|
-
:param str preservica_parent: The parent folder in Preservica to upload to
|
|
1670
|
-
:param bool callback: Show upload progress bar
|
|
1671
|
-
:param str security_tag: The security tag to apply to the uploaded assets
|
|
1672
|
-
:param bool delete_after_upload: Delete the local copy of the package after the upload has completed
|
|
1673
|
-
:param int max_MB_ingested: The maximum number of MB to ingest
|
|
1674
|
-
:param int max_workflows: The maximum number of workflows to run concurrently
|
|
1662
|
+
delete_after_upload: bool = True, max_MB_ingested: int = -1):
|
|
1675
1663
|
|
|
1664
|
+
from pyPreservica import EntityAPI
|
|
1676
1665
|
|
|
1677
|
-
|
|
1666
|
+
def entity_value(client: EntityAPI, identifier: str) -> Entity:
|
|
1667
|
+
back_off: int = 5
|
|
1668
|
+
while True:
|
|
1669
|
+
try:
|
|
1670
|
+
entities = client.identifier("code", identifier)
|
|
1671
|
+
if bool(len(entities) > 0):
|
|
1672
|
+
return entities.pop()
|
|
1673
|
+
else:
|
|
1674
|
+
return None
|
|
1675
|
+
except HTTPException as e:
|
|
1676
|
+
sleep(back_off)
|
|
1677
|
+
back_off = back_off * 2
|
|
1678
|
+
|
|
1679
|
+
def entity_exists(client: EntityAPI, identifier: str) -> bool:
|
|
1680
|
+
back_off: int = 5
|
|
1681
|
+
while True:
|
|
1682
|
+
try:
|
|
1683
|
+
entities = client.identifier("code", identifier)
|
|
1684
|
+
return bool(len(entities) > 0)
|
|
1685
|
+
except HTTPException as e:
|
|
1686
|
+
sleep(back_off)
|
|
1687
|
+
back_off = back_off * 2
|
|
1678
1688
|
|
|
1679
1689
|
def get_parent(client, identifier, parent_reference):
|
|
1680
|
-
|
|
1681
|
-
if not
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
if
|
|
1685
|
-
folder = entities.pop()
|
|
1690
|
+
dirname_id: str = str(os.path.dirname(identifier))
|
|
1691
|
+
if not dirname_id:
|
|
1692
|
+
dirname_id = identifier
|
|
1693
|
+
folder = entity_value(client, dirname_id)
|
|
1694
|
+
if folder is not None:
|
|
1686
1695
|
folder = client.folder(folder.reference)
|
|
1687
1696
|
return folder.reference
|
|
1688
1697
|
else:
|
|
1689
1698
|
return parent_reference
|
|
1690
1699
|
|
|
1691
1700
|
def get_folder(client, name, tag, parent_reference, identifier):
|
|
1692
|
-
|
|
1693
|
-
if
|
|
1701
|
+
folder = entity_value(client, identifier)
|
|
1702
|
+
if folder is None:
|
|
1694
1703
|
logger.info(f"Creating new folder with name {name}")
|
|
1695
1704
|
folder = client.create_folder(name, name, tag, parent_reference)
|
|
1696
1705
|
client.add_identifier(folder, "code", identifier)
|
|
1697
1706
|
else:
|
|
1698
1707
|
logger.info(f"Found existing folder with name {name}")
|
|
1699
|
-
folder = entities.pop()
|
|
1700
1708
|
return folder
|
|
1701
1709
|
|
|
1702
|
-
from pyPreservica import EntityAPI, WorkflowAPI
|
|
1703
1710
|
entity_client = EntityAPI(username=self.username, password=self.password, server=self.server,
|
|
1704
1711
|
tenant=self.tenant,
|
|
1705
1712
|
two_fa_secret_key=self.two_fa_secret_key, use_shared_secret=self.shared_secret,
|
|
1706
1713
|
protocol=self.protocol)
|
|
1707
1714
|
|
|
1708
|
-
workflow_client = WorkflowAPI(username=self.username, password=self.password, server=self.server,
|
|
1709
|
-
tenant=self.tenant,
|
|
1710
|
-
two_fa_secret_key=self.two_fa_secret_key, use_shared_secret=self.shared_secret,
|
|
1711
|
-
protocol=self.protocol)
|
|
1712
|
-
|
|
1713
1715
|
if preservica_parent:
|
|
1714
1716
|
parent = entity_client.folder(preservica_parent)
|
|
1715
1717
|
logger.info(f"Folders will be created inside Preservica collection {parent.title}")
|
|
@@ -1734,7 +1736,7 @@ class UploadAPI(AuthenticatedAPI):
|
|
|
1734
1736
|
files.remove(file)
|
|
1735
1737
|
continue
|
|
1736
1738
|
asset_code = os.path.join(code, file)
|
|
1737
|
-
if
|
|
1739
|
+
if not entity_exists(entity_client, asset_code):
|
|
1738
1740
|
bytes_ingested = bytes_ingested + os.stat(full_path).st_size
|
|
1739
1741
|
logger.info(f"Adding new file: {file} to package ready for upload")
|
|
1740
1742
|
file_identifiers = {"code": asset_code}
|
|
@@ -1752,18 +1754,13 @@ class UploadAPI(AuthenticatedAPI):
|
|
|
1752
1754
|
else:
|
|
1753
1755
|
progress_display = None
|
|
1754
1756
|
|
|
1755
|
-
workflow_queue_length = len(list(workflow_client.workflow_instances(workflow_state="Active", workflow_type="Ingest")))
|
|
1756
|
-
while workflow_queue_length > max_workflows:
|
|
1757
|
-
sleep(30)
|
|
1758
|
-
workflow_queue_length = len(list(workflow_client.workflow_instances(workflow_state="Active", workflow_type="Ingest")))
|
|
1759
|
-
|
|
1760
1757
|
if bucket_name is None:
|
|
1761
1758
|
self.upload_zip_package(path_to_zip_package=package, callback=progress_display,
|
|
1762
1759
|
delete_after_upload=delete_after_upload)
|
|
1763
1760
|
else:
|
|
1764
1761
|
self.upload_zip_to_Source(path_to_zip_package=package, container_name=bucket_name,
|
|
1765
|
-
|
|
1766
|
-
|
|
1762
|
+
show_progress=bool(progress_display is not None),
|
|
1763
|
+
delete_after_upload=delete_after_upload)
|
|
1767
1764
|
|
|
1768
1765
|
logger.info(f"Uploaded " + "{:.1f}".format(bytes_ingested / (1024 * 1024)) + " MB")
|
|
1769
1766
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pyPreservica
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.5
|
|
4
4
|
Summary: Python library for the Preservica API
|
|
5
5
|
Home-page: https://pypreservica.readthedocs.io/
|
|
6
6
|
Author: James Carr
|
|
@@ -24,7 +24,7 @@ License-File: LICENSE.txt
|
|
|
24
24
|
Requires-Dist: requests
|
|
25
25
|
Requires-Dist: urllib3
|
|
26
26
|
Requires-Dist: certifi
|
|
27
|
-
Requires-Dist: boto3
|
|
27
|
+
Requires-Dist: boto3<1.36.0
|
|
28
28
|
Requires-Dist: botocore
|
|
29
29
|
Requires-Dist: s3transfer
|
|
30
30
|
Requires-Dist: azure-storage-blob
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pyPreservica/__init__.py,sha256=
|
|
1
|
+
pyPreservica/__init__.py,sha256=d5_ol6jTBuUxdJrWZUCoaS7jqw4C-o4uX94c5FrF7Ag,1177
|
|
2
2
|
pyPreservica/adminAPI.py,sha256=511bc5KtrCAXbDyBk39dmDnxUVDaOu6xaiyu0jYhxa4,37781
|
|
3
3
|
pyPreservica/authorityAPI.py,sha256=Eule8g6LXr8c8SFcJgpRah4lH1FgevUItO5HhHDEaZE,9172
|
|
4
4
|
pyPreservica/common.py,sha256=nZeUObfypPXFauag5yYXEutvRC72sNXwVCN0wAFnssg,37796
|
|
@@ -9,11 +9,11 @@ pyPreservica/monitorAPI.py,sha256=HD-PUPdSI9wGAa07e2_2_-FLINH8PoWUwpFogz7F-j4,62
|
|
|
9
9
|
pyPreservica/opex.py,sha256=ccra1S4ojUXS3PlbU8WfxajOkJrwG4OykBnNrYP_jus,4875
|
|
10
10
|
pyPreservica/parAPI.py,sha256=f0ZUxLd0U-BW6kBx5K7W2Pv7NjG3MkTNydmxQ3U1ZVE,9296
|
|
11
11
|
pyPreservica/retentionAPI.py,sha256=F6okFSyqtnLhfMbcyChd_5V-D_PAxNLwyx8XohH2DEM,24840
|
|
12
|
-
pyPreservica/uploadAPI.py,sha256=
|
|
12
|
+
pyPreservica/uploadAPI.py,sha256=j7BnJ3tJZhXOIrAyvalAoAXWPgpQLfNVfoz89kO7D_Q,99367
|
|
13
13
|
pyPreservica/webHooksAPI.py,sha256=_K3KUOsmwYf8qMa-mD47sAmNUW7Pzb9oKVpS0VoSbC0,6827
|
|
14
14
|
pyPreservica/workflowAPI.py,sha256=OcOiiUdrQerbPllrkj1lWpmuW0jTuyyV0urwPSYcd_U,17561
|
|
15
|
-
pyPreservica-3.0.
|
|
16
|
-
pyPreservica-3.0.
|
|
17
|
-
pyPreservica-3.0.
|
|
18
|
-
pyPreservica-3.0.
|
|
19
|
-
pyPreservica-3.0.
|
|
15
|
+
pyPreservica-3.0.5.dist-info/LICENSE.txt,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
16
|
+
pyPreservica-3.0.5.dist-info/METADATA,sha256=HSictV4AVTAsXV0nXT9PAOjyaAb-EQ4hUSIGPDBWCKc,3025
|
|
17
|
+
pyPreservica-3.0.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
18
|
+
pyPreservica-3.0.5.dist-info/top_level.txt,sha256=iIBh6NAznYQHOV8mv_y_kGKSDITek9rANyFDwJsbU-c,13
|
|
19
|
+
pyPreservica-3.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|