ohmyapi 0.1.12__py3-none-any.whl → 0.1.13__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.
- ohmyapi/cli.py +26 -1
- {ohmyapi-0.1.12.dist-info → ohmyapi-0.1.13.dist-info}/METADATA +10 -5
- {ohmyapi-0.1.12.dist-info → ohmyapi-0.1.13.dist-info}/RECORD +5 -5
- {ohmyapi-0.1.12.dist-info → ohmyapi-0.1.13.dist-info}/WHEEL +0 -0
- {ohmyapi-0.1.12.dist-info → ohmyapi-0.1.13.dist-info}/entry_points.txt +0 -0
ohmyapi/cli.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
+
import atexit
|
2
3
|
import importlib
|
3
4
|
import sys
|
4
5
|
import typer
|
@@ -45,6 +46,28 @@ def shell(root: str = "."):
|
|
45
46
|
project_path = Path(root).resolve()
|
46
47
|
project = runtime.Project(project_path)
|
47
48
|
|
49
|
+
# Ensure the ORM is shutdown
|
50
|
+
async def close_project():
|
51
|
+
try:
|
52
|
+
await project.close_orm()
|
53
|
+
print("Tortoise ORM closed successfully.")
|
54
|
+
except Exception as e:
|
55
|
+
print(f"Error closing ORM: {e}")
|
56
|
+
|
57
|
+
def cleanup():
|
58
|
+
loop = None
|
59
|
+
try:
|
60
|
+
loop = asyncio.get_running_loop()
|
61
|
+
except RuntimeError:
|
62
|
+
pass
|
63
|
+
if loop and loop.is_running():
|
64
|
+
asyncio.create_task(close_project())
|
65
|
+
else:
|
66
|
+
asyncio.run(close_project())
|
67
|
+
|
68
|
+
# Ensure the ORM is initialized
|
69
|
+
asyncio.run(project.init_orm())
|
70
|
+
|
48
71
|
try:
|
49
72
|
from IPython import start_ipython
|
50
73
|
shell_vars = {
|
@@ -56,11 +79,13 @@ def shell(root: str = "."):
|
|
56
79
|
c.TerminalInteractiveShell.banner2 = banner.format(**{
|
57
80
|
"project_name": f"{f'{project.settings.PROJECT_NAME} ' if getattr(project.settings, 'PROJECT_NAME', '') else ''}[{Path(project_path).resolve()}]",
|
58
81
|
})
|
82
|
+
atexit.register(cleanup)
|
59
83
|
start_ipython(argv=[], user_ns=shell_vars, config=c)
|
60
84
|
except ImportError:
|
61
85
|
typer.echo("IPython is not installed. Falling back to built-in Python shell.")
|
62
86
|
import code
|
63
|
-
|
87
|
+
atexit.register(cleanup)
|
88
|
+
code.interact(local={"p": project})
|
64
89
|
|
65
90
|
|
66
91
|
@app.command()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ohmyapi
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.13
|
4
4
|
Summary: A Django-like but async web-framework based on FastAPI and TortoiseORM.
|
5
5
|
License-Expression: MIT
|
6
6
|
Keywords: fastapi,tortoise,orm,async,web-framework
|
@@ -353,12 +353,17 @@ Out[2]:
|
|
353
353
|
Routes:
|
354
354
|
- APIRoute(path='/auth/login', name='login', methods=['POST'])
|
355
355
|
- APIRoute(path='/auth/refresh', name='refresh_token', methods=['POST'])
|
356
|
-
- APIRoute(path='/auth/
|
357
|
-
- APIRoute(path='/auth/
|
356
|
+
- APIRoute(path='/auth/introspect', name='introspect', methods=['GET'])
|
357
|
+
- APIRoute(path='/auth/me', name='me', methods=['GET']),
|
358
|
+
'tournament': App: tournament
|
359
|
+
Models:
|
360
|
+
- Tournament
|
361
|
+
- Event
|
362
|
+
- Team
|
363
|
+
Routes:
|
364
|
+
- APIRoute(path='/tournament/', name='list', methods=['GET'])}
|
358
365
|
|
359
366
|
In [3]: from tournament.models import Tournament
|
360
|
-
Out[3]:
|
361
|
-
|
362
367
|
```
|
363
368
|
|
364
369
|
|
@@ -4,7 +4,7 @@ ohmyapi/builtin/auth/__init__.py,sha256=TY1RKgwWmJ6FKz_v4J3m0Ang69qSmtVDLe4rqjLk
|
|
4
4
|
ohmyapi/builtin/auth/models.py,sha256=Xsxn9m5RTgY2a0PPfW3wTj77ocuuISytdl4ec_TR_kw,1524
|
5
5
|
ohmyapi/builtin/auth/permissions.py,sha256=jf-I2b9rIOw2EF4Kga-_Bz1ZPPHU0vHNaXGrDQSwhSI,145
|
6
6
|
ohmyapi/builtin/auth/routes.py,sha256=iMxmgP6TSpMrtSKf-g7mc60NcOiw8FRkngUroalGCyk,5519
|
7
|
-
ohmyapi/cli.py,sha256=
|
7
|
+
ohmyapi/cli.py,sha256=Mip1eBKYyu1hmUHbNW-1kSMc05EJOTVXqdI0c0r_B4g,4440
|
8
8
|
ohmyapi/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
ohmyapi/core/runtime.py,sha256=l5zffc4VTwQOo7G9mfiYHsPGapMONRX_jtO_z9QaKHU,8577
|
10
10
|
ohmyapi/core/scaffolding.py,sha256=iMymscokJ-YqzB0ZTC-gcc2T71o73577j9tnb2x8lH8,2572
|
@@ -19,7 +19,7 @@ ohmyapi/db/exceptions.py,sha256=I7AubrdqQF_UvAvzKqz2ve08-BkXHzEWXnwG300StHE,35
|
|
19
19
|
ohmyapi/db/model/__init__.py,sha256=k3StTNuKatpwZo_Z5JBFa-927eJrzibFE8U4SA82asc,32
|
20
20
|
ohmyapi/db/model/model.py,sha256=BajFtLlQ1s0mZ2hj-_JNQhLQmxuVe-Lw2LuW5t2C7Rw,1579
|
21
21
|
ohmyapi/router.py,sha256=hutccsrP9RT8W5O6uBDhOJehwqrkRoPzaUI5zoHPh9A,55
|
22
|
-
ohmyapi-0.1.
|
23
|
-
ohmyapi-0.1.
|
24
|
-
ohmyapi-0.1.
|
25
|
-
ohmyapi-0.1.
|
22
|
+
ohmyapi-0.1.13.dist-info/METADATA,sha256=UcPMZIqwNTN5LrJ29RYgyLbhMUmCHsVMGm5UFCOHdU0,8812
|
23
|
+
ohmyapi-0.1.13.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
24
|
+
ohmyapi-0.1.13.dist-info/entry_points.txt,sha256=wb3lw8-meAlpiv1mqcQ3m25ukL7djagU_w89GkrC37k,43
|
25
|
+
ohmyapi-0.1.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|