isys.vtActivate is problematic when using tmux, chvt command works
well and we use it so rarely that it should be okay to call an
external command.
---
anaconda | 2 +-
anaconda.spec.in | 1 +
pyanaconda/exception.py | 12 ++++--------
pyanaconda/isys/__init__.py | 5 -----
pyanaconda/isys/isys.c | 15 ---------------
pyanaconda/iutil.py | 22 ++++++++++++++++++++++
6 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/anaconda b/anaconda
index a6bb720..8e67ec5 100755
--- a/anaconda
+++ b/anaconda
@@ -44,7 +44,7 @@ def exitHandler(rebootData, storage, exitCode=None):
anaconda.intf.shutdown()
if "nokill" in flags.cmdline:
- isys.vtActivate(1)
+ iutil.vtActivate(1)
print "anaconda halting due to nokill flag."
print "The system will be rebooted when you press
Ctrl-Alt-Delete."
while True:
diff --git a/anaconda.spec.in b/anaconda.spec.in
index 1cc1c41..72a1051 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -161,6 +161,7 @@ Requires: dhclient
Requires: anaconda-yum-plugins
Requires: libselinux-python >= %{libselinuxver}
Requires: fcoe-utils >= %{fcoeutilsver}
+Requires: kbd
%ifarch %{sparc}
Requires: elftoaout piggyback
%endif
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index 70deed5..b18f228 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -23,6 +23,7 @@
from meh.handler import *
from meh.dump import *
import isys
+import iutil
import sys
import os
import shutil
@@ -94,10 +95,7 @@ class AnacondaExceptionHandler(ExceptionHandler):
def runDebug(self, (ty, value, tb)):
# vtActivate does not work on certain ppc64 machines, so just skip
# that and continue with the rest of the debugger setup.
- try:
- isys.vtActivate(1)
- except SystemError:
- pass
+ iutil.vtActivate(1)
pidfl = "/tmp/vncshell.pid"
if os.path.exists(pidfl) and os.path.isfile(pidfl):
@@ -126,10 +124,8 @@ class AnacondaExceptionHandler(ExceptionHandler):
"the main window")
import pdb
pdb.post_mortem (tb)
- try:
- isys.vtActivate(6)
- except SystemError:
- pass
+
+ iutil.vtActivate(6)
def initExceptionHandling(anaconda):
fileList = [ "/tmp/anaconda.log",
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index 63edbf6..8195f0d 100755
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -265,11 +265,6 @@ def driveUsesModule(device, modules):
pass
return rc
-def vtActivate (num):
- if iutil.isS390():
- return
- _isys.vtActivate (num)
-
def isPseudoTTY (fd):
return _isys.isPseudoTTY (fd)
diff --git a/pyanaconda/isys/isys.c b/pyanaconda/isys/isys.c
index 9b9046a..82dc404 100644
--- a/pyanaconda/isys/isys.c
+++ b/pyanaconda/isys/isys.c
@@ -125,7 +125,6 @@ static PyMethodDef isysModuleMethods[] = {
{ "resetresolv", (PyCFunction) doResetResolv, METH_VARARGS, NULL },
{ "swapon", (PyCFunction) doSwapon, METH_VARARGS, NULL },
{ "swapoff", (PyCFunction) doSwapoff, METH_VARARGS, NULL },
- { "vtActivate", (PyCFunction) doVtActivate, METH_VARARGS, NULL},
{ "isPseudoTTY", (PyCFunction) doisPseudoTTY, METH_VARARGS, NULL},
{ "isVioConsole", (PyCFunction) doisVioConsole, METH_NOARGS, NULL},
{ "sync", (PyCFunction) doSync, METH_VARARGS, NULL},
@@ -444,20 +443,6 @@ static PyObject * doEjectCdrom(PyObject * s, PyObject * args) {
return Py_None;
}
-static PyObject * doVtActivate(PyObject * s, PyObject * args) {
- int vtnum;
-
- if (!PyArg_ParseTuple(args, "i", &vtnum)) return NULL;
-
- if (ioctl(0, VT_ACTIVATE, vtnum)) {
- PyErr_SetFromErrno(PyExc_SystemError);
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
static PyObject * doisPseudoTTY(PyObject * s, PyObject * args) {
int fd;
struct stat sb;
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index fd0b985..f232309 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -1074,6 +1074,28 @@ def get_option_value(opt_name, options):
if name == opt_name:
return val.strip()
+def vtActivate(num):
+ """
+ Try to switch to tty number $num.
+
+ @type num: int
+ @return: whether the switch was successful or not
+ @rtype: bool
+
+ """
+
+ try:
+ ret = execWithRedirect("chvt", [num], stdout="/dev/tty5",
+ stderr="/dev/tty5")
+ except OSError as oserr:
+ ret = -1
+ log.error("Failed to run chvt: %s", oserr.strerror)
+
+ if ret != 0:
+ log.error("Failed to switch tty to tty%d", num)
+
+ return ret == 0
+
class ProxyStringError(Exception):
pass
--
1.7.11.2