|
23 | 23 | from lean.models.logger import Option
|
24 | 24 | from lean.models.errors import AuthenticationError
|
25 | 25 |
|
| 26 | +import tempfile |
| 27 | + |
26 | 28 |
|
27 | 29 | def get_whoami_message() -> str:
|
28 | 30 | """
|
@@ -59,6 +61,28 @@ def get_whoami_message() -> str:
|
59 | 61 |
|
60 | 62 | return f"logged in as {member.name} ({member.email})"
|
61 | 63 |
|
| 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 | + |
62 | 86 | class VerboseOption(ClickOption):
|
63 | 87 | def __init__(self, *args, **kwargs):
|
64 | 88 | super().__init__(["--verbose"],
|
@@ -131,11 +155,21 @@ def _parse_verbose_option(ctx: Context, param: Parameter, value: Optional[bool])
|
131 | 155 | except:
|
132 | 156 | docker_version = "Not installed"
|
133 | 157 |
|
| 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 | + |
134 | 166 | logger.debug(f"Context information:\n" +
|
135 | 167 | hostname +
|
136 | 168 | username +
|
137 | 169 | f" Python version: {python_version}\n"
|
138 | 170 | f" OS: {platform()}\n"
|
| 171 | + f" Temporary directory: {temp_dir}\n" |
| 172 | + f" {space_info}\n" |
139 | 173 | f" Lean CLI version: {lean_cli_version}\n"
|
140 | 174 | f" .NET version: {dotnet_version}\n"
|
141 | 175 | f" VS Code version: {vscode_version}\n"
|
|
0 commit comments