Make help commands in settings compatible with Python 3.4

This commit is contained in:
Michal Krenek (Mikos) 2017-03-28 10:44:03 +02:00
parent 9ee6f631dc
commit fa462f885d
2 changed files with 14 additions and 15 deletions

View File

@ -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

View File

@ -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