xenfra-sdk 0.1.7__py3-none-any.whl → 0.1.9__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.
xenfra_sdk/engine.py
CHANGED
|
@@ -324,7 +324,7 @@ class InfraEngine:
|
|
|
324
324
|
raise DeploymentError("Could not establish SSH connection.", stage="Polling")
|
|
325
325
|
|
|
326
326
|
with conn:
|
|
327
|
-
for i in range(
|
|
327
|
+
for i in range(120): # 20-minute timeout for cloud-init (installing Docker, Caddy, etc.)
|
|
328
328
|
if conn.run("test -f /root/setup_complete", warn=True).ok:
|
|
329
329
|
logger(" - Cloud-init setup complete.")
|
|
330
330
|
break
|
|
@@ -133,6 +133,7 @@ class DeploymentsManager(BaseManager):
|
|
|
133
133
|
try:
|
|
134
134
|
# Use httpx to stream the SSE response
|
|
135
135
|
import httpx
|
|
136
|
+
import os
|
|
136
137
|
|
|
137
138
|
headers = {
|
|
138
139
|
"Authorization": f"Bearer {self._client._token}",
|
|
@@ -140,7 +141,19 @@ class DeploymentsManager(BaseManager):
|
|
|
140
141
|
"Content-Type": "application/json",
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
# Use streaming API URL if available (bypasses Cloudflare timeout)
|
|
145
|
+
# Otherwise fall back to regular API URL
|
|
146
|
+
streaming_api_url = os.getenv("XENFRA_STREAMING_API_URL")
|
|
147
|
+
if streaming_api_url:
|
|
148
|
+
base_url = streaming_api_url
|
|
149
|
+
elif self._client.api_url == "https://api.xenfra.tech":
|
|
150
|
+
# Production: use non-proxied streaming subdomain
|
|
151
|
+
base_url = "https://stream.xenfra.tech"
|
|
152
|
+
else:
|
|
153
|
+
# Local/dev: use regular API URL
|
|
154
|
+
base_url = self._client.api_url
|
|
155
|
+
|
|
156
|
+
url = f"{base_url}/deployments/stream"
|
|
144
157
|
|
|
145
158
|
with httpx.stream(
|
|
146
159
|
"POST",
|
|
@@ -169,7 +182,13 @@ class DeploymentsManager(BaseManager):
|
|
|
169
182
|
)
|
|
170
183
|
|
|
171
184
|
# Parse SSE events
|
|
185
|
+
current_event = None # Initialize before loop
|
|
172
186
|
for line in response.iter_lines():
|
|
187
|
+
# No need to explicitly decode if iter_lines is used on a decoded response,
|
|
188
|
+
# but if it returns bytes, we decode it.
|
|
189
|
+
if isinstance(line, bytes):
|
|
190
|
+
line = line.decode('utf-8', errors='ignore')
|
|
191
|
+
|
|
173
192
|
line = line.strip()
|
|
174
193
|
if not line:
|
|
175
194
|
continue
|
|
@@ -179,17 +198,25 @@ class DeploymentsManager(BaseManager):
|
|
|
179
198
|
current_event = line[6:].strip()
|
|
180
199
|
elif line.startswith("data:"):
|
|
181
200
|
data = line[5:].strip()
|
|
201
|
+
|
|
202
|
+
# Get event type (default to "message" if no event line was sent)
|
|
203
|
+
event_type = current_event if current_event is not None else "message"
|
|
204
|
+
|
|
205
|
+
# Skip keep-alive events (used to prevent proxy timeouts)
|
|
206
|
+
if event_type == "keep-alive":
|
|
207
|
+
current_event = None
|
|
208
|
+
continue
|
|
209
|
+
|
|
182
210
|
try:
|
|
183
211
|
# Try to parse as JSON
|
|
184
212
|
data_parsed = json.loads(data)
|
|
185
|
-
yield {"event":
|
|
213
|
+
yield {"event": event_type, "data": data_parsed}
|
|
186
214
|
except json.JSONDecodeError:
|
|
187
215
|
# If not JSON, yield as plain text
|
|
188
|
-
yield {"event":
|
|
216
|
+
yield {"event": event_type, "data": data}
|
|
189
217
|
|
|
190
|
-
# Reset current_event
|
|
191
|
-
|
|
192
|
-
del current_event
|
|
218
|
+
# Reset current_event after yielding
|
|
219
|
+
current_event = None
|
|
193
220
|
|
|
194
221
|
except httpx.HTTPError as e:
|
|
195
222
|
raise XenfraError(f"HTTP error during streaming deployment: {e}")
|
|
@@ -9,7 +9,7 @@ xenfra_sdk/db/models.py,sha256=oNT9UhYzr_SgzDJdPu5fF6IiiztWjm2tHZzpIAYVJ4Y,706
|
|
|
9
9
|
xenfra_sdk/db/session.py,sha256=ul6tFBBDKU8UErJsZ-g7b8cryLr9-yA6jGY3d8fD15Q,853
|
|
10
10
|
xenfra_sdk/dependencies.py,sha256=k7tiy_5dayr_iQx_i2klGeNjGWhxfivGVC38SpvQvzE,1250
|
|
11
11
|
xenfra_sdk/dockerizer.py,sha256=hOXy6dKl3QGFamRN2WZ0rAh6Vguykhkdyal3grhGAOI,3146
|
|
12
|
-
xenfra_sdk/engine.py,sha256
|
|
12
|
+
xenfra_sdk/engine.py,sha256=K9HVqG37HcTbLFE4DeknNv00ADyKL68olYA7IudRJj8,17090
|
|
13
13
|
xenfra_sdk/exceptions.py,sha256=FaKctVJNMFIw09G8Lm2yd_DHhSngGcyh2j_BTgXMM60,496
|
|
14
14
|
xenfra_sdk/mcp_client.py,sha256=GPsVJtWT87G7k_GxePATLfCqFkYFFNIbpW5AsZi4Bhk,5931
|
|
15
15
|
xenfra_sdk/models.py,sha256=VDd41JxqyzrsNZugXe5IP9OKkNuGVRFSnoTrHBOSKjk,7185
|
|
@@ -18,7 +18,7 @@ xenfra_sdk/privacy.py,sha256=ksGf5L9PVtRP-xZS3T-Gj7MKfexTqIMgbFLoYkIESOE,5662
|
|
|
18
18
|
xenfra_sdk/recipes.py,sha256=g_UKQIcdSokYh7zn186mzDTr08P034-KZ1iiDNELyP4,877
|
|
19
19
|
xenfra_sdk/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
xenfra_sdk/resources/base.py,sha256=C6BuZfhR-oU5ecHSfkGG6ZLU6MHGXUyCWoy1F-yTIf8,84
|
|
21
|
-
xenfra_sdk/resources/deployments.py,sha256=
|
|
21
|
+
xenfra_sdk/resources/deployments.py,sha256=2GRF-BWwC8y-oM7Pje5YoHrlkKRduSWsC_3-erlw9V8,9174
|
|
22
22
|
xenfra_sdk/resources/intelligence.py,sha256=Y11K6_iXfm2QKTbH1vUmt45MifLoVtZtlHEkqbzmTzs,3418
|
|
23
23
|
xenfra_sdk/resources/projects.py,sha256=EsCVXmqkhWl_Guz_8WDQDi3kAm1Wyg1rjXcyAigPD6E,3712
|
|
24
24
|
xenfra_sdk/security.py,sha256=Px887RRb1BUDXaPUrxmQITJ1mHyOyupCJqEDZ78F7Tk,1240
|
|
@@ -26,6 +26,6 @@ xenfra_sdk/templates/Dockerfile.j2,sha256=GXc0JiaF-HsxTQS15Gs2fcvsIhA1EHnwapdFVi
|
|
|
26
26
|
xenfra_sdk/templates/cloud-init.sh.j2,sha256=NKIwtL9OgnlK2NnYRZI3gWC9aYl6wNPsS6r14g8eHQQ,2290
|
|
27
27
|
xenfra_sdk/templates/docker-compose.yml.j2,sha256=qMHiatuZlxiYZ1pE_g2ag1M798MvQbeq0cVTVK07jkM,893
|
|
28
28
|
xenfra_sdk/utils.py,sha256=d8eCjjV32QwqoJa759CEcETnnsjG5qVKDLQ84yYtlus,3898
|
|
29
|
-
xenfra_sdk-0.1.
|
|
30
|
-
xenfra_sdk-0.1.
|
|
31
|
-
xenfra_sdk-0.1.
|
|
29
|
+
xenfra_sdk-0.1.9.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
|
|
30
|
+
xenfra_sdk-0.1.9.dist-info/METADATA,sha256=PAeq0SV1LWdfLDH9Ey3PeVnrXT-7rs5uINdjAcqELbA,3980
|
|
31
|
+
xenfra_sdk-0.1.9.dist-info/RECORD,,
|
|
File without changes
|