terminal.py: No --disable-factory for gnome-terminal >= 3.10
PATCH v2 1/1 terminal.py: No --disable-factory for gnome-terminal >= 3.10
--disable-factory has been disabled in earlier versions of gnome-terminal but from version 3.10 it raises an error and quits. This makes devshell unusable with gnome-terminal >= 3.10. This patch checks for the version and removes --disable-factory if you have the terminal version 3.10 or higher.
--- meta/lib/oe/terminal.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
meta/lib/oe/terminal.py +22 -8
@@ -55,6 +55,14 @@ class Gnome(XTerminal): command = 'gnome-terminal -t "{title}" --disable-factory -x {command}' priority = 2 + def __init__(self, sh_cmd, title=None, env=None, d=None): + # Check version + (major, minor) = check_terminal_version("gnome-terminal") + if major >= 3 and minor >= 10: + logger.warn(1, 'Gnome-Terminal >3.10 does not support --disable-factory') + self.command = 'gnome-terminal -t "{title}" -x {command}' + XTerminal.__init__(self, sh_cmd, title, env, d) + class Mate(XTerminal): command = 'mate-terminal -t "{title}" -x {command}' priority = 2
@@ -73,11 +81,10 @@ class Konsole(XTerminal): def __init__(self, sh_cmd, title=None, env=None, d=None): # Check version - vernum = check_konsole_version("konsole") - if vernum: - if vernum.split('.')[0] == "2": - logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') - raise UnsupportedTerminal(self.name) + (major, minor) = check_terminal_version("konsole") + if major == 2: + logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') + raise UnsupportedTerminal(self.name) XTerminal.__init__(self, sh_cmd, title, env, d) class XTerm(XTerminal):
@@ -219,10 +226,10 @@ def check_tmux_pane_size(tmux): return True return False -def check_konsole_version(konsole): +def check_terminal_version(terminalName): import subprocess as sub try: - p = sub.Popen(['sh', '-c', '%s --version' % konsole],stdout=sub.PIPE,stderr=sub.PIPE) + p = sub.Popen(['sh', '-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) out, err = p.communicate() ver_info = out.rstrip().split('\n') except OSError as exc:
@@ -232,10 +239,17 @@ def check_konsole_version(konsole): else: raise vernum = None + major = int(0) + minor = int(0) for ver in ver_info: if ver.startswith('Konsole'): vernum = ver.split(' ')[-1] - return vernum + if ver.startswith('GNOME Terminal'): + vernum = ver.split(' ')[-1] + if vernum: + major = int(vernum.split('.')[0]) + minor = int(vernum.split('.')[1]) + return major, minor def distro_name(): try:
Signature · 1 line
1.9.3
Hi Sven,
Quoted 66 lines · On Monday 23 February 2015 20:39:41 Sven Ebenfeld wrote:
--disable-factory has been disabled in earlier versions of gnome-terminal but from version 3.10 it raises an error and quits. This makes devshell unusable with gnome-terminal >= 3.10. This patch checks for the version and removes --disable-factory if you have the terminal version 3.10 or higher.
Signed-off-by Sven Ebenfeld <[email protected]>--- meta/lib/oe/terminal.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)meta/lib/oe/terminal.py +9
-5@@ -55,6 +55,14 @@ class Gnome(XTerminal): command = 'gnome-terminal -t "{title}" --disable-factory -x {command}' priority = 2 + def __init__(self, sh_cmd, title=None, env=None, d=None): + # Check version + (major, minor) = check_terminal_version("gnome-terminal") + if major >= 3 and minor >= 10: + logger.warn(1, 'Gnome-Terminal >3.10 does not support --disable-factory') + self.command = 'gnome-terminal -t "{title}" -x {command}' + XTerminal.__init__(self, sh_cmd, title, env, d) + class Mate(XTerminal): command = 'mate-terminal -t "{title}" -x {command}' priority = 2@@ -73,11 +81,10 @@ class Konsole(XTerminal): def __init__(self, sh_cmd, title=None, env=None, d=None): # Check version - vernum = check_konsole_version("konsole") - if vernum: - if vernum.split('.')[0] == "2": - logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') - raise UnsupportedTerminal(self.name) + (major, minor) = check_terminal_version("konsole") + if major == 2: + logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') + raise UnsupportedTerminal(self.name) XTerminal.__init__(self, sh_cmd, title, env, d)class XTerm(XTerminal):
meta/lib/oe/terminal.py +3
-2@@ -219,10 +226,10 @@ def check_tmux_pane_size(tmux): return True return False -def check_konsole_version(konsole): +def check_terminal_version(terminalName): import subprocess as sub try: - p = sub.Popen(['sh', '-c', '%s --version' % konsole],stdout=sub.PIPE,stderr=sub.PIPE) + p = sub.Popen(['sh', '-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) out, err = p.communicate() ver_info = out.rstrip().split('\n') except OSError as exc:@@ -232,10 +239,17 @@ def check_konsole_version(konsole): else: raise vernum = None + major = int(0) + minor = int(0)
meta/lib/oe/terminal.py def check_konsole_version(konsole): · line 252
Quoted 10 lines
meta/lib/oe/terminal.py +6
-1for ver in ver_info: if ver.startswith('Konsole'): vernum = ver.split(' ')[-1] - return vernum + if ver.startswith('GNOME Terminal'): + vernum = ver.split(' ')[-1] + if vernum: + major = int(vernum.split('.')[0]) + minor = int(vernum.split('.')[1]) + return major, minor
Obviously we needed the other part, but this API change means that we no longer get the full version when there are more than two parts (e.g. the current version of konsole on my system is 2.4.12), and it will blow up in the case when the version does not contain '.' or contains non-integer parts e.g. "3.4-beta". These might not be immediate problems but they may be in future.
I'd honestly rather we keep this as a string; if we need to do comparisons we can use distutils.version.LooseVersion(). I can send a fix for this along with a fix for Konsole 2.x which seems to be able to work now.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 103 lines · On Wednesday 25 February 2015 09:46:07 Paul Eggleton wrote:
Hi Sven,
Quoted 82 lines · On Monday 23 February 2015 20:39:41 Sven Ebenfeld wrote:
--disable-factory has been disabled in earlier versions of gnome-terminal but from version 3.10 it raises an error and quits. This makes devshell unusable with gnome-terminal >= 3.10. This patch checks for the version and
removes --disable-factory if you have the terminal version 3.10 or higher.Signed-off-by Sven Ebenfeld <[email protected]>---
meta/lib/oe/terminal.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)meta/lib/oe/terminal.py +5
-1@@ -55,6 +55,14 @@ class Gnome(XTerminal): command = 'gnome-terminal -t "{title}" --disable-factory -x {command}' priority = 2 + def __init__(self, sh_cmd, title=None, env=None, d=None): + # Check version + (major, minor) = check_terminal_version("gnome-terminal") + if major >= 3 and minor >= 10: + logger.warn(1, 'Gnome-Terminal >3.10 does not support --disable-factory') + self.command = 'gnome-terminal -t "{title}" -x {command}' + XTerminal.__init__(self, sh_cmd, title,env, d)
meta/lib/oe/terminal.py +4
-4+ class Mate(XTerminal): command = 'mate-terminal -t "{title}" -x {command}' priority = 2@@ -73,11 +81,10 @@ class Konsole(XTerminal): def __init__(self, sh_cmd, title=None, env=None, d=None): # Check version - vernum = check_konsole_version("konsole") - if vernum: - if vernum.split('.')[0] == "2": - logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') - raise UnsupportedTerminal(self.name) + (major, minor) = check_terminal_version("konsole") + if major == 2: + logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') + raise UnsupportedTerminal(self.name) XTerminal.__init__(self, sh_cmd, title, env, d)class XTerm(XTerminal):
meta/lib/oe/terminal.py +1
-2@@ -219,10 +226,10 @@ def check_tmux_pane_size(tmux): return True return False -def check_konsole_version(konsole): +def check_terminal_version(terminalName): import subprocess as sub try: - p = sub.Popen(['sh', '-c', '%s --version' %konsole],stdout=sub.PIPE,stderr=sub.PIPE) + p = sub.Popen(['sh',
'-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) out, err =p.communicate()
ver_info= out.rstrip().split('\n')except OSError as exc:
meta/lib/oe/terminal.py +2
-0@@ -232,10 +239,17 @@ def check_konsole_version(konsole): else: raise vernum = None + major = int(0) + minor = int(0) for ver in ver_info:meta/lib/oe/terminal.py def check_konsole_version(konsole):
Quoted 10 lines
meta/lib/oe/terminal.py +6
-1if ver.startswith('Konsole'): vernum = ver.split(' ')[-1] - return vernum + if ver.startswith('GNOME Terminal'): + vernum = ver.split(' ')[-1] + if vernum: + major = int(vernum.split('.')[0]) + minor = int(vernum.split('.')[1]) + return major, minorObviously we needed the other part, but this API change means that we no longer get the full version when there are more than two parts (e.g. the current version of konsole on my system is 2.4.12), and it will blow up in the case when the version does not contain '.' or contains non-integer parts e.g. "3.4-beta". These might not be immediate problems but they may be in future.
Quoted 3 lines
I'd honestly rather we keep this as a string; if we need to do comparisons we can use
distutils.version.LooseVersion(). I can send a fix for this along with a fix for Konsole 2.x which seems to be able to work now.
Sorry, I should have CC'd Ross since he advised you to do the split within the function.
Another couple of issues I noticed:
1) This added tabs in python code - please don't add these
2) We don't want this to show a warning when launching gnome-terminal 3.10+ and logger.warn() doesn't take an integer first parameter in any case (logger.debug() does)
I'm fixing these as well.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre