plain.dev 0.32.1__py3-none-any.whl → 0.33.1__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.
- plain/dev/CHANGELOG.md +26 -0
- plain/dev/README.md +16 -1
- plain/dev/cli.py +192 -397
- plain/dev/contribute/cli.py +1 -2
- plain/dev/core.py +346 -0
- plain/dev/poncho/printer.py +31 -1
- plain/dev/precommit/cli.py +48 -51
- plain/dev/process.py +127 -0
- plain/dev/services.py +9 -67
- {plain_dev-0.32.1.dist-info → plain_dev-0.33.1.dist-info}/METADATA +17 -3
- {plain_dev-0.32.1.dist-info → plain_dev-0.33.1.dist-info}/RECORD +14 -13
- plain/dev/dev_pid.py +0 -36
- {plain_dev-0.32.1.dist-info → plain_dev-0.33.1.dist-info}/WHEEL +0 -0
- {plain_dev-0.32.1.dist-info → plain_dev-0.33.1.dist-info}/entry_points.txt +0 -0
- {plain_dev-0.32.1.dist-info → plain_dev-0.33.1.dist-info}/licenses/LICENSE +0 -0
plain/dev/services.py
CHANGED
@@ -1,36 +1,17 @@
|
|
1
1
|
import os
|
2
|
-
import subprocess
|
3
|
-
import time
|
4
2
|
import tomllib
|
5
|
-
from importlib.util import find_spec
|
6
3
|
from pathlib import Path
|
7
4
|
|
8
|
-
import click
|
9
|
-
|
10
5
|
from plain.runtime import APP_PATH, PLAIN_TEMP_PATH
|
11
6
|
|
12
|
-
from .
|
7
|
+
from .process import ProcessManager
|
13
8
|
from .utils import has_pyproject_toml
|
14
9
|
|
15
10
|
|
16
|
-
class
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def write(self):
|
21
|
-
pid = os.getpid()
|
22
|
-
self.pidfile.parent.mkdir(parents=True, exist_ok=True)
|
23
|
-
with self.pidfile.open("w+") as f:
|
24
|
-
f.write(str(pid))
|
25
|
-
|
26
|
-
def rm(self):
|
27
|
-
self.pidfile.unlink()
|
28
|
-
|
29
|
-
def exists(self):
|
30
|
-
return self.pidfile.exists()
|
11
|
+
class ServicesProcess(ProcessManager):
|
12
|
+
pidfile = PLAIN_TEMP_PATH / "dev" / "services.pid"
|
13
|
+
log_dir = PLAIN_TEMP_PATH / "dev" / "logs" / "services"
|
31
14
|
|
32
|
-
|
33
|
-
class Services:
|
34
15
|
@staticmethod
|
35
16
|
def get_services(root):
|
36
17
|
if not has_pyproject_toml(root):
|
@@ -46,20 +27,10 @@ class Services:
|
|
46
27
|
.get("services", {})
|
47
28
|
)
|
48
29
|
|
49
|
-
def __init__(self):
|
50
|
-
self.poncho = PonchoManager()
|
51
|
-
|
52
|
-
@staticmethod
|
53
|
-
def are_running():
|
54
|
-
pid = ServicesPid()
|
55
|
-
return pid.exists()
|
56
|
-
|
57
30
|
def run(self):
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
pid = ServicesPid()
|
62
|
-
pid.write()
|
31
|
+
self.write_pidfile()
|
32
|
+
self.prepare_log()
|
33
|
+
self.init_poncho(print)
|
63
34
|
|
64
35
|
try:
|
65
36
|
services = self.get_services(APP_PATH.parent)
|
@@ -73,34 +44,5 @@ class Services:
|
|
73
44
|
|
74
45
|
self.poncho.loop()
|
75
46
|
finally:
|
76
|
-
|
77
|
-
|
78
|
-
def __enter__(self):
|
79
|
-
if not self.get_services(APP_PATH.parent):
|
80
|
-
# No-op if no services are defined
|
81
|
-
return
|
82
|
-
|
83
|
-
if self.are_running():
|
84
|
-
click.secho("Services already running", fg="yellow")
|
85
|
-
return
|
86
|
-
|
87
|
-
print("Starting `plain dev services`")
|
88
|
-
self._subprocess = subprocess.Popen(
|
89
|
-
["plain", "dev", "services"], cwd=APP_PATH.parent
|
90
|
-
)
|
91
|
-
|
92
|
-
if find_spec("plain.models"):
|
93
|
-
time.sleep(0.5) # Give it a chance to hit on the first try
|
94
|
-
subprocess.check_call(["plain", "models", "db-wait"], env=os.environ)
|
95
|
-
else:
|
96
|
-
# A bit of a hack to wait for the services to start
|
97
|
-
time.sleep(3)
|
98
|
-
|
99
|
-
def __exit__(self, *args):
|
100
|
-
if not hasattr(self, "_subprocess"):
|
101
|
-
return
|
102
|
-
|
103
|
-
self._subprocess.terminate()
|
104
|
-
|
105
|
-
# Flush the buffer so the output doesn't spill over
|
106
|
-
self._subprocess.communicate()
|
47
|
+
self.rm_pidfile()
|
48
|
+
self.close()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: plain.dev
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.33.1
|
4
4
|
Summary: Local development tools for Plain.
|
5
5
|
Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
|
6
6
|
License-Expression: BSD-3-Clause
|
@@ -10,7 +10,6 @@ Requires-Dist: click>=8.0.0
|
|
10
10
|
Requires-Dist: gunicorn>20
|
11
11
|
Requires-Dist: inotify
|
12
12
|
Requires-Dist: plain<1.0.0
|
13
|
-
Requires-Dist: psycopg[binary]~=3.2.2
|
14
13
|
Requires-Dist: python-dotenv~=1.0.0
|
15
14
|
Requires-Dist: requests>=2.0.0
|
16
15
|
Requires-Dist: rich
|
@@ -26,6 +25,7 @@ The `plain.dev` package can be [installed from PyPI](https://pypi.org/project/pl
|
|
26
25
|
|
27
26
|
- [`plain dev`](#plain-dev)
|
28
27
|
- [`plain dev services`](#plain-dev-services)
|
28
|
+
- [`plain dev logs`](#plain-dev-logs)
|
29
29
|
- [`plain pre-commit`](#plain-pre-commit)
|
30
30
|
- [`plain contrib`](#plain-contrib)
|
31
31
|
- [VS Code debugging](#vscode-debugging)
|
@@ -62,12 +62,26 @@ Unlike [services](#services), custom processes are _only_ run during `plain dev`
|
|
62
62
|
```toml
|
63
63
|
# pyproject.toml
|
64
64
|
[tool.plain.dev.run]
|
65
|
-
ngrok = {command = "ngrok http $PORT"}
|
65
|
+
ngrok = {command = "ngrok http $PORT"}
|
66
66
|
```
|
67
67
|
|
68
68
|
## `plain dev services`
|
69
69
|
|
70
70
|
Starts your [services](#services) by themselves.
|
71
|
+
Logs are stored in `.plain/dev/logs/services/`.
|
72
|
+
|
73
|
+
## `plain dev logs`
|
74
|
+
|
75
|
+
Show output from recent `plain dev` runs.
|
76
|
+
|
77
|
+
Logs are stored in `.plain/dev/logs/run/`.
|
78
|
+
|
79
|
+
```bash
|
80
|
+
plain dev logs # print last log
|
81
|
+
plain dev logs -f # follow the latest log
|
82
|
+
plain dev logs --pid 1234
|
83
|
+
plain dev logs --path
|
84
|
+
```
|
71
85
|
|
72
86
|
## `plain pre-commit`
|
73
87
|
|
@@ -1,29 +1,30 @@
|
|
1
|
-
plain/dev/CHANGELOG.md,sha256=
|
2
|
-
plain/dev/README.md,sha256=
|
1
|
+
plain/dev/CHANGELOG.md,sha256=jAFWdcHPeVbC9k1uvbii7gRV18rbszI0y_5inhN9I5s,3653
|
2
|
+
plain/dev/README.md,sha256=Q-lyWmFH5DOq-xCGCLtEUNcanoldzQGANionqiE67Nw,4109
|
3
3
|
plain/dev/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
4
|
-
plain/dev/cli.py,sha256=
|
4
|
+
plain/dev/cli.py,sha256=siRCSuSOoeYUWGUr3OPeat-OULozhGYhMmJ_gAe9DpA,8146
|
5
|
+
plain/dev/core.py,sha256=SOR1xH0-TYY6zDo_G7dTqatKbg3hNuVO9uHBIVt7_Ac,12086
|
5
6
|
plain/dev/debug.py,sha256=Ka84K8zUdF0kMYNyqiLYDrdzU1jU8LSOkts3hcw_Gok,1005
|
6
7
|
plain/dev/default_settings.py,sha256=uXWYORWP_aRDwXIFXdu5kHyiBFUZzARIJdhPeFaX35c,75
|
7
|
-
plain/dev/dev_pid.py,sha256=wV8avKNY-zyd-FVQYjtjg5y4zOE7sgiVOhIjj9OmWNg,882
|
8
8
|
plain/dev/entrypoints.py,sha256=diqNwA6eydUMtoO7p_rH-DtSYsw5-GBmjFe1Z5bHagc,579
|
9
9
|
plain/dev/gunicorn_logging.json,sha256=3H6b6bQf_KdY61gzypvI0ly_Jduy-Uhqs2ra9ttzGJQ,867
|
10
10
|
plain/dev/mkcert.py,sha256=fm1U_UTGPREso6ZaP79WqEvd9uvA4lYWFo6fKhNglMM,3911
|
11
11
|
plain/dev/pdb.py,sha256=4ru3rlIIyuYVXteyI7v42i4MmdBIjpJP0IJemBpf83A,3742
|
12
|
-
plain/dev/
|
12
|
+
plain/dev/process.py,sha256=2Gdfng8ptRA7qPLONXbCP8vUTh-k-trmXqt6dcPV3o8,4051
|
13
|
+
plain/dev/services.py,sha256=wg0pBhrnZDIALjFy6jFv6U1tryADGybLnhQPXMx1WoA,1269
|
13
14
|
plain/dev/utils.py,sha256=4wMzpvj1Is_c0QxhsTu34_P9wAYlzw4glNPfVtZr_0A,123
|
14
15
|
plain/dev/contribute/README.md,sha256=v9Ympugu2wvDEe_045WJnF1dmC4ZH7v_Bnxkpfaf_rM,329
|
15
16
|
plain/dev/contribute/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
16
|
-
plain/dev/contribute/cli.py,sha256=
|
17
|
+
plain/dev/contribute/cli.py,sha256=jQnXxmv29sHa19vPUqYWH6z8HvsNL12rEdCPzPJge-U,3575
|
17
18
|
plain/dev/poncho/__init__.py,sha256=MDOk2rhhoR3V-I-rg6tMHFeX60vTGJuQ14RI-_N6tQY,97
|
18
19
|
plain/dev/poncho/color.py,sha256=Dk77inPR9qNc9vCaZOGk8W9skXfRgoUlxp_E6mhPNns,610
|
19
20
|
plain/dev/poncho/compat.py,sha256=l66WZLR7kRpO8P8DI5-aUsbNlohPaXEurQ5xXESQYDs,1276
|
20
21
|
plain/dev/poncho/manager.py,sha256=l0tcVslJ0snEiNPn4Pgphti_aIFKp1yfRx6Cng1F55w,6817
|
21
|
-
plain/dev/poncho/printer.py,sha256=
|
22
|
+
plain/dev/poncho/printer.py,sha256=1LhaQx55ujxmo-SSwQtzsh0bO6HL5q2_kiA0jLWEB-o,2976
|
22
23
|
plain/dev/poncho/process.py,sha256=JJOKy-C6vMCg7-6JMCtu6C649h7HmOBSJqDP_hnX49I,2637
|
23
24
|
plain/dev/precommit/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
24
|
-
plain/dev/precommit/cli.py,sha256=
|
25
|
-
plain_dev-0.
|
26
|
-
plain_dev-0.
|
27
|
-
plain_dev-0.
|
28
|
-
plain_dev-0.
|
29
|
-
plain_dev-0.
|
25
|
+
plain/dev/precommit/cli.py,sha256=ax_2cUpYfOhh6iZirhZS5cX0jy6rTfJAWzwm1qeRm58,3176
|
26
|
+
plain_dev-0.33.1.dist-info/METADATA,sha256=v0E-ImpPqMVUApj6s8tddCAd3bYHwI3IF7NSSbnt6E4,4576
|
27
|
+
plain_dev-0.33.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
28
|
+
plain_dev-0.33.1.dist-info/entry_points.txt,sha256=zrcTOiFk_MLKsnYVlwVP7aMm1XLEqq7w4EBkJ-3ge-g,114
|
29
|
+
plain_dev-0.33.1.dist-info/licenses/LICENSE,sha256=Cx4Dq9yR2fLHthf8Ke36B8QJvE1bZFXVzDIGE8wGzsY,4132
|
30
|
+
plain_dev-0.33.1.dist-info/RECORD,,
|
plain/dev/dev_pid.py
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
|
3
|
-
from plain.runtime import PLAIN_TEMP_PATH
|
4
|
-
|
5
|
-
|
6
|
-
class DevPid:
|
7
|
-
"""Manage a pidfile for the running ``plain dev`` command."""
|
8
|
-
|
9
|
-
def __init__(self):
|
10
|
-
self.pidfile = PLAIN_TEMP_PATH / "dev" / "dev.pid"
|
11
|
-
|
12
|
-
def write(self):
|
13
|
-
pid = os.getpid()
|
14
|
-
self.pidfile.parent.mkdir(parents=True, exist_ok=True)
|
15
|
-
with self.pidfile.open("w+") as f:
|
16
|
-
f.write(str(pid))
|
17
|
-
|
18
|
-
def rm(self):
|
19
|
-
if self.pidfile.exists():
|
20
|
-
self.pidfile.unlink()
|
21
|
-
|
22
|
-
def exists(self):
|
23
|
-
if not self.pidfile.exists():
|
24
|
-
return False
|
25
|
-
try:
|
26
|
-
pid = int(self.pidfile.read_text())
|
27
|
-
except (ValueError, OSError):
|
28
|
-
self.rm()
|
29
|
-
return False
|
30
|
-
try:
|
31
|
-
os.kill(pid, 0)
|
32
|
-
except OSError:
|
33
|
-
# Stale pidfile
|
34
|
-
self.rm()
|
35
|
-
return False
|
36
|
-
return True
|
File without changes
|
File without changes
|
File without changes
|