nc-py-api 0.23.0__py3-none-any.whl → 0.24.0__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.
- nc_py_api/_exceptions.py +12 -9
- nc_py_api/_session.py +10 -6
- nc_py_api/_version.py +1 -1
- nc_py_api/ex_app/integration_fastapi.py +8 -1
- nc_py_api/files/_files.py +6 -2
- {nc_py_api-0.23.0.dist-info → nc_py_api-0.24.0.dist-info}/METADATA +1 -1
- {nc_py_api-0.23.0.dist-info → nc_py_api-0.24.0.dist-info}/RECORD +10 -10
- {nc_py_api-0.23.0.dist-info → nc_py_api-0.24.0.dist-info}/WHEEL +1 -1
- {nc_py_api-0.23.0.dist-info → nc_py_api-0.24.0.dist-info}/licenses/AUTHORS +0 -0
- {nc_py_api-0.23.0.dist-info → nc_py_api-0.24.0.dist-info}/licenses/LICENSE.txt +0 -0
nc_py_api/_exceptions.py
CHANGED
|
@@ -8,12 +8,15 @@ class NextcloudException(Exception):
|
|
|
8
8
|
|
|
9
9
|
status_code: int
|
|
10
10
|
reason: str
|
|
11
|
+
info: str
|
|
12
|
+
response: Response | None
|
|
11
13
|
|
|
12
|
-
def __init__(self, status_code: int = 0, reason: str = "", info: str = ""):
|
|
14
|
+
def __init__(self, status_code: int = 0, reason: str = "", info: str = "", response: Response | None = None):
|
|
13
15
|
super(BaseException, self).__init__()
|
|
14
16
|
self.status_code = status_code
|
|
15
17
|
self.reason = reason
|
|
16
18
|
self.info = info
|
|
19
|
+
self.response = response
|
|
17
20
|
|
|
18
21
|
def __str__(self):
|
|
19
22
|
reason = f" {self.reason}" if self.reason else ""
|
|
@@ -24,22 +27,22 @@ class NextcloudException(Exception):
|
|
|
24
27
|
class NextcloudExceptionNotModified(NextcloudException):
|
|
25
28
|
"""The exception indicates that there is no need to retransmit the requested resources."""
|
|
26
29
|
|
|
27
|
-
def __init__(self, reason="Not modified", info: str = ""):
|
|
28
|
-
super().__init__(304, reason=reason, info=info)
|
|
30
|
+
def __init__(self, reason="Not modified", info: str = "", response: Response | None = None):
|
|
31
|
+
super().__init__(304, reason=reason, info=info, response=response)
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
class NextcloudExceptionNotFound(NextcloudException):
|
|
32
35
|
"""The exception that is thrown during operations when the object is not found."""
|
|
33
36
|
|
|
34
|
-
def __init__(self, reason="Not found", info: str = ""):
|
|
35
|
-
super().__init__(404, reason=reason, info=info)
|
|
37
|
+
def __init__(self, reason="Not found", info: str = "", response: Response | None = None):
|
|
38
|
+
super().__init__(404, reason=reason, info=info, response=response)
|
|
36
39
|
|
|
37
40
|
|
|
38
41
|
class NextcloudMissingCapabilities(NextcloudException):
|
|
39
42
|
"""The exception that is thrown when required capability for API is missing."""
|
|
40
43
|
|
|
41
|
-
def __init__(self, reason="Missing capability", info: str = ""):
|
|
42
|
-
super().__init__(412, reason=reason, info=info)
|
|
44
|
+
def __init__(self, reason="Missing capability", info: str = "", response: Response | None = None):
|
|
45
|
+
super().__init__(412, reason=reason, info=info, response=response)
|
|
43
46
|
|
|
44
47
|
|
|
45
48
|
def check_error(response: Response, info: str = ""):
|
|
@@ -59,12 +62,12 @@ def check_error(response: Response, info: str = ""):
|
|
|
59
62
|
phrase = "Not found"
|
|
60
63
|
else:
|
|
61
64
|
phrase = "Unknown error"
|
|
62
|
-
raise NextcloudException(status_code, reason=phrase, info=info)
|
|
65
|
+
raise NextcloudException(status_code, reason=phrase, info=info, response=response)
|
|
63
66
|
|
|
64
67
|
try:
|
|
65
68
|
response.raise_for_status()
|
|
66
69
|
except HTTPError as e:
|
|
67
|
-
raise NextcloudException(status_code, reason=response.reason, info=info) from e
|
|
70
|
+
raise NextcloudException(status_code, reason=response.reason, info=info, response=response) from e
|
|
68
71
|
|
|
69
72
|
|
|
70
73
|
class ModelFetchError(Exception):
|
nc_py_api/_session.py
CHANGED
|
@@ -236,10 +236,12 @@ class NcSessionBasic(NcSessionBase, ABC):
|
|
|
236
236
|
self.init_adapter(restart=True)
|
|
237
237
|
return self.ocs(method, path, **kwargs, content=content, json=json, params=params, nested_req=True)
|
|
238
238
|
if ocs_meta["statuscode"] in (404, OCSRespond.RESPOND_NOT_FOUND):
|
|
239
|
-
raise NextcloudExceptionNotFound(reason=ocs_meta["message"], info=info)
|
|
239
|
+
raise NextcloudExceptionNotFound(reason=ocs_meta["message"], info=info, response=response)
|
|
240
240
|
if ocs_meta["statuscode"] == 304:
|
|
241
|
-
raise NextcloudExceptionNotModified(reason=ocs_meta["message"], info=info)
|
|
242
|
-
raise NextcloudException(
|
|
241
|
+
raise NextcloudExceptionNotModified(reason=ocs_meta["message"], info=info, response=response)
|
|
242
|
+
raise NextcloudException(
|
|
243
|
+
status_code=ocs_meta["statuscode"], reason=ocs_meta["message"], info=info, response=response
|
|
244
|
+
)
|
|
243
245
|
return response_data["ocs"]["data"]
|
|
244
246
|
|
|
245
247
|
def update_server_info(self) -> None:
|
|
@@ -363,10 +365,12 @@ class AsyncNcSessionBasic(NcSessionBase, ABC):
|
|
|
363
365
|
method, path, **kwargs, content=content, json=json, params=params, nested_req=True
|
|
364
366
|
)
|
|
365
367
|
if ocs_meta["statuscode"] in (404, OCSRespond.RESPOND_NOT_FOUND):
|
|
366
|
-
raise NextcloudExceptionNotFound(reason=ocs_meta["message"], info=info)
|
|
368
|
+
raise NextcloudExceptionNotFound(reason=ocs_meta["message"], info=info, response=response)
|
|
367
369
|
if ocs_meta["statuscode"] == 304:
|
|
368
|
-
raise NextcloudExceptionNotModified(reason=ocs_meta["message"], info=info)
|
|
369
|
-
raise NextcloudException(
|
|
370
|
+
raise NextcloudExceptionNotModified(reason=ocs_meta["message"], info=info, response=response)
|
|
371
|
+
raise NextcloudException(
|
|
372
|
+
status_code=ocs_meta["statuscode"], reason=ocs_meta["message"], info=info, response=response
|
|
373
|
+
)
|
|
370
374
|
return response_data["ocs"]["data"]
|
|
371
375
|
|
|
372
376
|
async def update_server_info(self) -> None:
|
nc_py_api/_version.py
CHANGED
|
@@ -252,8 +252,15 @@ def __fetch_model_as_snapshot(
|
|
|
252
252
|
from tqdm import tqdm # noqa isort:skip pylint: disable=C0415 disable=E0401
|
|
253
253
|
|
|
254
254
|
class TqdmProgress(tqdm):
|
|
255
|
+
def __init__(self, *args, **kwargs):
|
|
256
|
+
# huggingface may provide a name, but tqdm rejects a "name"
|
|
257
|
+
# argument, so it needs to be removed
|
|
258
|
+
kwargs.pop("name", None)
|
|
259
|
+
super().__init__(*args, **kwargs)
|
|
260
|
+
|
|
255
261
|
def display(self, msg=None, pos=None):
|
|
256
|
-
|
|
262
|
+
if self.total:
|
|
263
|
+
nc.set_init_status(min(current_progress + int(progress_for_task * self.n / self.total), 99))
|
|
257
264
|
return super().display(msg, pos)
|
|
258
265
|
|
|
259
266
|
workers = download_options.pop("max_workers", 2)
|
nc_py_api/files/_files.py
CHANGED
|
@@ -360,10 +360,14 @@ def lf_parse_webdav_response(
|
|
|
360
360
|
def _webdav_response_to_records(webdav_res: Response, info: str) -> list[dict]:
|
|
361
361
|
check_error(webdav_res, info=info)
|
|
362
362
|
if webdav_res.status_code != 207: # multistatus
|
|
363
|
-
raise NextcloudException(
|
|
363
|
+
raise NextcloudException(
|
|
364
|
+
webdav_res.status_code, "Response is not a multistatus.", info=info, response=webdav_res
|
|
365
|
+
)
|
|
364
366
|
response_data = loads(dumps(xmltodict.parse(webdav_res.text)))
|
|
365
367
|
if "d:error" in response_data:
|
|
366
368
|
err = response_data["d:error"]
|
|
367
|
-
raise NextcloudException(
|
|
369
|
+
raise NextcloudException(
|
|
370
|
+
reason=f'{err["s:exception"]}: {err["s:message"]}'.replace("\n", ""), info=info, response=webdav_res
|
|
371
|
+
)
|
|
368
372
|
response = response_data["d:multistatus"].get("d:response", [])
|
|
369
373
|
return [response] if isinstance(response, dict) else response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nc-py-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24.0
|
|
4
4
|
Summary: Nextcloud Python Framework
|
|
5
5
|
Project-URL: Changelog, https://github.com/cloud-py-api/nc_py_api/blob/main/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://cloud-py-api.github.io/nc_py_api/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
nc_py_api/__init__.py,sha256=S5IytGqp8PkWnmcZXRFPSVEwfeb4iZ8xPeCmSf4sTFQ,460
|
|
2
2
|
nc_py_api/_deffered_error.py,sha256=BpEe_tBqflwfj2Zolb67nhW-K16XX-WbcY2IH_6u8fo,319
|
|
3
|
-
nc_py_api/_exceptions.py,sha256=
|
|
3
|
+
nc_py_api/_exceptions.py,sha256=kkiCblAovOY3Fp-9aruPO4HTGfZiVh_zVUYIvV21J00,2722
|
|
4
4
|
nc_py_api/_misc.py,sha256=dUzCP9VmyhtICTsn1aexlFAYUioBm40k6Zh-YE5WwCY,3333
|
|
5
5
|
nc_py_api/_preferences.py,sha256=OtovFZuGHnHYKjdDjSnUappO795tW8Oxj7qVaejHWpQ,2479
|
|
6
6
|
nc_py_api/_preferences_ex.py,sha256=Y6sDBrFJc7lk8BoDUfjC_iwOfjSbPPNPpcSxsL1fyIM,6391
|
|
7
|
-
nc_py_api/_session.py,sha256=
|
|
7
|
+
nc_py_api/_session.py,sha256=R4gVvEHvJgKBqcYSUOs4SFrHi5XylER6oP2nWudxbBo,22192
|
|
8
8
|
nc_py_api/_talk_api.py,sha256=0Uo7OduYniuuX3UQPb468RyGJJ-PWBCgJ5HoPuz5Qa0,51068
|
|
9
9
|
nc_py_api/_theming.py,sha256=hTr3nuOemSuRFZaPy9iXNmBM7rDgQHECH43tHMWGqEY,1870
|
|
10
|
-
nc_py_api/_version.py,sha256=
|
|
10
|
+
nc_py_api/_version.py,sha256=R7Ta4vklXDcaT--ibtsvGjCCoif9zwhnNycbsPdzydw,52
|
|
11
11
|
nc_py_api/activity.py,sha256=t9VDSnnaXRNOvALqOSGCeXSQZ-426pCOMSfQ96JHys4,9574
|
|
12
12
|
nc_py_api/apps.py,sha256=Us2y2lszdxXlD8t6kxwd5_Nrrmazc0EvZXIH9O-ol80,9315
|
|
13
13
|
nc_py_api/calendar_api.py,sha256=a2Q5EGf5_swWPYkUbHnoEg6h1S9KTEUQD7f7DljGHYY,1442
|
|
@@ -25,7 +25,7 @@ nc_py_api/weather_status.py,sha256=wAkjuJPjxc0Rxe4za0BzfwB0XeUmkCXoisJtTH3-qdQ,7
|
|
|
25
25
|
nc_py_api/webhooks.py,sha256=BGHRtankgbUkcqBRJTFShjRLpaVoFNcjLsrVitoNziM,8083
|
|
26
26
|
nc_py_api/ex_app/__init__.py,sha256=6Lwid4bBXOSrZf_ocf5m8qkkO1OgYxG0GTs4q6Nw72o,691
|
|
27
27
|
nc_py_api/ex_app/defs.py,sha256=FaQInH3jLugKxDUqpwrXdkMT-lBxmoqWmXJXc11fa6A,727
|
|
28
|
-
nc_py_api/ex_app/integration_fastapi.py,sha256=
|
|
28
|
+
nc_py_api/ex_app/integration_fastapi.py,sha256=GxCYt1baibok4V3XD1-OOPTEsAuqgZ2VN0XyZDWFZUk,13674
|
|
29
29
|
nc_py_api/ex_app/logger.py,sha256=nAHLObuPvl3UBLrlqZulgoxxVaAJ661iP4F6bTW-V-Y,1475
|
|
30
30
|
nc_py_api/ex_app/misc.py,sha256=c7B0uE8isaIi4SQbxURGUuWjZaaXiLg3Ov6cqvRYplE,2298
|
|
31
31
|
nc_py_api/ex_app/occ_commands.py,sha256=hb2BJuvFKIigvLycSCyAe9v6hedq4Gfu2junQZTaK_M,5219
|
|
@@ -41,12 +41,12 @@ nc_py_api/ex_app/ui/settings.py,sha256=VyGly-rCYMw9Zw7cTYRYilXXKe7f6tesTAW83X5gH
|
|
|
41
41
|
nc_py_api/ex_app/ui/top_menu.py,sha256=oCgGtIoMYbp-5iN5aXEbT7Q88HtccR7hg6IBFgbbyX4,5118
|
|
42
42
|
nc_py_api/ex_app/ui/ui.py,sha256=OqFHKn6oIZli8T1wnv6YtQ4glNfeNb90WwGCvtWI1Z4,1632
|
|
43
43
|
nc_py_api/files/__init__.py,sha256=aN6Lhc0km5eAIGFA8YoG-xXDOzIJILV2izCzHeC-a78,17949
|
|
44
|
-
nc_py_api/files/_files.py,sha256=
|
|
44
|
+
nc_py_api/files/_files.py,sha256=r0Y3u-sX-D07c7wXH1jg8GIxJiqATnSxf8LSVBOBZsY,14386
|
|
45
45
|
nc_py_api/files/files.py,sha256=A05iT_s5cYMK1MtarqdjTZP9QA1l_SiINq805VLrzuY,24999
|
|
46
46
|
nc_py_api/files/files_async.py,sha256=GoTPswMgozcx3Vkbj4YSitNeP7vpPJ4lIbrCnj77rP4,25858
|
|
47
47
|
nc_py_api/files/sharing.py,sha256=VRZCl-TYK6dbu9rUHPs3_jcVozu1EO8bLGZwoRpiLsU,14439
|
|
48
|
-
nc_py_api-0.
|
|
49
|
-
nc_py_api-0.
|
|
50
|
-
nc_py_api-0.
|
|
51
|
-
nc_py_api-0.
|
|
52
|
-
nc_py_api-0.
|
|
48
|
+
nc_py_api-0.24.0.dist-info/METADATA,sha256=HGqQtLkGd1oZCZOV0M3jcUGlh_-mwNcp4UMW5tiySyk,8024
|
|
49
|
+
nc_py_api-0.24.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
50
|
+
nc_py_api-0.24.0.dist-info/licenses/AUTHORS,sha256=B2Q9q9XH3PAxJp0V3GiKQc1l0z7vtGDpDHqda-ISWKM,616
|
|
51
|
+
nc_py_api-0.24.0.dist-info/licenses/LICENSE.txt,sha256=OLEMh401fAumGHfRSna365MLIfnjdTcdOHZ6QOzMjkg,1551
|
|
52
|
+
nc_py_api-0.24.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|