diff --git a/qspectrumanalyzer/backends/__init__.py b/qspectrumanalyzer/backends/__init__.py index 22628c2..82705ee 100644 --- a/qspectrumanalyzer/backends/__init__.py +++ b/qspectrumanalyzer/backends/__init__.py @@ -38,10 +38,11 @@ class BaseInfo: @classmethod def help_params(cls, executable): try: - p = subprocess.run([executable, '-h'], universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - env=dict(os.environ, COLUMNS='125')) - text = p.stdout + text = subprocess.check_output([executable, '-h'], universal_newlines=True, + stderr=subprocess.STDOUT, + env=dict(os.environ, COLUMNS='125')) + except subprocess.CalledProcessError as e: + text = e.output except OSError: text = '{} executable not found!'.format(executable) return text diff --git a/qspectrumanalyzer/backends/soapy_power.py b/qspectrumanalyzer/backends/soapy_power.py index 809024a..9eecfa0 100644 --- a/qspectrumanalyzer/backends/soapy_power.py +++ b/qspectrumanalyzer/backends/soapy_power.py @@ -46,17 +46,15 @@ class Info(BaseInfo): @classmethod def help_device(cls, executable, device): try: - text = '' - p = subprocess.run([executable, '--detect'], universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, - env=dict(os.environ, COLUMNS='125')) - text += p.stdout + '\n' - - if p.returncode == 0: - p = subprocess.run([executable, '--device', device, '--info'], universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, - env=dict(os.environ, COLUMNS='125')) - text += p.stdout + text = subprocess.check_output([executable, '--detect'], universal_newlines=True, + stderr=subprocess.DEVNULL, + env=dict(os.environ, COLUMNS='125')) + text += '\n' + text += subprocess.check_output([executable, '--device', device, '--info'], universal_newlines=True, + stderr=subprocess.DEVNULL, + env=dict(os.environ, COLUMNS='125')) + except subprocess.CalledProcessError as e: + text = e.output except OSError: text = '{} executable not found!'.format(executable) return text