pybgpkitstream 0.1.4__py3-none-any.whl → 0.1.6__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.
- pybgpkitstream/bgpkitstream.py +14 -4
- pybgpkitstream/bgpstreamconfig.py +11 -1
- {pybgpkitstream-0.1.4.dist-info → pybgpkitstream-0.1.6.dist-info}/METADATA +1 -1
- pybgpkitstream-0.1.6.dist-info/RECORD +10 -0
- pybgpkitstream-0.1.4.dist-info/RECORD +0 -10
- {pybgpkitstream-0.1.4.dist-info → pybgpkitstream-0.1.6.dist-info}/WHEEL +0 -0
- {pybgpkitstream-0.1.4.dist-info → pybgpkitstream-0.1.6.dist-info}/entry_points.txt +0 -0
pybgpkitstream/bgpkitstream.py
CHANGED
|
@@ -56,6 +56,15 @@ class Directory:
|
|
|
56
56
|
pass
|
|
57
57
|
|
|
58
58
|
|
|
59
|
+
def get_shared_memory():
|
|
60
|
+
"""Get a RAM-based temp path if available, otherwise fall back to default."""
|
|
61
|
+
if os.path.exists("/dev/shm"): # Linux tmpfs
|
|
62
|
+
return "/dev/shm"
|
|
63
|
+
elif os.path.exists("/Volumes/RAMDisk"): # macOS (if mounted)
|
|
64
|
+
return "/Volumes/RAMDisk"
|
|
65
|
+
return None # Fall back to default temp directory
|
|
66
|
+
|
|
67
|
+
|
|
59
68
|
class BGPKITStream:
|
|
60
69
|
def __init__(
|
|
61
70
|
self,
|
|
@@ -73,7 +82,9 @@ class BGPKITStream:
|
|
|
73
82
|
self.collector_id = collector_id
|
|
74
83
|
self.data_type = data_type
|
|
75
84
|
self.cache_dir: Directory | TemporaryDirectory = (
|
|
76
|
-
Directory(cache_dir)
|
|
85
|
+
Directory(cache_dir)
|
|
86
|
+
if cache_dir
|
|
87
|
+
else TemporaryDirectory(dir=get_shared_memory())
|
|
77
88
|
)
|
|
78
89
|
self.filters = filters
|
|
79
90
|
self.max_concurrent_downloads = max_concurrent_downloads
|
|
@@ -116,9 +127,8 @@ class BGPKITStream:
|
|
|
116
127
|
self.urls = {"rib": defaultdict(list), "update": defaultdict(list)}
|
|
117
128
|
for data_type in self.data_type:
|
|
118
129
|
items: list[BrokerItem] = self.broker.query(
|
|
119
|
-
ts_start=
|
|
120
|
-
|
|
121
|
-
ts_end=datetime.datetime.fromtimestamp(self.ts_end),
|
|
130
|
+
ts_start=int(self.ts_start - 60),
|
|
131
|
+
ts_end=int(self.ts_end),
|
|
122
132
|
collector_id=self.collector_id,
|
|
123
133
|
data_type=data_type,
|
|
124
134
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
|
-
from pydantic import BaseModel, Field, DirectoryPath
|
|
2
|
+
from pydantic import BaseModel, Field, DirectoryPath, field_validator
|
|
3
3
|
from typing import Literal
|
|
4
4
|
from ipaddress import IPv4Address, IPv6Address
|
|
5
5
|
|
|
@@ -70,3 +70,13 @@ class BGPStreamConfig(BaseModel):
|
|
|
70
70
|
default=datetime.timedelta(hours=2),
|
|
71
71
|
description="Interval for the fetch/parse cycle (avoid long prefetch time)",
|
|
72
72
|
)
|
|
73
|
+
|
|
74
|
+
@field_validator("start_time", "end_time")
|
|
75
|
+
@classmethod
|
|
76
|
+
def normalize_to_utc(cls, dt: datetime.datetime) -> datetime.datetime:
|
|
77
|
+
# if naive datetime (not timezone-aware) assume it's UTC
|
|
78
|
+
if dt.tzinfo is None:
|
|
79
|
+
return dt.replace(tzinfo=datetime.timezone.utc)
|
|
80
|
+
# if timezone-aware, convert to utc
|
|
81
|
+
else:
|
|
82
|
+
return dt.astimezone(datetime.timezone.utc)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pybgpkitstream/__init__.py,sha256=kNfv6bvDkaGKjlw0pr9LWVqOQtIGmIPk-VG1ZCBuA38,163
|
|
2
|
+
pybgpkitstream/bgpelement.py,sha256=7mXSUmWThhIbKy2JVsLchoteve0BshT3uH8cdbAe0Go,1176
|
|
3
|
+
pybgpkitstream/bgpkitstream.py,sha256=VU79Olu1wk_GNBMxsCKCMjMfSU5YoKA9WsCf-4sOMBk,10997
|
|
4
|
+
pybgpkitstream/bgpstreamconfig.py,sha256=tFZEpqOoFMMNbyf6dzKHEtHZnEnm1Gv88hKy6BqTCq8,3299
|
|
5
|
+
pybgpkitstream/cli.py,sha256=E0E1hO0fzGhy1skBopRufdewsiSy_mA-J8Gf2WxBRxo,4214
|
|
6
|
+
pybgpkitstream/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
pybgpkitstream-0.1.6.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
8
|
+
pybgpkitstream-0.1.6.dist-info/entry_points.txt,sha256=aWhImGlXLtRKkfyJHudcbSp5K5As4ZGL8wXZC0y6q4o,60
|
|
9
|
+
pybgpkitstream-0.1.6.dist-info/METADATA,sha256=yKcQtzIS0JFXppGsnMVnQRlhVp82_u6Es8Q1fgPLFqQ,2953
|
|
10
|
+
pybgpkitstream-0.1.6.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
pybgpkitstream/__init__.py,sha256=kNfv6bvDkaGKjlw0pr9LWVqOQtIGmIPk-VG1ZCBuA38,163
|
|
2
|
-
pybgpkitstream/bgpelement.py,sha256=7mXSUmWThhIbKy2JVsLchoteve0BshT3uH8cdbAe0Go,1176
|
|
3
|
-
pybgpkitstream/bgpkitstream.py,sha256=n68cE4IPI1Lir0Zjkd8R0yPAjZg3GbbFZEEH7BbUIB4,10708
|
|
4
|
-
pybgpkitstream/bgpstreamconfig.py,sha256=_PHoNhq8lw4QzNKya-KQFQ24dEbTjTkmefFhx0t6K8Q,2873
|
|
5
|
-
pybgpkitstream/cli.py,sha256=E0E1hO0fzGhy1skBopRufdewsiSy_mA-J8Gf2WxBRxo,4214
|
|
6
|
-
pybgpkitstream/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
pybgpkitstream-0.1.4.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
8
|
-
pybgpkitstream-0.1.4.dist-info/entry_points.txt,sha256=aWhImGlXLtRKkfyJHudcbSp5K5As4ZGL8wXZC0y6q4o,60
|
|
9
|
-
pybgpkitstream-0.1.4.dist-info/METADATA,sha256=scEKSheKIwDh35g4AGgz5dD_ba1RSKlTEuG-vj5QXBY,2953
|
|
10
|
-
pybgpkitstream-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|