Ayon-Python-Api 0.3.1__tar.gz → 0.3.2__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 (24) hide show
  1. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/PKG-INFO +1 -1
  2. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/__init__.py +5 -0
  3. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/server_api.py +44 -28
  4. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/utils.py +20 -0
  5. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/version.py +1 -1
  6. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_python_api.egg-info/PKG-INFO +1 -1
  7. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/pyproject.toml +1 -1
  8. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/LICENSE +0 -0
  9. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/README.md +0 -0
  10. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/_api.py +0 -0
  11. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/constants.py +0 -0
  12. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/entity_hub.py +0 -0
  13. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/events.py +0 -0
  14. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/exceptions.py +0 -0
  15. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/graphql.py +0 -0
  16. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/graphql_queries.py +0 -0
  17. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/operations.py +0 -0
  18. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_api/thumbnails.py +0 -0
  19. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  20. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  21. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_python_api.egg-info/requires.txt +0 -0
  22. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/ayon_python_api.egg-info/top_level.txt +0 -0
  23. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/setup.cfg +0 -0
  24. {ayon-python-api-0.3.1 → ayon-python-api-0.3.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -1,6 +1,8 @@
1
+ from .version import __version__
1
2
  from .utils import (
2
3
  TransferProgress,
3
4
  slugify_string,
5
+ create_dependency_package_basename,
4
6
  )
5
7
  from .server_api import (
6
8
  ServerAPI,
@@ -183,8 +185,11 @@ from ._api import (
183
185
 
184
186
 
185
187
  __all__ = (
188
+ "__version__",
189
+
186
190
  "TransferProgress",
187
191
  "slugify_string",
192
+ "create_dependency_package_basename",
188
193
 
189
194
  "ServerAPI",
190
195
 
@@ -61,6 +61,7 @@ from .utils import (
61
61
  entity_data_json_default,
62
62
  failed_json_default,
63
63
  TransferProgress,
64
+ create_dependency_package_basename,
64
65
  )
65
66
 
66
67
  PatternType = type(re.compile(""))
@@ -114,6 +115,10 @@ class RestApiResponse(object):
114
115
  self.status = status_code
115
116
  self._data = data
116
117
 
118
+ @property
119
+ def text(self):
120
+ return self._response.text
121
+
117
122
  @property
118
123
  def orig_response(self):
119
124
  return self._response
@@ -150,11 +155,13 @@ class RestApiResponse(object):
150
155
  def status_code(self):
151
156
  return self.status
152
157
 
153
- def raise_for_status(self):
158
+ def raise_for_status(self, message=None):
154
159
  try:
155
160
  self._response.raise_for_status()
156
161
  except requests.exceptions.HTTPError as exc:
157
- raise HTTPRequestError(str(exc), exc.response)
162
+ if message is None:
163
+ message = str(exc)
164
+ raise HTTPRequestError(message, exc.response)
158
165
 
159
166
  def __enter__(self, *args, **kwargs):
160
167
  return self._response.__enter__(*args, **kwargs)
@@ -1303,13 +1310,15 @@ class ServerAPI(object):
1303
1310
  progress.set_transfer_done()
1304
1311
  return progress
1305
1312
 
1306
- def _upload_file(self, url, filepath, progress):
1313
+ def _upload_file(self, url, filepath, progress, request_type=None):
1314
+ if request_type is None:
1315
+ request_type = RequestTypes.put
1307
1316
  kwargs = {}
1308
1317
  if self._session is None:
1309
1318
  kwargs["headers"] = self.get_headers()
1310
- post_func = self._base_functions_mapping[RequestTypes.post]
1319
+ post_func = self._base_functions_mapping[request_type]
1311
1320
  else:
1312
- post_func = self._session_functions_mapping[RequestTypes.post]
1321
+ post_func = self._session_functions_mapping[request_type]
1313
1322
 
1314
1323
  with open(filepath, "rb") as stream:
1315
1324
  stream.seek(0, io.SEEK_END)
@@ -1320,7 +1329,9 @@ class ServerAPI(object):
1320
1329
  response.raise_for_status()
1321
1330
  progress.set_transferred_size(size)
1322
1331
 
1323
- def upload_file(self, endpoint, filepath, progress=None):
1332
+ def upload_file(
1333
+ self, endpoint, filepath, progress=None, request_type=None
1334
+ ):
1324
1335
  """Upload file to server.
1325
1336
 
1326
1337
  Todos:
@@ -1331,6 +1342,8 @@ class ServerAPI(object):
1331
1342
  filepath (str): Source filepath.
1332
1343
  progress (Optional[TransferProgress]): Object that gives ability
1333
1344
  to track upload progress.
1345
+ request_type (Optional[RequestType]): Type of request that will
1346
+ be used to upload file.
1334
1347
  """
1335
1348
 
1336
1349
  if endpoint.startswith(self._base_url):
@@ -1349,7 +1362,7 @@ class ServerAPI(object):
1349
1362
  progress.set_started()
1350
1363
 
1351
1364
  try:
1352
- self._upload_file(url, filepath, progress)
1365
+ self._upload_file(url, filepath, progress, request_type)
1353
1366
 
1354
1367
  except Exception as exc:
1355
1368
  progress.set_failed(str(exc))
@@ -1486,13 +1499,11 @@ class ServerAPI(object):
1486
1499
  """
1487
1500
 
1488
1501
  response = self.delete("attributes/{}".format(attribute_name))
1489
- if response.status_code != 204:
1490
- # TODO raise different exception
1491
- raise ValueError(
1492
- "Attribute \"{}\" was not created/updated. {}".format(
1493
- attribute_name, response.detail
1494
- )
1502
+ response.raise_for_status(
1503
+ "Attribute \"{}\" was not created/updated. {}".format(
1504
+ attribute_name, response.detail
1495
1505
  )
1506
+ )
1496
1507
 
1497
1508
  self.reset_attributes_schema()
1498
1509
 
@@ -1732,8 +1743,9 @@ class ServerAPI(object):
1732
1743
  python_version,
1733
1744
  platform_name,
1734
1745
  python_modules,
1746
+ runtime_python_modules,
1735
1747
  checksum,
1736
- checksum_type,
1748
+ checksum_algorithm,
1737
1749
  file_size,
1738
1750
  sources=None,
1739
1751
  ):
@@ -1742,6 +1754,10 @@ class ServerAPI(object):
1742
1754
  This step will create only metadata. Make sure to upload installer
1743
1755
  to the server using 'upload_installer' method.
1744
1756
 
1757
+ Runtime python modules are modules that are required to run AYON
1758
+ desktop application, but are not added to PYTHONPATH for any
1759
+ subprocess.
1760
+
1745
1761
  Args:
1746
1762
  filename (str): Installer filename.
1747
1763
  version (str): Version of installer.
@@ -1749,8 +1765,10 @@ class ServerAPI(object):
1749
1765
  platform_name (str): Name of platform.
1750
1766
  python_modules (dict[str, str]): Python modules that are available
1751
1767
  in installer.
1768
+ runtime_python_modules (dict[str, str]): Runtime python modules
1769
+ that are available in installer.
1752
1770
  checksum (str): Installer file checksum.
1753
- checksum_type (str): Type of checksum used to create checksum.
1771
+ checksum_algorithm (str): Type of checksum used to create checksum.
1754
1772
  file_size (int): File size.
1755
1773
  sources (Optional[list[dict[str, Any]]]): List of sources that
1756
1774
  can be used to download file.
@@ -1762,8 +1780,9 @@ class ServerAPI(object):
1762
1780
  "pythonVersion": python_version,
1763
1781
  "platform": platform_name,
1764
1782
  "pythonModules": python_modules,
1783
+ "runtimePythonModules": runtime_python_modules,
1765
1784
  "checksum": checksum,
1766
- "checksumType": checksum_type,
1785
+ "checksumAlgorithm": checksum_algorithm,
1767
1786
  "size": file_size,
1768
1787
  }
1769
1788
  if sources:
@@ -1781,7 +1800,7 @@ class ServerAPI(object):
1781
1800
  can be used to download file. Fully replaces existing sources.
1782
1801
  """
1783
1802
 
1784
- response = self.post(
1803
+ response = self.patch(
1785
1804
  "desktop/installers/{}".format(filename),
1786
1805
  sources=sources
1787
1806
  )
@@ -1794,7 +1813,7 @@ class ServerAPI(object):
1794
1813
  filename (str): Installer filename.
1795
1814
  """
1796
1815
 
1797
- response = self.delete("dekstop/installers/{}".format(filename))
1816
+ response = self.delete("desktop/installers/{}".format(filename))
1798
1817
  response.raise_for_status()
1799
1818
 
1800
1819
  def download_installer(
@@ -1929,8 +1948,7 @@ class ServerAPI(object):
1929
1948
  checksum=checksum,
1930
1949
  **kwargs
1931
1950
  )
1932
- if response.status not in (200, 201, 204):
1933
- raise ServerError("Failed to create/update dependency")
1951
+ response.raise_for_status("Failed to create/update dependency")
1934
1952
  return response.data
1935
1953
 
1936
1954
  def get_dependency_packages(self):
@@ -2065,8 +2083,7 @@ class ServerAPI(object):
2065
2083
 
2066
2084
  route = self._get_dependency_package_route(filename, platform_name)
2067
2085
  response = self.delete(route)
2068
- if response.status != 200:
2069
- raise ServerError("Failed to delete dependency file")
2086
+ response.raise_for_status("Failed to delete dependency file")
2070
2087
  return response.data
2071
2088
 
2072
2089
  def download_dependency_package(
@@ -2131,6 +2148,10 @@ class ServerAPI(object):
2131
2148
  def create_dependency_package_basename(self, platform_name=None):
2132
2149
  """Create basename for dependency package file.
2133
2150
 
2151
+ Deprecated:
2152
+ Use 'create_dependency_package_basename' from `ayon_api` or
2153
+ `ayon_api.utils` instead.
2154
+
2134
2155
  Args:
2135
2156
  platform_name (Optional[str]): Name of platform for which the
2136
2157
  bundle is targeted. Default value is current platform.
@@ -2139,12 +2160,7 @@ class ServerAPI(object):
2139
2160
  str: Dependency package name with timestamp and platform.
2140
2161
  """
2141
2162
 
2142
- if platform_name is None:
2143
- platform_name = platform.system().lower()
2144
-
2145
- now_date = datetime.datetime.now()
2146
- time_stamp = now_date.strftime("%y%m%d%H%M")
2147
- return "ayon_{}_{}".format(time_stamp, platform_name)
2163
+ return create_dependency_package_basename(platform_name)
2148
2164
 
2149
2165
  def _get_bundles_route(self):
2150
2166
  major, minor, patch, _, _ = self.server_version_tuple
@@ -2,6 +2,7 @@ import re
2
2
  import datetime
3
3
  import uuid
4
4
  import string
5
+ import platform
5
6
  import collections
6
7
  try:
7
8
  # Python 3
@@ -449,3 +450,22 @@ class TransferProgress:
449
450
  destination_url = property(get_destination_url, set_destination_url)
450
451
  content_size = property(get_content_size, set_content_size)
451
452
  transferred_size = property(get_transferred_size, set_transferred_size)
453
+
454
+
455
+ def create_dependency_package_basename(platform_name=None):
456
+ """Create basename for dependency package file.
457
+
458
+ Args:
459
+ platform_name (Optional[str]): Name of platform for which the
460
+ bundle is targeted. Default value is current platform.
461
+
462
+ Returns:
463
+ str: Dependency package name with timestamp and platform.
464
+ """
465
+
466
+ if platform_name is None:
467
+ platform_name = platform.system().lower()
468
+
469
+ now_date = datetime.datetime.now()
470
+ time_stamp = now_date.strftime("%y%m%d%H%M")
471
+ return "ayon_{}_{}".format(time_stamp, platform_name)
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for Ayon server."""
2
- __version__ = "0.3.1"
2
+ __version__ = "0.3.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ayon-python-api"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}
File without changes