roboherd 0.1.9__py3-none-any.whl → 0.1.11__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.
Potentially problematic release.
This version of roboherd might be problematic. Click here for more details.
- roboherd/__main__.py +42 -6
- roboherd/herd/__init__.py +21 -6
- roboherd/herd/manager/__init__.py +1 -2
- roboherd/herd/test_herd.py +2 -2
- roboherd/register.py +4 -2
- roboherd/util.py +2 -2
- roboherd/version.py +1 -0
- {roboherd-0.1.9.dist-info → roboherd-0.1.11.dist-info}/METADATA +1 -1
- {roboherd-0.1.9.dist-info → roboherd-0.1.11.dist-info}/RECORD +11 -10
- {roboherd-0.1.9.dist-info → roboherd-0.1.11.dist-info}/WHEEL +0 -0
- {roboherd-0.1.9.dist-info → roboherd-0.1.11.dist-info}/entry_points.txt +0 -0
roboherd/__main__.py
CHANGED
|
@@ -11,12 +11,13 @@ from roboherd.herd.manager import HerdManager
|
|
|
11
11
|
from roboherd.util import create_connection
|
|
12
12
|
from roboherd.register import register as run_register
|
|
13
13
|
from roboherd.validators import validators
|
|
14
|
+
from roboherd.version import __version__
|
|
14
15
|
|
|
15
16
|
logging.basicConfig(level=logging.INFO)
|
|
16
17
|
logging.captureWarnings(True)
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
@click.group()
|
|
20
|
+
@click.group(invoke_without_command=True)
|
|
20
21
|
@click.option(
|
|
21
22
|
"--connection_string",
|
|
22
23
|
default=None,
|
|
@@ -28,9 +29,22 @@ logging.captureWarnings(True)
|
|
|
28
29
|
help="Base url to create cows with",
|
|
29
30
|
)
|
|
30
31
|
@click.option("--config_file", default="roboherd.toml", help="Configuration file")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--version", is_flag=True, default=False, help="display version then exit"
|
|
34
|
+
)
|
|
31
35
|
@click.pass_context
|
|
32
|
-
def main(
|
|
36
|
+
def main(
|
|
37
|
+
ctx: click.Context,
|
|
38
|
+
connection_string: str,
|
|
39
|
+
base_url: str,
|
|
40
|
+
config_file: str,
|
|
41
|
+
version: bool,
|
|
42
|
+
):
|
|
33
43
|
"""Configuration is usually loaded from the config_file. These options can be overwritten by passing as a command line argument."""
|
|
44
|
+
if version:
|
|
45
|
+
print(f"roboherd version: {__version__}")
|
|
46
|
+
exit(0)
|
|
47
|
+
|
|
34
48
|
settings = dynaconf.Dynaconf(
|
|
35
49
|
settings_files=[config_file],
|
|
36
50
|
envvar_prefix="ROBOHERD",
|
|
@@ -44,17 +58,39 @@ def main(ctx, connection_string, base_url, config_file):
|
|
|
44
58
|
if connection_string:
|
|
45
59
|
ctx.obj["connection_string"] = connection_string
|
|
46
60
|
else:
|
|
47
|
-
ctx.obj["connection_string"] = settings.connection_string
|
|
61
|
+
ctx.obj["connection_string"] = settings.connection_string # type: ignore
|
|
48
62
|
|
|
49
63
|
if base_url:
|
|
50
64
|
ctx.obj["base_url"] = base_url
|
|
51
65
|
else:
|
|
52
|
-
ctx.obj["base_url"] = settings.base_url
|
|
66
|
+
ctx.obj["base_url"] = settings.base_url # type: ignore
|
|
67
|
+
|
|
68
|
+
print("Please specify a command")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@main.command()
|
|
72
|
+
@click.option("--fail", is_flag=True, default=False, help="Fail if actors do not exist")
|
|
73
|
+
@click.pass_context
|
|
74
|
+
def check(ctx: click.Context, fail: bool):
|
|
75
|
+
"""Checks that the connection is configured correctly"""
|
|
76
|
+
|
|
77
|
+
create_connection(ctx)
|
|
78
|
+
|
|
79
|
+
herd = RoboHerd(base_url=ctx.obj["base_url"])
|
|
80
|
+
|
|
81
|
+
settings = ctx.obj["settings"]
|
|
82
|
+
|
|
83
|
+
if settings.get("cow"):
|
|
84
|
+
herd.manager = HerdManager.from_settings(settings)
|
|
85
|
+
asyncio.run(herd.check(ctx.obj["connection"], raise_if_cows_to_create=fail))
|
|
86
|
+
else:
|
|
87
|
+
click.echo("No cows specified")
|
|
88
|
+
exit(1)
|
|
53
89
|
|
|
54
90
|
|
|
55
91
|
@main.command()
|
|
56
92
|
@click.pass_context
|
|
57
|
-
def run(ctx):
|
|
93
|
+
def run(ctx: click.Context):
|
|
58
94
|
"""Runs the roboherd by connecting to the server."""
|
|
59
95
|
|
|
60
96
|
create_connection(ctx)
|
|
@@ -91,7 +127,7 @@ def watch(ctx):
|
|
|
91
127
|
prompt=True,
|
|
92
128
|
)
|
|
93
129
|
@click.option("--fediverse", help="Fediverse handle", prompt=True)
|
|
94
|
-
def register(ctx, name, password, fediverse):
|
|
130
|
+
def register(ctx: click.Context, name: str, password: str, fediverse: str):
|
|
95
131
|
"""Registers a new account on dev.bovine.social. All three options are required. If not provided, you will be prompted for them."""
|
|
96
132
|
|
|
97
133
|
if os.path.exists(ctx.obj["config_file"]):
|
roboherd/herd/__init__.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
|
-
from typing import List, Tuple
|
|
5
4
|
from dataclasses import dataclass, field
|
|
6
5
|
|
|
7
6
|
from roboherd.cow import RoboCow, CronEntry
|
|
@@ -20,7 +19,7 @@ class RoboHerd:
|
|
|
20
19
|
base_url: str = "http://abel"
|
|
21
20
|
|
|
22
21
|
manager: HerdManager = field(default_factory=HerdManager)
|
|
23
|
-
cows:
|
|
22
|
+
cows: list[RoboCow] = field(default_factory=list) # type: ignore
|
|
24
23
|
|
|
25
24
|
async def run(self, connection: Almabtrieb):
|
|
26
25
|
async with connection:
|
|
@@ -28,12 +27,26 @@ class RoboHerd:
|
|
|
28
27
|
await self.startup(connection)
|
|
29
28
|
await self.process(connection)
|
|
30
29
|
|
|
30
|
+
async def check(
|
|
31
|
+
self, connection: Almabtrieb, raise_if_cows_to_create: bool = False
|
|
32
|
+
):
|
|
33
|
+
async with connection:
|
|
34
|
+
if not connection.information:
|
|
35
|
+
raise Exception("Could not get information from server")
|
|
36
|
+
self.validate(connection)
|
|
37
|
+
cows_to_create = self.manager.cows_to_create(connection.information.actors)
|
|
38
|
+
|
|
39
|
+
if len(cows_to_create) > 0:
|
|
40
|
+
print("Missing cows: " + ", ".join([x.name for x in cows_to_create]))
|
|
41
|
+
|
|
42
|
+
if raise_if_cows_to_create:
|
|
43
|
+
raise Exception("Missing cows")
|
|
44
|
+
|
|
31
45
|
async def startup(self, connection: Almabtrieb):
|
|
32
46
|
if not connection.information:
|
|
33
47
|
raise Exception("Could not get information from server")
|
|
34
48
|
|
|
35
49
|
self.cows = self.manager.existing_cows(connection.information.actors)
|
|
36
|
-
|
|
37
50
|
cows_to_create = self.manager.cows_to_create(connection.information.actors)
|
|
38
51
|
|
|
39
52
|
for cow_config in cows_to_create:
|
|
@@ -65,8 +78,10 @@ class RoboHerd:
|
|
|
65
78
|
|
|
66
79
|
connection.add_on_disconnect(scheduler.stop)
|
|
67
80
|
|
|
68
|
-
def validate(self, connection):
|
|
81
|
+
def validate(self, connection: Almabtrieb):
|
|
69
82
|
result = connection.information
|
|
83
|
+
if result is None:
|
|
84
|
+
raise ValueError("information not retrieved from connection")
|
|
70
85
|
|
|
71
86
|
logger.info("Got base urls: %s", ",".join(result.base_urls))
|
|
72
87
|
|
|
@@ -78,7 +93,7 @@ class RoboHerd:
|
|
|
78
93
|
)
|
|
79
94
|
raise ValueError("Incorrectly configured base url")
|
|
80
95
|
|
|
81
|
-
def cron_entries(self) ->
|
|
96
|
+
def cron_entries(self) -> list[tuple[RoboCow, CronEntry]]:
|
|
82
97
|
"""Returns the cron entries of all cows"""
|
|
83
98
|
|
|
84
99
|
result = []
|
|
@@ -88,7 +103,7 @@ class RoboHerd:
|
|
|
88
103
|
|
|
89
104
|
return result
|
|
90
105
|
|
|
91
|
-
def incoming_handlers(self) ->
|
|
106
|
+
def incoming_handlers(self) -> list[RoboCow]:
|
|
92
107
|
result = []
|
|
93
108
|
for cow in self.cows:
|
|
94
109
|
if cow.internals.handlers.has_handlers:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
from typing import List
|
|
4
3
|
from dataclasses import dataclass, field
|
|
5
4
|
|
|
6
5
|
from almabtrieb.model import ActorInformation
|
|
@@ -21,7 +20,7 @@ class HerdManager:
|
|
|
21
20
|
def from_settings(settings):
|
|
22
21
|
return HerdManager(herd_config=HerdConfig.from_settings(settings))
|
|
23
22
|
|
|
24
|
-
def existing_cows(self, actors:
|
|
23
|
+
def existing_cows(self, actors: list[ActorInformation]) -> list[RoboCow]:
|
|
25
24
|
existing_cows = []
|
|
26
25
|
|
|
27
26
|
for info in actors:
|
roboherd/herd/test_herd.py
CHANGED
|
@@ -6,11 +6,11 @@ from roboherd.examples.dev_null import bot as dev_null
|
|
|
6
6
|
|
|
7
7
|
from roboherd.cow import CronEntry
|
|
8
8
|
|
|
9
|
-
from . import RoboHerd
|
|
9
|
+
from . import RoboHerd, RoboCow
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@pytest.mark.parametrize("cow, length", [(moocow, 0), (bot, 1)])
|
|
13
|
-
def test_cron_entries(cow, length):
|
|
13
|
+
def test_cron_entries(cow: RoboCow, length: int):
|
|
14
14
|
manager = RoboHerd(cows=[cow])
|
|
15
15
|
|
|
16
16
|
assert len(manager.cron_entries()) == length
|
roboherd/register.py
CHANGED
|
@@ -2,7 +2,9 @@ import aiohttp
|
|
|
2
2
|
import tomli_w
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def create_config(
|
|
5
|
+
def create_config(
|
|
6
|
+
name: str, password: str, domain: str = "dev.bovine.social"
|
|
7
|
+
) -> dict[str, bool | str]:
|
|
6
8
|
"""
|
|
7
9
|
|
|
8
10
|
```
|
|
@@ -21,7 +23,7 @@ def create_config(name, password, domain="dev.bovine.social"):
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
async def register(config_file, name, password, fediverse):
|
|
26
|
+
async def register(config_file: str, name: str, password: str, fediverse: str):
|
|
25
27
|
async with aiohttp.ClientSession() as session:
|
|
26
28
|
result = await session.post(
|
|
27
29
|
"https://dev.bovine.social/register",
|
roboherd/util.py
CHANGED
|
@@ -8,7 +8,7 @@ from almabtrieb import Almabtrieb
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def parse_connection_string(connection_string: str) -> dict:
|
|
11
|
+
def parse_connection_string(connection_string: str) -> dict[str, str | int | None]:
|
|
12
12
|
"""
|
|
13
13
|
Parse a connection string into a dictionary of connection parameters.
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ def parse_connection_string(connection_string: str) -> dict:
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
def create_connection(ctx):
|
|
46
|
+
def create_connection(ctx: click.Context):
|
|
47
47
|
connection_string = ctx.obj["connection_string"]
|
|
48
48
|
base_url = ctx.obj["base_url"]
|
|
49
49
|
|
roboherd/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.11"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
roboherd/__init__.py,sha256=E89YtYyL77iJDJJkHS4Pn0JdTbmkmQS7Cp_XPqpRgx8,533
|
|
2
|
-
roboherd/__main__.py,sha256=
|
|
3
|
-
roboherd/register.py,sha256=
|
|
2
|
+
roboherd/__main__.py,sha256=Bix6QLAXXs9zh3G8UOPHbq33QDhOCn4bNB7P0z1_9N0,3979
|
|
3
|
+
roboherd/register.py,sha256=jnnHv-epeyXHcmmulxJoHqT7uWmb_efFnCbdxojKOBM,1044
|
|
4
4
|
roboherd/test_validators.py,sha256=UiFgJkutmXBLjGpdLP2IBYCEf75quwnRHX7Z51G8Xqo,222
|
|
5
|
-
roboherd/util.py,sha256=
|
|
5
|
+
roboherd/util.py,sha256=gG8Scht1xRfauUOdL7GrLf9e3UO-j88X2wEdc1Ymm3o,1748
|
|
6
6
|
roboherd/validators.py,sha256=2mc43ZGwFazp4f3B9J4RxZCU4Y_ErSNotib8MnYVtmY,140
|
|
7
|
+
roboherd/version.py,sha256=nllDrH0jyChMuuYrK0CC55iTBKUNTUjejtcwxyUF2EQ,23
|
|
7
8
|
roboherd/annotations/__init__.py,sha256=BrP5UWiVnh8FwmHc6wEY3G69BStidGUpF8uP4Ea5-dg,1140
|
|
8
9
|
roboherd/annotations/bovine.py,sha256=cFLUSFzTulikNjZb1lLq5v4tGjL1i7_dR3H6wimegCg,2322
|
|
9
10
|
roboherd/annotations/common.py,sha256=n5rm8WTgsg116RczKdzm_VoPg1mBk_IMf2V7l8UgWKQ,1351
|
|
@@ -25,20 +26,20 @@ roboherd/examples/moocow.py,sha256=2bZ8oZOpysuf7l3DP3zM4YiaALQHFbWpbP3h_Xlok6E,9
|
|
|
25
26
|
roboherd/examples/number.py,sha256=c4zALxrKR5POuAUTmzAF4wHVgXMPfrP736N7dgn4xzo,1845
|
|
26
27
|
roboherd/examples/rooster.py,sha256=ItPBpxhz72agkzFf13nv6csYVUJCZRabtUaGyKwUKRg,501
|
|
27
28
|
roboherd/examples/scarecrow.py,sha256=jUnBaDJ2w9LQNIJAAfA53oJyRvKPJoKHtvHbeW-Pex0,626
|
|
28
|
-
roboherd/herd/__init__.py,sha256=
|
|
29
|
+
roboherd/herd/__init__.py,sha256=_JC0GK1sXSeY5nIwZ9Sd7XWuG6ZteHRcK3N8q5Awt3k,3825
|
|
29
30
|
roboherd/herd/builder.py,sha256=MSVPRF0Jsxure9kdyCoYJHQ7nYilGAD0_uQaGQ-rQyE,619
|
|
30
31
|
roboherd/herd/processor.py,sha256=4wZUp4xND9ZhxLIedUN7Yu3jxKWuuFqJent7wRiaAE0,1153
|
|
31
32
|
roboherd/herd/scheduler.py,sha256=4zAPJkWs1ZGHlwTweHdhYb5xrHnpiSTpTEQ64drA-oE,1735
|
|
32
|
-
roboherd/herd/test_herd.py,sha256=
|
|
33
|
+
roboherd/herd/test_herd.py,sha256=9Gf_Yh2a58EsSq3KYbR6IJBqM9JOueO6unzPwe-ciJ4,868
|
|
33
34
|
roboherd/herd/test_scheduler.py,sha256=wLisqRMSl734P_rjbqMNH5WTQKepwihgr7ZC32nEj80,424
|
|
34
35
|
roboherd/herd/types.py,sha256=_EidQbglm0jpsKX1EsL6U2qm_J5wCPhwUi6Avac22Ow,210
|
|
35
|
-
roboherd/herd/manager/__init__.py,sha256=
|
|
36
|
+
roboherd/herd/manager/__init__.py,sha256=7GcH0AZwLjNX7kLK-CXTvnaM3ZMWdstlTEqAY3IstZA,1440
|
|
36
37
|
roboherd/herd/manager/config.py,sha256=8m-313_wn_-b4ivPSoPyyTQh0ONNLcd-Zz3pgWh8p1c,2429
|
|
37
38
|
roboherd/herd/manager/load.py,sha256=BoeBID2UGP--sIKwITABQkQv2lMc9Y8pyp7_nleu2bw,351
|
|
38
39
|
roboherd/herd/manager/test_config.py,sha256=I2EP7nEUdBVO8Wqot7SRhzp5UZFr5oGIuFS7cNB2iFk,1745
|
|
39
40
|
roboherd/herd/manager/test_load.py,sha256=zyu5LIChMfTnxu_tYK63-bSOHYn1K1zUlbDY5DkE3GY,514
|
|
40
41
|
roboherd/herd/manager/test_manager.py,sha256=9pSMaH7zmN-zagYCIBpQcV3Q0sBT7XZSCvsmLVC0rOI,1047
|
|
41
|
-
roboherd-0.1.
|
|
42
|
-
roboherd-0.1.
|
|
43
|
-
roboherd-0.1.
|
|
44
|
-
roboherd-0.1.
|
|
42
|
+
roboherd-0.1.11.dist-info/METADATA,sha256=7l6P2qnsbNozntECa2Otgggvx9TeMV_l5dmhpap8iIY,2206
|
|
43
|
+
roboherd-0.1.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
44
|
+
roboherd-0.1.11.dist-info/entry_points.txt,sha256=WebdVUmh8Ot-FupKJY6Du8LuFbmezt9yoy2UICqV3bE,52
|
|
45
|
+
roboherd-0.1.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|