Add popen function
This commit is contained in:
parent
d22873f53b
commit
2ac1415975
|
@ -39,6 +39,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -170,6 +171,10 @@ PC = platform.node()
|
||||||
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
||||||
INFO_DEBUG = f"{sys.version}\n\n{platform.platform()}\n\n" + '\n'.join(sys.path)
|
INFO_DEBUG = f"{sys.version}\n\n{platform.platform()}\n\n" + '\n'.join(sys.path)
|
||||||
|
|
||||||
|
PYTHON = 'python'
|
||||||
|
if IS_WIN:
|
||||||
|
PYTHON = 'python.exe'
|
||||||
|
|
||||||
_MACROS = {}
|
_MACROS = {}
|
||||||
_start = 0
|
_start = 0
|
||||||
|
|
||||||
|
@ -302,7 +307,7 @@ def catch_exception(f):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
name = f.__name__
|
name = f.__name__
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
debug(traceback.format_exc())
|
msgbox(traceback.format_exc())
|
||||||
log.error(name, exc_info=True)
|
log.error(name, exc_info=True)
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
@ -535,7 +540,7 @@ def run(command, capture=False, split=True):
|
||||||
return subprocess.check_output(command, shell=True).decode()
|
return subprocess.check_output(command, shell=True).decode()
|
||||||
|
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
result = subprocess.run(cmd, capture_output=capture, text=True)
|
result = subprocess.run(cmd, capture_output=capture, text=True, shell=IS_WIN)
|
||||||
if capture:
|
if capture:
|
||||||
result = result.stdout
|
result = result.stdout
|
||||||
else:
|
else:
|
||||||
|
@ -543,15 +548,15 @@ def run(command, capture=False, split=True):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
# ~ def popen(command, stdin=None):
|
def popen(command):
|
||||||
# ~ try:
|
try:
|
||||||
# ~ proc = subprocess.Popen(shlex.split(command), shell=IS_WIN,
|
proc = subprocess.Popen(shlex.split(command), shell=IS_WIN,
|
||||||
# ~ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
# ~ for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
# ~ yield line.decode().rstrip()
|
yield line.decode().rstrip()
|
||||||
# ~ except Exception as e:
|
except Exception as e:
|
||||||
# ~ error(e)
|
error(e)
|
||||||
# ~ yield (e.errno, e.strerror)
|
yield (e.errno, e.strerror)
|
||||||
|
|
||||||
|
|
||||||
def sleep(seconds):
|
def sleep(seconds):
|
||||||
|
@ -4039,7 +4044,13 @@ class Paths(object):
|
||||||
|
|
||||||
@classproperty
|
@classproperty
|
||||||
def python(self):
|
def python(self):
|
||||||
return sys.executable
|
if IS_WIN:
|
||||||
|
path = self.join(self.config('Module'), PYTHON)
|
||||||
|
elif IS_MAC:
|
||||||
|
path = self.join(self.config('Module'), '..', 'Resources', PYTHON)
|
||||||
|
else:
|
||||||
|
path = sys.executable
|
||||||
|
return path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dir_tmp(self, only_name=False):
|
def dir_tmp(self, only_name=False):
|
||||||
|
|
Loading…
Reference in New Issue