Skip to content

Commit f69b292

Browse files
author
Aviv Laufer
committed
protoconfloader 1st version
1 parent d4e7c5f commit f69b292

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

config.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"crawlers": [
3+
{
4+
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A525 Safari/8536.25",
5+
"httpTimeout": 30,
6+
"followRedirects": true
7+
},
8+
{
9+
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A525 Safari/8536.25",
10+
"httpTimeout": 60
11+
},
12+
{
13+
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A525 Safari/8536.25",
14+
"httpTimeout": 90
15+
},
16+
{
17+
"userAgent": "Linux/ time=1562845087",
18+
"httpTimeout": 30
19+
}
20+
],
21+
"logLevel": 5
22+
23+
}

protoconfloader/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .protoconfloader import Configuration

protoconfloader/protoconfloader.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import aiofiles
21
import asyncio
3-
import grpc
42
import json
53
import logging
64
import os
75
import pathlib
86
import sys
9-
from google.protobuf.any_pb2 import Any
10-
from google.protobuf.json_format import Parse
117
from typing import Any, Callable
8+
9+
import aiofiles
10+
import grpc
11+
from google.protobuf.json_format import Parse
1212
from watchdog.events import FileSystemEvent, FileSystemEventHandler
1313
from watchdog.observers import Observer
1414

@@ -167,11 +167,11 @@ async def watch_config(self, delay: int = 0) -> None:
167167
task1.result(),
168168
task2.result(),
169169
)
170-
except* asyncio.CancelledError:
170+
except asyncio.CancelledError:
171171
self.logger.info("Tasks were cancelled")
172-
except* Exception as e:
172+
except Exception as e:
173173
self.logger.error("Error in watch_config: %s", e)
174-
for exc in e.exceptions:
175-
self.logger.error("Sub-exception: %s", exc)
176-
self.logger.error("Traceback: ", exc_info=exc)
177-
exit(os.EX_UNAVAILABLE)
174+
# Removed the incorrect handling of exceptions as instances of Exception do not have an 'exceptions' member
175+
# Instead, directly log the exception and its traceback
176+
self.logger.error("Error traceback: ", exc_info=e)
177+
sys.exit(os.EX_UNAVAILABLE)

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ readme = "README.md"
77

88
[tool.poetry.dependencies]
99
python = "^3.11"
10-
inotify = "^0.2.10"
1110
grpclib = "^0.4.7"
1211
protobuf = "^5.27.1"
1312
asyncio = "^3.4.3"
13+
grpcio = "^1.65.5"
14+
grpcio-tools = "^1.65.5"
15+
watchdog = "^4.0.2"
16+
aiofiles = "^24.1.0"
1417

1518

1619
[tool.poetry.group.test.dependencies]
17-
pytest = "^8.2.2"
20+
pytest = "^8.3.2"
21+
pytest-asyncio = "^0.23.8"
22+
pytest-cov = "^5.0.0"
1823

1924
[build-system]
2025
requires = ["poetry-core"]

0 commit comments

Comments
 (0)