mdify-cli 2.10.1__py3-none-any.whl → 2.11.1__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.
- mdify/__init__.py +1 -1
- mdify/cli.py +42 -13
- mdify/container.py +46 -0
- {mdify_cli-2.10.1.dist-info → mdify_cli-2.11.1.dist-info}/METADATA +1 -1
- mdify_cli-2.11.1.dist-info/RECORD +12 -0
- mdify_cli-2.10.1.dist-info/RECORD +0 -12
- {mdify_cli-2.10.1.dist-info → mdify_cli-2.11.1.dist-info}/WHEEL +0 -0
- {mdify_cli-2.10.1.dist-info → mdify_cli-2.11.1.dist-info}/entry_points.txt +0 -0
- {mdify_cli-2.10.1.dist-info → mdify_cli-2.11.1.dist-info}/licenses/LICENSE +0 -0
- {mdify_cli-2.10.1.dist-info → mdify_cli-2.11.1.dist-info}/top_level.txt +0 -0
mdify/__init__.py
CHANGED
mdify/cli.py
CHANGED
|
@@ -38,6 +38,9 @@ SUPPORTED_RUNTIMES = ("docker", "podman", "orbstack", "colima", "container")
|
|
|
38
38
|
MACOS_RUNTIMES_PRIORITY = ("container", "orbstack", "colima", "podman", "docker")
|
|
39
39
|
OTHER_RUNTIMES_PRIORITY = ("docker", "podman")
|
|
40
40
|
|
|
41
|
+
# Debug mode
|
|
42
|
+
DEBUG = os.environ.get("MDIFY_DEBUG", "").lower() in ("1", "true", "yes")
|
|
43
|
+
|
|
41
44
|
|
|
42
45
|
# =============================================================================
|
|
43
46
|
# Update checking functions
|
|
@@ -983,6 +986,9 @@ def main() -> int:
|
|
|
983
986
|
start_time = time.time()
|
|
984
987
|
try:
|
|
985
988
|
# Convert via HTTP API
|
|
989
|
+
if DEBUG:
|
|
990
|
+
print(f" DEBUG: Converting {input_file.name} via {container.base_url}/v1/convert/file", file=sys.stderr)
|
|
991
|
+
|
|
986
992
|
result = convert_file(
|
|
987
993
|
container.base_url, input_file, to_format="md"
|
|
988
994
|
)
|
|
@@ -1017,21 +1023,44 @@ def main() -> int:
|
|
|
1017
1023
|
|
|
1018
1024
|
# Check if container is still healthy
|
|
1019
1025
|
error_msg = str(e)
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1026
|
+
is_connection_error = "Connection refused" in error_msg or "Connection aborted" in error_msg or "RemoteDisconnected" in error_msg
|
|
1027
|
+
|
|
1028
|
+
if is_connection_error:
|
|
1029
|
+
container_alive = container.is_ready()
|
|
1030
|
+
if not args.quiet:
|
|
1031
|
+
print(
|
|
1032
|
+
f"{progress} {input_file.name} ✗ ({format_duration(elapsed)})"
|
|
1033
|
+
)
|
|
1034
|
+
if container_alive:
|
|
1035
|
+
print(f" Error: Connection lost (container may be restarting or overloaded)", file=sys.stderr)
|
|
1036
|
+
else:
|
|
1037
|
+
print(f" Error: Container crashed while processing file", file=sys.stderr)
|
|
1038
|
+
print(f" File may be too complex, large, or malformed", file=sys.stderr)
|
|
1039
|
+
|
|
1040
|
+
# Show logs for debugging (whether container is alive or not)
|
|
1041
|
+
if DEBUG or not container_alive:
|
|
1042
|
+
print(f" Retrieving container logs...", file=sys.stderr)
|
|
1043
|
+
logs = container.get_logs(tail=30)
|
|
1044
|
+
if logs:
|
|
1045
|
+
print(f" Container logs (last 30 lines):", file=sys.stderr)
|
|
1046
|
+
for line in logs.strip().split('\n'):
|
|
1047
|
+
print(f" {line}", file=sys.stderr)
|
|
1048
|
+
else:
|
|
1049
|
+
print(f" No logs available", file=sys.stderr)
|
|
1050
|
+
|
|
1051
|
+
if not container_alive:
|
|
1027
1052
|
print(f" Stopping remaining conversions", file=sys.stderr)
|
|
1053
|
+
|
|
1054
|
+
# Stop processing if container is dead
|
|
1055
|
+
if not container_alive:
|
|
1028
1056
|
break
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1057
|
+
else:
|
|
1058
|
+
# Non-connection error
|
|
1059
|
+
if not args.quiet:
|
|
1060
|
+
print(
|
|
1061
|
+
f"{progress} {input_file.name} ✗ ({format_duration(elapsed)})"
|
|
1062
|
+
)
|
|
1063
|
+
print(f" Error: {error_msg}", file=sys.stderr)
|
|
1035
1064
|
|
|
1036
1065
|
total_elapsed = time.time() - conversion_start
|
|
1037
1066
|
|
mdify/container.py
CHANGED
|
@@ -125,6 +125,48 @@ class DoclingContainer:
|
|
|
125
125
|
check=False,
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
+
def get_logs(self, tail: int = 50) -> str:
|
|
129
|
+
"""Get container logs for debugging.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
tail: Number of lines to retrieve from end of logs
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Container logs as string
|
|
136
|
+
"""
|
|
137
|
+
if not self.container_name:
|
|
138
|
+
return ""
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
result = subprocess.run(
|
|
142
|
+
[self.runtime, "logs", "--tail", str(tail), self.container_name],
|
|
143
|
+
capture_output=True,
|
|
144
|
+
text=True,
|
|
145
|
+
check=False,
|
|
146
|
+
)
|
|
147
|
+
return result.stdout if result.returncode == 0 else ""
|
|
148
|
+
except Exception:
|
|
149
|
+
return ""
|
|
150
|
+
|
|
151
|
+
def is_running(self) -> bool:
|
|
152
|
+
"""Check if container process is still running.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
True if container is running, False otherwise
|
|
156
|
+
"""
|
|
157
|
+
if not self.container_name:
|
|
158
|
+
return False
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
result = subprocess.run(
|
|
162
|
+
[self.runtime, "ps", "-q", "-f", f"name={self.container_name}"],
|
|
163
|
+
capture_output=True,
|
|
164
|
+
check=False,
|
|
165
|
+
)
|
|
166
|
+
return result.returncode == 0 and bool(result.stdout.strip())
|
|
167
|
+
except Exception:
|
|
168
|
+
return False
|
|
169
|
+
|
|
128
170
|
def is_ready(self) -> bool:
|
|
129
171
|
"""Check if container is healthy.
|
|
130
172
|
|
|
@@ -132,6 +174,10 @@ class DoclingContainer:
|
|
|
132
174
|
True if container is healthy, False otherwise
|
|
133
175
|
"""
|
|
134
176
|
try:
|
|
177
|
+
# First check if container is still running
|
|
178
|
+
if not self.is_running():
|
|
179
|
+
return False
|
|
180
|
+
# Then check health endpoint
|
|
135
181
|
return check_health(self.base_url)
|
|
136
182
|
except Exception:
|
|
137
183
|
return False
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
assets/mdify.png,sha256=qUj7WXWqNwpI2KNXOW79XJwqFqa-UI0JEkmt1mmy4Rg,1820418
|
|
2
|
+
mdify/__init__.py,sha256=RVkAMYdoP74oQx7cL4Tm3Tq1JIbOIa3o41jzrH00ZOU,91
|
|
3
|
+
mdify/__main__.py,sha256=bhpJ00co6MfaVOdH4XLoW04NtLYDa_oJK7ODzfLrn9M,143
|
|
4
|
+
mdify/cli.py,sha256=MYTR8Vpu7p88Hf2KOyINGYlVq4dyUiQ094On-0XOkmA,36780
|
|
5
|
+
mdify/container.py,sha256=JoN8mUE1hIIVnrxZwdHud70vgNo_1ZIJtmNoPwBWk8I,6647
|
|
6
|
+
mdify/docling_client.py,sha256=xuQR6sC1v3EPloOSwExoHCqT4uUxE8myYq-Yeby3C2I,7975
|
|
7
|
+
mdify_cli-2.11.1.dist-info/licenses/LICENSE,sha256=NWM66Uv-XuSMKaU-gaPmvfyk4WgE6zcIPr78wyg6GAo,1065
|
|
8
|
+
mdify_cli-2.11.1.dist-info/METADATA,sha256=CRZHevY6HxWmqppUMq3UuSC92sYtPOm5sKnCJDPwrMU,9623
|
|
9
|
+
mdify_cli-2.11.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
mdify_cli-2.11.1.dist-info/entry_points.txt,sha256=0Xki8f5lADQUtwdt6Eq_FEaieI6Byhk8UE7BuDhChMg,41
|
|
11
|
+
mdify_cli-2.11.1.dist-info/top_level.txt,sha256=qltzf7h8owHq7dxCdfCkSHY8gT21hn1_E8P-VWS_OKM,6
|
|
12
|
+
mdify_cli-2.11.1.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
assets/mdify.png,sha256=qUj7WXWqNwpI2KNXOW79XJwqFqa-UI0JEkmt1mmy4Rg,1820418
|
|
2
|
-
mdify/__init__.py,sha256=c9HHXZfZwsYFSH08YfXMEClMKzbm9NIlShXjHP9tNsI,91
|
|
3
|
-
mdify/__main__.py,sha256=bhpJ00co6MfaVOdH4XLoW04NtLYDa_oJK7ODzfLrn9M,143
|
|
4
|
-
mdify/cli.py,sha256=NvOOhJ1uYwRkUHKIMt5vntHUEHqj96St5pH470GyaiE,35080
|
|
5
|
-
mdify/container.py,sha256=tkk0nv7EquL-rKUY4nkS_yGITb7mqw8B7eEfuqaeVrg,5239
|
|
6
|
-
mdify/docling_client.py,sha256=xuQR6sC1v3EPloOSwExoHCqT4uUxE8myYq-Yeby3C2I,7975
|
|
7
|
-
mdify_cli-2.10.1.dist-info/licenses/LICENSE,sha256=NWM66Uv-XuSMKaU-gaPmvfyk4WgE6zcIPr78wyg6GAo,1065
|
|
8
|
-
mdify_cli-2.10.1.dist-info/METADATA,sha256=vYWbynUKYVsRc1Wdx_vatsN0M53zkMfC0z9KzmlGLhg,9623
|
|
9
|
-
mdify_cli-2.10.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
-
mdify_cli-2.10.1.dist-info/entry_points.txt,sha256=0Xki8f5lADQUtwdt6Eq_FEaieI6Byhk8UE7BuDhChMg,41
|
|
11
|
-
mdify_cli-2.10.1.dist-info/top_level.txt,sha256=qltzf7h8owHq7dxCdfCkSHY8gT21hn1_E8P-VWS_OKM,6
|
|
12
|
-
mdify_cli-2.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|