running-process
Advanced tools
+1
-1
| Metadata-Version: 2.4 | ||
| Name: running_process | ||
| Version: 1.0.7 | ||
| Version: 1.1.0 | ||
| Summary: A modern subprocess.Popen wrapper with improved process management | ||
@@ -5,0 +5,0 @@ Project-URL: Homepage, https://github.com/yourusername/running-process |
+6
-6
@@ -1,2 +0,2 @@ | ||
| running_process/__init__.py,sha256=0SbyaLazVhgiWX4w6n21kMj2gMIVYSBtTxEARfEy3ow,690 | ||
| running_process/__init__.py,sha256=_UqFcFsZaMeL5-YmeJbhhDhSj3bnaoKpML7vqZL5AxA,690 | ||
| running_process/line_iterator.py,sha256=lbsjssk0yKjCRCb2knOuU5C2hbvdqKEgDjv2hPwIqrQ,1544 | ||
@@ -8,9 +8,9 @@ running_process/output_formatter.py,sha256=ie8gRQSZRGpBcNuZt5ns-yK6DDjO_SzAsiQAqLo71D0,1917 | ||
| running_process/pty.py,sha256=KfRutEF4dZyLRc4h0Wvl7nRbiM3zqHuibX4MaV7SEYY,8147 | ||
| running_process/running_process.py,sha256=RWhaTUfqjTi-NhaQQ4d0-L8OiR9QXEivad356NHnMFc,42730 | ||
| running_process/running_process.py,sha256=MGQPea1vL7VwySiLD6qwtJsXuYMjz5OKcmxUGDVny6I,45954 | ||
| running_process/running_process_manager.py,sha256=xx_kmXw9j-hjOI_pRrlTKdc9yekKBVQHhUq1eDpBGJU,2467 | ||
| running_process/subprocess_runner.py,sha256=O_Wwe2vrXWnYkiNEpauNLre3PqNO3uDogrRz0JCkH7M,3223 | ||
| running_process/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54 | ||
| running_process-1.0.7.dist-info/METADATA,sha256=-op6vAtBOV9YRYox3xsWuhgNaAG5eYnJA7YvQj9lqzo,8465 | ||
| running_process-1.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87 | ||
| running_process-1.0.7.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064 | ||
| running_process-1.0.7.dist-info/RECORD,, | ||
| running_process-1.1.0.dist-info/METADATA,sha256=XLZECBsy2bx88kXLS2vhd7XBq43HwxZWz9eNTGtrvhI,8465 | ||
| running_process-1.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87 | ||
| running_process-1.1.0.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064 | ||
| running_process-1.1.0.dist-info/RECORD,, |
@@ -5,3 +5,3 @@ """A modern subprocess.Popen wrapper with improved process management.""" | ||
| __version__ = "1.0.5" | ||
| __version__ = "1.1.0" | ||
@@ -8,0 +8,0 @@ from running_process.output_formatter import OutputFormatter, TimeDeltaFormatter |
@@ -219,2 +219,4 @@ """Enhanced subprocess execution with timeout protection, output streaming, and process tree management. | ||
| env: dict[str, str] | None = None, # Environment variables for the process | ||
| creationflags: int | None = None, # Windows-specific process creation flags | ||
| **popen_kwargs: Any, # Additional kwargs to pass to subprocess.Popen | ||
| ) -> None: | ||
@@ -238,2 +240,9 @@ """ | ||
| env: Environment variables for the process. If None, uses os.environ.copy(). | ||
| creationflags: Windows-specific process creation flags (e.g., subprocess.CREATE_NO_WINDOW). | ||
| On Windows, defaults to CREATE_NO_WINDOW to suppress console popups. | ||
| Pass 0 to disable default behavior. | ||
| **popen_kwargs: Additional keyword arguments to pass through to subprocess.Popen. | ||
| These will be merged with internal kwargs, with warnings for conflicts. | ||
| Some keys (stdout, stderr, text, encoding, errors, bufsize) cannot be | ||
| overridden as they're required for RunningProcess functionality. | ||
| """ | ||
@@ -277,2 +286,10 @@ # Validate command/shell combination | ||
| self.env = env | ||
| # Store creationflags, defaulting to CREATE_NO_WINDOW on Windows if not specified | ||
| # Users can pass 0 to explicitly disable this behavior | ||
| if creationflags is None and sys.platform == "win32" and hasattr(subprocess, "CREATE_NO_WINDOW"): | ||
| self.creationflags = subprocess.CREATE_NO_WINDOW | ||
| else: | ||
| self.creationflags = creationflags | ||
| # Store user-provided popen kwargs for merging with internal kwargs | ||
| self.popen_kwargs = popen_kwargs | ||
| self.reader_thread: threading.Thread | None = None | ||
@@ -398,2 +415,41 @@ self.watcher_thread: threading.Thread | None = None | ||
| def _merge_popen_kwargs(self, base_kwargs: dict[str, Any]) -> dict[str, Any]: | ||
| """ | ||
| Merge user-provided popen_kwargs with internal base kwargs. | ||
| Protected keys (required for RunningProcess functionality) cannot be overridden. | ||
| Other conflicts will warn but allow user values to take precedence. | ||
| Args: | ||
| base_kwargs: Internal kwargs set by RunningProcess | ||
| Returns: | ||
| Merged kwargs dictionary with conflicts resolved | ||
| """ | ||
| # Keys that are critical for RunningProcess and cannot be overridden | ||
| protected_keys = {"stdout", "stderr", "text", "encoding", "errors", "bufsize"} | ||
| merged = base_kwargs.copy() | ||
| for key, value in self.popen_kwargs.items(): | ||
| if key in protected_keys: | ||
| logger.warning( | ||
| "Cannot override protected subprocess.Popen argument '%s' " | ||
| "(required for RunningProcess functionality). Ignoring user value.", | ||
| key, | ||
| ) | ||
| continue | ||
| if key in merged and merged[key] != value: | ||
| logger.warning( | ||
| "User-provided popen_kwargs['%s']=%r conflicts with " "internal value %r. Using user value.", | ||
| key, | ||
| value, | ||
| merged[key], | ||
| ) | ||
| merged[key] = value | ||
| return merged | ||
| def _create_process_with_pipe(self) -> None: | ||
@@ -408,13 +464,25 @@ """Create subprocess with standard pipes.""" | ||
| # Build subprocess.Popen arguments (internal/required) | ||
| base_popen_kwargs = { | ||
| "shell": self.shell, | ||
| "cwd": self.cwd, | ||
| "stdout": subprocess.PIPE, | ||
| "stderr": subprocess.STDOUT, # Merge stderr into stdout | ||
| "text": True, # Use text mode | ||
| "encoding": "utf-8", # Explicitly use UTF-8 | ||
| "errors": "replace", # Replace invalid chars instead of failing | ||
| "bufsize": 1, # Line-buffered for real-time output | ||
| "env": env, | ||
| } | ||
| # Add creationflags if specified (e.g., CREATE_NO_WINDOW on Windows) | ||
| if self.creationflags is not None: | ||
| base_popen_kwargs["creationflags"] = self.creationflags | ||
| # Merge with user-provided kwargs, with conflict detection | ||
| final_popen_kwargs = self._merge_popen_kwargs(base_popen_kwargs) | ||
| self.proc = subprocess.Popen( # noqa: S603 | ||
| popen_command, | ||
| shell=self.shell, | ||
| cwd=self.cwd, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.STDOUT, # Merge stderr into stdout | ||
| text=True, # Use text mode | ||
| encoding="utf-8", # Explicitly use UTF-8 | ||
| errors="replace", # Replace invalid chars instead of failing | ||
| bufsize=1, # Line-buffered for real-time output | ||
| env=env, | ||
| **final_popen_kwargs, | ||
| ) | ||
@@ -1013,4 +1081,4 @@ | ||
| stdout_callback: Callable[[str], None] | None = None, | ||
| stderr_callback: Callable[[str], None] | None = None, | ||
| **kwargs: Any, | ||
| _stderr_callback: Callable[[str], None] | None = None, | ||
| **_kwargs: Any, | ||
| ) -> int: | ||
@@ -1032,4 +1100,4 @@ """Convenience classmethod for running a command with streaming output. | ||
| stdout_callback: Optional callback for stdout lines (default: print to stdout) | ||
| stderr_callback: Optional callback for stderr lines (IGNORED - for API compatibility only) | ||
| **kwargs: Additional arguments (currently unused, for API compatibility) | ||
| _stderr_callback: Optional callback for stderr lines (IGNORED - for API compatibility only) | ||
| **_kwargs: Additional arguments (currently unused, for API compatibility) | ||
@@ -1036,0 +1104,0 @@ Returns: |
+1
-1
| Wheel-Version: 1.0 | ||
| Generator: hatchling 1.27.0 | ||
| Generator: hatchling 1.28.0 | ||
| Root-Is-Purelib: true | ||
| Tag: py3-none-any |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.