瀏覽代碼

fix python file execution checking

Nick Sweeting 4 年之前
父節點
當前提交
c3d009e4ec
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      archivebox/system.py

+ 4 - 4
archivebox/system.py

@@ -18,7 +18,7 @@ from .config import PYTHON_BINARY, OUTPUT_PERMISSIONS
 
 
 
 
 
 
-def run(*args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs):
+def run(cmd, *args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs):
     """Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective
     """Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective
         Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
         Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
     """
     """
@@ -37,10 +37,10 @@ def run(*args, input=None, capture_output=True, timeout=None, check=False, text=
 
 
     pgid = None
     pgid = None
     try:
     try:
-        if args[0].endswith('.py'):
-            args = (PYTHON_BINARY, *args)
+        if isinstance(cmd, (list, tuple)) and cmd[0].endswith('.py'):
+            cmd = (PYTHON_BINARY, *cmd)
 
 
-        with Popen(*args, start_new_session=start_new_session, **kwargs) as process:
+        with Popen(cmd, *args, start_new_session=start_new_session, **kwargs) as process:
             pgid = os.getpgid(process.pid)
             pgid = os.getpgid(process.pid)
             try:
             try:
                 stdout, stderr = process.communicate(input, timeout=timeout)
                 stdout, stderr = process.communicate(input, timeout=timeout)