mdify-cli 3.0.4__tar.gz → 3.0.5__tar.gz

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.
Files changed (27) hide show
  1. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/PKG-INFO +1 -1
  2. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/__init__.py +1 -1
  3. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/ssh/remote_container.py +41 -4
  4. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/PKG-INFO +1 -1
  5. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/pyproject.toml +1 -1
  6. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/LICENSE +0 -0
  7. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/README.md +0 -0
  8. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/assets/mdify.png +0 -0
  9. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/__main__.py +0 -0
  10. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/cli.py +0 -0
  11. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/container.py +0 -0
  12. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/docling_client.py +0 -0
  13. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/formatting.py +0 -0
  14. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/ssh/__init__.py +0 -0
  15. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/ssh/client.py +0 -0
  16. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/ssh/models.py +0 -0
  17. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify/ssh/transfer.py +0 -0
  18. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/SOURCES.txt +0 -0
  19. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/dependency_links.txt +0 -0
  20. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/entry_points.txt +0 -0
  21. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/requires.txt +0 -0
  22. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/mdify_cli.egg-info/top_level.txt +0 -0
  23. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/setup.cfg +0 -0
  24. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/tests/test_cli.py +0 -0
  25. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/tests/test_container.py +0 -0
  26. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/tests/test_docling_client.py +0 -0
  27. {mdify_cli-3.0.4 → mdify_cli-3.0.5}/tests/test_ssh_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdify-cli
3
- Version: 3.0.4
3
+ Version: 3.0.5
4
4
  Summary: Convert PDFs and document images into structured Markdown for LLM workflows
5
5
  Author: tiroq
6
6
  License-Expression: MIT
@@ -1,3 +1,3 @@
1
1
  """mdify - Convert documents to Markdown via Docling container."""
2
2
 
3
- __version__ = "3.0.4"
3
+ __version__ = "3.0.5"
@@ -54,14 +54,48 @@ class RemoteContainer(DoclingContainer):
54
54
  )
55
55
  self.is_healthy = False
56
56
 
57
+ async def _cleanup_port(self) -> None:
58
+ """Clean up any existing containers using this port.
59
+
60
+ Attempts to find and stop containers that are bound to self.port.
61
+ This handles the case where a previous container wasn't properly cleaned up.
62
+ """
63
+ try:
64
+ # Find containers using this port
65
+ # Using docker inspect with port filter
66
+ cmd = f"{self.runtime} ps -a --filter 'publish={self.port}' --format '{{{{.ID}}}}'"
67
+ stdout, stderr, code = await self.ssh_client.run_command(cmd, timeout=10)
68
+
69
+ if code == 0 and stdout.strip():
70
+ container_ids = stdout.strip().split('\n')
71
+ for container_id in container_ids:
72
+ container_id = container_id.strip()
73
+ if not container_id:
74
+ continue
75
+
76
+ logger.info(f"Cleaning up existing container on port {self.port}: {container_id}")
77
+
78
+ # Stop the container
79
+ stop_cmd = f"{self.runtime} stop {container_id}"
80
+ await self.ssh_client.run_command(stop_cmd, timeout=10)
81
+
82
+ # Remove the container
83
+ rm_cmd = f"{self.runtime} rm {container_id}"
84
+ await self.ssh_client.run_command(rm_cmd, timeout=10)
85
+
86
+ logger.debug(f"Container removed: {container_id}")
87
+ except Exception as e:
88
+ logger.debug(f"Port cleanup check failed (non-blocking): {e}")
89
+
57
90
  async def start(self) -> None:
58
91
  """Start container on remote server.
59
92
 
60
93
  Operations:
61
- 1. Detect container runtime on remote
62
- 2. Run docker/podman run command
63
- 3. Extract container ID
64
- 4. Wait for health check
94
+ 1. Clean up any existing containers using this port
95
+ 2. Detect container runtime on remote
96
+ 3. Run docker/podman run command
97
+ 4. Extract container ID
98
+ 5. Wait for health check
65
99
 
66
100
  Raises:
67
101
  RuntimeError: Container already running or start failed
@@ -72,6 +106,9 @@ class RemoteContainer(DoclingContainer):
72
106
 
73
107
  logger.info(f"Starting remote container: {self.name}")
74
108
 
109
+ # Clean up any existing containers on this port
110
+ await self._cleanup_port()
111
+
75
112
  try:
76
113
  # Detect runtime if needed
77
114
  if not self.runtime:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdify-cli
3
- Version: 3.0.4
3
+ Version: 3.0.5
4
4
  Summary: Convert PDFs and document images into structured Markdown for LLM workflows
5
5
  Author: tiroq
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mdify-cli"
3
- version = "3.0.4"
3
+ version = "3.0.5"
4
4
  description = "Convert PDFs and document images into structured Markdown for LLM workflows"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes