Skip to content

Commit 4ca0f62

Browse files
committed
fix: run/debug redirect stdout to file
1 parent 889500d commit 4ca0f62

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath"
3-
version = "2.2.26"
3+
version = "2.2.27"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-runtime>=0.2.3, <0.3.0",
8+
"uipath-runtime==0.2.4.dev1000460151",
99
"uipath-core>=0.1.0, <0.2.0",
1010
"click>=8.3.1",
1111
"httpx>=0.28.1",
@@ -139,8 +139,12 @@ show_missing = true
139139
[tool.coverage.run]
140140
source = ["src"]
141141

142+
142143
[[tool.uv.index]]
143144
name = "testpypi"
144145
url = "https://test.pypi.org/simple/"
145146
publish-url = "https://test.pypi.org/legacy/"
146147
explicit = true
148+
149+
[tool.uv.sources]
150+
uipath-runtime = { index = "testpypi" }

src/uipath/_cli/_debug/_bridge.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import signal
6+
import sys
67
from concurrent.futures import ThreadPoolExecutor
78
from enum import Enum
89
from typing import Any, Literal
@@ -75,6 +76,7 @@ def __init__(self, verbose: bool = True):
7576
verbose: If True, show state updates. If False, only show breakpoints.
7677
"""
7778
self.console = Console(force_terminal=True)
79+
self.is_terminal = sys.stdout.isatty()
7880
self.verbose = verbose
7981
self.state = DebuggerState()
8082

@@ -372,6 +374,20 @@ def _print_help(self) -> None:
372374

373375
def _print_json(self, data: dict[str, Any] | str, label: str = "data") -> None:
374376
"""Print JSON data with enhanced hierarchy."""
377+
# Check if output is being redirected
378+
if not self.is_terminal:
379+
# Plain text output for file redirection
380+
try:
381+
json_str = json.dumps(data, indent=2, default=str)
382+
print(f"\n{label}:")
383+
print(json_str)
384+
print()
385+
except Exception:
386+
print(f"\n{label}:")
387+
print(str(data))
388+
print()
389+
return
390+
375391
try:
376392
# Create a tree for nested structure
377393
tree = Tree(f"[bold cyan]{label}[/bold cyan]")

src/uipath/_cli/_utils/_console.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sys
34
from contextlib import contextmanager
45
from enum import Enum
56
from typing import Any, Iterator, Type
@@ -83,6 +84,13 @@ def log(
8384
level: The log level (determines the emoji)
8485
fg: Optional foreground color for the message
8586
"""
87+
# Check if stdout is closed or broken
88+
try:
89+
if sys.stdout.closed:
90+
return
91+
except (AttributeError, ValueError, OSError):
92+
return
93+
8694
# Stop any active spinner before logging
8795
self._stop_spinner_if_active()
8896

uv.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)