Skip to content

Commit 7c13ed7

Browse files
committed
Add temporary directory to verbose output
1 parent 14072d6 commit 7c13ed7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lean/click.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from lean.models.logger import Option
2424
from lean.models.errors import AuthenticationError
2525

26+
import tempfile
27+
2628

2729
def get_whoami_message() -> str:
2830
"""
@@ -59,6 +61,28 @@ def get_whoami_message() -> str:
5961

6062
return f"logged in as {member.name} ({member.email})"
6163

64+
def get_disk_space_info(path: Path) -> str:
65+
import os
66+
try:
67+
if os.name == 'posix': # macOS y Linux
68+
stat = os.statvfs(path)
69+
total = stat.f_blocks * stat.f_frsize
70+
free = stat.f_bfree * stat.f_frsize
71+
used = total - free
72+
else: # Windows
73+
import shutil
74+
usage = shutil.disk_usage(path)
75+
total, used, free = usage.total, usage.used, usage.free
76+
77+
return (
78+
f"Space in temporary location - "
79+
f"Total: {total / (1024 ** 3):.2f} GB, "
80+
f"Used: {used / (1024 ** 3):.2f} GB, "
81+
f"Free: {free / (1024 ** 3):.2f} GB"
82+
)
83+
except Exception as e:
84+
return f"Error getting disk space: {str(e)}"
85+
6286
class VerboseOption(ClickOption):
6387
def __init__(self, *args, **kwargs):
6488
super().__init__(["--verbose"],
@@ -131,11 +155,21 @@ def _parse_verbose_option(ctx: Context, param: Parameter, value: Optional[bool])
131155
except:
132156
docker_version = "Not installed"
133157

158+
try:
159+
temp_dir = Path(tempfile.gettempdir()).resolve() # Resuelve symlinks (común en macOS)
160+
space_info = get_disk_space_info(temp_dir)
161+
except:
162+
temp_dir = ""
163+
space_info = ""
164+
165+
134166
logger.debug(f"Context information:\n" +
135167
hostname +
136168
username +
137169
f" Python version: {python_version}\n"
138170
f" OS: {platform()}\n"
171+
f" Temporary directory: {temp_dir}\n"
172+
f" {space_info}\n"
139173
f" Lean CLI version: {lean_cli_version}\n"
140174
f" .NET version: {dotnet_version}\n"
141175
f" VS Code version: {vscode_version}\n"

0 commit comments

Comments
 (0)