zenx 0.9.2__tar.gz → 0.9.3__tar.gz
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.
- {zenx-0.9.2 → zenx-0.9.3}/PKG-INFO +2 -1
- {zenx-0.9.2 → zenx-0.9.3}/pyproject.toml +2 -1
- zenx-0.9.3/zenx/pipelines/discord.py +45 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/settings.py +2 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/spiders/base.py +1 -1
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/PKG-INFO +2 -1
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/SOURCES.txt +1 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/requires.txt +1 -0
- {zenx-0.9.2 → zenx-0.9.3}/setup.cfg +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/cli.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/__init__.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/database.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/http.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/debug_runner.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/discovery.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/engine.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/exceptions.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/logger.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/__init__.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/base.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/google_rpc.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/manager.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/preprocess.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/websocket.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/__init__.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/feed_pb2.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/feed_pb2_grpc.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/spiders/__init__.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx/utils.py +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/dependency_links.txt +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/entry_points.txt +0 -0
- {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/top_level.txt +0 -0
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: zenx
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.3
|
4
4
|
Summary: mini-framework
|
5
5
|
Requires-Python: >=3.12
|
6
6
|
Requires-Dist: curl-cffi>=0.12.0
|
7
|
+
Requires-Dist: httpx>=0.28.1
|
7
8
|
Requires-Dist: parsel>=1.10.0
|
8
9
|
Requires-Dist: pebble>=5.1.1
|
9
10
|
Requires-Dist: pydantic>=2.11.7
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from httpx import AsyncClient
|
2
|
+
from typing import Dict
|
3
|
+
from structlog import BoundLogger
|
4
|
+
|
5
|
+
from zenx.pipelines.base import Pipeline
|
6
|
+
from zenx.clients.database import DBClient
|
7
|
+
from zenx.settings import Settings
|
8
|
+
from zenx.utils import log_processing_time
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
class SynopticDiscordPipeline(Pipeline):
|
13
|
+
name = "syncoptic_discord"
|
14
|
+
required_settings = ["SYNOPTIC_DISCORD_WEBHOOK"]
|
15
|
+
|
16
|
+
|
17
|
+
def __init__(self, logger: BoundLogger, db: DBClient, settings: Settings) -> None:
|
18
|
+
super().__init__(logger, db, settings)
|
19
|
+
self._uri = settings.SYNOPTIC_DISCORD_WEBHOOK
|
20
|
+
self._client = AsyncClient(headers={"Content-Type": "application/json"})
|
21
|
+
|
22
|
+
|
23
|
+
async def start(self) -> None:
|
24
|
+
for setting in self.required_settings:
|
25
|
+
if not getattr(self.settings, setting):
|
26
|
+
raise ValueError(f"Missing required setting: {setting}")
|
27
|
+
|
28
|
+
|
29
|
+
@log_processing_time
|
30
|
+
async def process_item(self, item: Dict, spider: str) -> Dict:
|
31
|
+
await self._process(item)
|
32
|
+
return item
|
33
|
+
|
34
|
+
|
35
|
+
async def _process(self, item: Dict) -> None:
|
36
|
+
try:
|
37
|
+
_item = {k: v for k, v in item.items() if not k.startswith("_")}
|
38
|
+
await self._client.post(self._uri, json=_item)
|
39
|
+
except Exception as e:
|
40
|
+
self.logger.error("processing", exception=str(e), id=item.get("_id"), pipeline=self.name)
|
41
|
+
|
42
|
+
|
43
|
+
async def close(self) -> None:
|
44
|
+
if hasattr(self, "_client") and self._client:
|
45
|
+
await self._client.aclose()
|
@@ -14,7 +14,7 @@ class Spider(ABC):
|
|
14
14
|
# central registry
|
15
15
|
name: ClassVar[str]
|
16
16
|
_registry: ClassVar[Dict[str, Type[Spider]]] = {}
|
17
|
-
pipelines: ClassVar[List[Literal["preprocess","synoptic_websocket","synoptic_grpc"]]]
|
17
|
+
pipelines: ClassVar[List[Literal["preprocess","synoptic_websocket","synoptic_grpc","synoptic_discord"]]]
|
18
18
|
client_name: ClassVar[Literal["curl_cffi"]] = "curl_cffi"
|
19
19
|
|
20
20
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: zenx
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.3
|
4
4
|
Summary: mini-framework
|
5
5
|
Requires-Python: >=3.12
|
6
6
|
Requires-Dist: curl-cffi>=0.12.0
|
7
|
+
Requires-Dist: httpx>=0.28.1
|
7
8
|
Requires-Dist: parsel>=1.10.0
|
8
9
|
Requires-Dist: pebble>=5.1.1
|
9
10
|
Requires-Dist: pydantic>=2.11.7
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|