Skip to content

Commit 1726541

Browse files
authored
fixes for new AppEcosystem version (#84)
Signed-off-by: Alexander Piskun <[email protected]>
1 parent d8cb165 commit 1726541

File tree

11 files changed

+48
-20
lines changed

11 files changed

+48
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.0.31 - 2023-08-17]
6+
7+
### Added
8+
9+
- `FsNode` can be created from Nextcloud `UiActionFileInfo` reply.
10+
- Finished documentation.
11+
512
## [0.0.30 - 2023-08-15]
613

714
### Added

examples/as_app/skeleton/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ deploy:
3232
.PHONY: run28
3333
run28:
3434
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent || true
35-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes
35+
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes \
36+
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
3637

3738
.PHONY: run27
3839
run27:
3940
docker exec master-stable27-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent || true
40-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes
41+
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes \
42+
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
4143

4244
.PHONY: manual_register
4345
manual_register:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nc_py_api[app]
1+
nc_py_api[app]>=0.0.30

examples/as_app/to_gif/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ help:
1515
@echo " run27 install ToGif for Nextcloud 27"
1616
@echo " "
1717
@echo " For development of this example use PyCharm run configurations. Development is always set for last Nextcloud."
18-
@echo " First run 'to_gif' and then 'make manual_register', after that you can use/debug/develop it and easy test."
18+
@echo " First run 'ToGif' and then 'make manual_register', after that you can use/debug/develop it and easy test."
1919
@echo " "
2020
@echo " manual_register perform registration of running 'to_gif' into the 'manual_install' deploy daemon."
2121

@@ -32,12 +32,14 @@ deploy:
3232
.PHONY: run28
3333
run28:
3434
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister to_gif --silent || true
35-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register to_gif docker_dev -e --force-scopes
35+
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register to_gif docker_dev -e --force-scopes \
36+
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/to_gif/appinfo/info.xml
3637

3738
.PHONY: run27
3839
run27:
3940
docker exec master-stable27-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister to_gif --silent || true
40-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register to_gif docker_dev -e --force-scopes
41+
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register to_gif docker_dev -e --force-scopes \
42+
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/to_gif/appinfo/info.xml
4143

4244
.PHONY: manual_register
4345
manual_register:

examples/as_app/to_gif/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nc_py_api[app]
1+
nc_py_api[app]>=0.0.30
22
pygifsicle
33
imageio
44
opencv-python

examples/as_app/to_gif/src/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
UiFileActionHandlerInfo,
1919
nc_app,
2020
run_app,
21+
set_handlers,
2122
)
2223

2324
APP = FastAPI()
@@ -88,10 +89,13 @@ def enabled_handler(enabled: bool, nc: NextcloudApp) -> str:
8889
return ""
8990

9091

92+
@APP.on_event("startup")
93+
def initialization():
94+
set_handlers(APP, enabled_handler)
95+
96+
9197
if __name__ == "__main__":
9298
run_app(
93-
APP,
94-
enabled_handler,
9599
"main:APP",
96100
log_level="trace",
97101
)

nc_py_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.0.30"
3+
__version__ = "0.0.31.dev0"

nc_py_api/ex_app/uvicorn_fastapi.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
import typing
33
from os import environ
44

5-
from uvicorn import run
6-
from uvicorn.config import ASGIApplication
5+
try:
6+
import uvicorn
7+
except ImportError as ex:
8+
from .._deffered_error import DeferredError
9+
10+
uvicorn = DeferredError(ex)
711

812

913
def run_app(
10-
uvicorn_app: typing.Union["ASGIApplication", typing.Callable, str],
14+
uvicorn_app: typing.Union[typing.Callable, str, typing.Any],
1115
*args,
1216
**kwargs,
1317
) -> None:
1418
"""Wrapper around Uvicorn's ``run`` function.
1519
16-
Accepts and passes all arguments to it, except for ``host`` and ``port`` which are taken from the environment.
20+
:param uvicorn_app: "ASGIApplication", usually consists of the "name_of_file:FastAPI_class".
21+
:param args: Any args to pass to **uvicorn.run**.
22+
:param kwargs: Any **kwargs** to pass to **uvicorn.run**, except ``host`` and ``port``.
1723
"""
18-
run(uvicorn_app, *args, host=environ.get("APP_HOST", "127.0.0.1"), port=int(environ["APP_PORT"]), **kwargs)
24+
uvicorn.run(uvicorn_app, *args, host=environ.get("APP_HOST", "127.0.0.1"), port=int(environ["APP_PORT"]), **kwargs)

tests/_install_only_enabled_handler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ def enabled_handler(_enabled: bool, _nc: NextcloudApp) -> str:
99
return ""
1010

1111

12+
@APP.on_event("startup")
13+
def initialization():
14+
ex_app.set_handlers(APP, enabled_handler)
15+
16+
1217
if __name__ == "__main__":
13-
ex_app.run_app(APP, enabled_handler, "_install_only_enabled_handler:APP", log_level="warning")
18+
ex_app.run_app("_install_only_enabled_handler:APP", log_level="warning")

tests/nc_app_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def test_app_cfg():
3333
def test_scope_allow_app_ecosystem_disabled():
3434
NC.apps.disable("app_ecosystem_v2")
3535
try:
36-
assert NC_APP.scope_allowed(ApiScope.DAV)
36+
assert NC_APP.scope_allowed(ApiScope.FILES)
3737
NC_APP.update_server_info()
38-
assert not NC_APP.scope_allowed(ApiScope.DAV)
38+
assert not NC_APP.scope_allowed(ApiScope.FILES)
3939
finally:
4040
NC.apps.enable("app_ecosystem_v2")
4141
NC_APP.update_server_info()

0 commit comments

Comments
 (0)