This is a pile of other VNC fixes that I thought of after sending the set last night. These have all been tested with an updates.img against branched.
-jlk
--- anaconda | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/anaconda b/anaconda index 57f7bb8..0e47714 100755 --- a/anaconda +++ b/anaconda @@ -405,6 +405,7 @@ def startDebugger(signum, frame): def setupDisplay(anaconda, opts): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke + from pykickstart.constants import DISPLAY_MODE_TEXT
graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object. @@ -455,6 +456,10 @@ def setupDisplay(anaconda, opts): if iutil.memInstalled() < isys.MIN_GUI_RAM: flags.vncquestion = False
+ # disable VNC question if we were explicitly asked for text in kickstart + if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT: + flags.vncquestion = False + if os.environ.has_key('DISPLAY'): flags.preexisting_x11 = True
On Fri, Sep 28, 2012 at 12:17:42PM -0700, Jesse Keating wrote:
anaconda | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/anaconda b/anaconda index 57f7bb8..0e47714 100755 --- a/anaconda +++ b/anaconda @@ -405,6 +405,7 @@ def startDebugger(signum, frame): def setupDisplay(anaconda, opts): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke
from pykickstart.constants import DISPLAY_MODE_TEXT
graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object.
@@ -455,6 +456,10 @@ def setupDisplay(anaconda, opts): if iutil.memInstalled() < isys.MIN_GUI_RAM: flags.vncquestion = False
- # disable VNC question if we were explicitly asked for text in kickstart
- if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT:
flags.vncquestion = False
What about DISPLAY_MODE_CMDLINE? If cmdline is specified it shouldn't ask either.
On 09/28/2012 04:05 PM, Brian C. Lane wrote:
On Fri, Sep 28, 2012 at 12:17:42PM -0700, Jesse Keating wrote:
anaconda | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/anaconda b/anaconda index 57f7bb8..0e47714 100755 --- a/anaconda +++ b/anaconda @@ -405,6 +405,7 @@ def startDebugger(signum, frame): def setupDisplay(anaconda, opts): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke
from pykickstart.constants import DISPLAY_MODE_TEXT
graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object.
@@ -455,6 +456,10 @@ def setupDisplay(anaconda, opts): if iutil.memInstalled() < isys.MIN_GUI_RAM: flags.vncquestion = False
- # disable VNC question if we were explicitly asked for text in kickstart
- if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT:
flags.vncquestion = False
What about DISPLAY_MODE_CMDLINE? If cmdline is specified it shouldn't ask either.
We only ask about VNC is display mode is t and the askvnc is set, OR if display mode is X but X startup failed. This precludes asking for VNC if display mode is c.
On Mon, Oct 01, 2012 at 09:23:35AM -0700, Jesse Keating wrote:
On 09/28/2012 04:05 PM, Brian C. Lane wrote:
On Fri, Sep 28, 2012 at 12:17:42PM -0700, Jesse Keating wrote:
anaconda | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/anaconda b/anaconda index 57f7bb8..0e47714 100755 --- a/anaconda +++ b/anaconda @@ -405,6 +405,7 @@ def startDebugger(signum, frame): def setupDisplay(anaconda, opts): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke
from pykickstart.constants import DISPLAY_MODE_TEXT
graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object.
@@ -455,6 +456,10 @@ def setupDisplay(anaconda, opts): if iutil.memInstalled() < isys.MIN_GUI_RAM: flags.vncquestion = False
- # disable VNC question if we were explicitly asked for text in kickstart
- if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT:
flags.vncquestion = False
What about DISPLAY_MODE_CMDLINE? If cmdline is specified it shouldn't ask either.
We only ask about VNC is display mode is t and the askvnc is set, OR if display mode is X but X startup failed. This precludes asking for VNC if display mode is c.
Thanks for the clarification, ACK to this set then.
Moves the checks that were in the VNC question out to the prep for the VNC question. We don't get a simple true/false out of the question anymore. --- anaconda | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/anaconda b/anaconda index 0e47714..411bb07 100755 --- a/anaconda +++ b/anaconda @@ -406,6 +406,7 @@ def setupDisplay(anaconda, opts): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke from pykickstart.constants import DISPLAY_MODE_TEXT + from pyanaconda import network
graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object. @@ -460,6 +461,14 @@ def setupDisplay(anaconda, opts): if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT: flags.vncquestion = False
+ # disable VNC question if we don't have network + if not network.hasActiveNetDev(): + flags.vncquestion = False + + # disable VNC question if we don't have X + if not os.access('/usr/bin/Xvnc', os.X_OK): + flags.vncquestion = False + if os.environ.has_key('DISPLAY'): flags.preexisting_x11 = True
@@ -549,7 +558,7 @@ def setupDisplay(anaconda, opts): set_x_resolution(opts.runres)
if anaconda.displayMode == 't' and graphical_failed and \ - not anaconda.ksdata.vnc.enabled: + flags.vncquestion and not anaconda.ksdata.vnc.enabled: app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata) app.schedule_screen(spoke)
--- pyanaconda/ui/tui/spokes/askvnc.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py index fc13235..a3cf3c4 100644 --- a/pyanaconda/ui/tui/spokes/askvnc.py +++ b/pyanaconda/ui/tui/spokes/askvnc.py @@ -94,9 +94,14 @@ class VNCPassSpoke(NormalTUISpoke): title = _("VNC Password") category = "vnc"
- def __init__(self, app, data, storage, payload, instclass): + def __init__(self, app, data, storage, payload, instclass, message=None): NormalTUISpoke.__init__(self, app, data, storage, payload, instclass) self._password = "" + if message: + self._message = message + else: + self._message = _("Please provide VNC password. You will have to type it twice. \n" + "Leave blank for no password")
@property def indirect(self): @@ -108,8 +113,7 @@ class VNCPassSpoke(NormalTUISpoke):
def refresh(self, args = None): NormalTUISpoke.refresh(self, args) - self._window += [TextWidget(_("Please provide VNC password. You will have to type it twice. \n" \ - "Leave blank for no password")), ""] + self._window += [TextWidget(self._message), ""]
return True
On Fri, 2012-09-28 at 12:17 -0700, Jesse Keating wrote:
pyanaconda/ui/tui/spokes/askvnc.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py index fc13235..a3cf3c4 100644 --- a/pyanaconda/ui/tui/spokes/askvnc.py +++ b/pyanaconda/ui/tui/spokes/askvnc.py @@ -94,9 +94,14 @@ class VNCPassSpoke(NormalTUISpoke): title = _("VNC Password") category = "vnc"
- def __init__(self, app, data, storage, payload, instclass):
- def __init__(self, app, data, storage, payload, instclass, message=None): NormalTUISpoke.__init__(self, app, data, storage, payload, instclass) self._password = ""
if message:
self._message = message
else:
self._message = _("Please provide VNC password. You will have to type it twice. \n"
"Leave blank for no password")
This could be shortened by using:
self._message = message or _(...)
On 10/01/2012 12:19 AM, Vratislav Podzimek wrote:
This could be shortened by using:
self._message = message or _(...)
It could, but I'm really not a fan of this style. Feels like something from a different language.
--- pyanaconda/ui/tui/spokes/askvnc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py index a3cf3c4..1e67118 100644 --- a/pyanaconda/ui/tui/spokes/askvnc.py +++ b/pyanaconda/ui/tui/spokes/askvnc.py @@ -125,7 +125,7 @@ class VNCPassSpoke(NormalTUISpoke): if p1 != p2: print _("Passwords do not match!") return None - elif p1 > 0 < 6: + elif 0 < len(p1) < 6: print _("The password must be at least " "six characters long.") return None
This cleans up a lot of stuff in this file by making use of the spoke we have instead of newt. There are also a few whitespace fixes and removeals of unnecessary imports. --- pyanaconda/vnc.py | 183 +++++------------------------------------------------- 1 file changed, 17 insertions(+), 166 deletions(-)
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index 22e758c..2cdc947 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -19,18 +19,18 @@ # Author(s): Jeremy Katz katzj@redhat.com #
-import os, sys, string +import os, sys import time -from snack import * from constants import * -from textw.constants_text import * import network -import isys import product import socket import subprocess import iutil
+from pyanaconda.ui.tui.simpleline import App +from pyanaconda.ui.tui.spokes.askvnc import VNCPassSpoke + import gettext _ = lambda x: gettext.ldgettext("anaconda", x) P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z) @@ -219,14 +219,14 @@ class VncServer: "set a password, it will be used in case the connection \n" "to the vncviewer is unsuccessful\n\n")) elif self.password == "": - self.log.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n" + self.log.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n" "You can use the vncpassword=<password> boot option\n" "if you would like to secure the server.\n\n")) elif self.password != "": - self.log.warning(_("\n\nYou chose to execute vnc with a password. \n\n")) + self.log.warning(_("\n\nYou chose to execute vnc with a password. \n\n")) else: - self.log.warning(_("\n\nUnknown Error. Aborting. \n\n")) - sys.exit(1) + self.log.warning(_("\n\nUnknown Error. Aborting. \n\n")) + sys.exit(1)
# Lets try to configure the vnc server to whatever the user specified if self.vncconnecthost != "": @@ -242,164 +242,15 @@ class VncServer: """ Change the password to a sane parameter.
We ask user to input a password that len(password) > 6 - or password == ''. Have to find a way to put askVncWindow - and this method together. + or password == ''. """
- screen = SnackScreen() - grid = GridFormHelp(screen, _("VNC Configuration"),"vnc", 1, 10) - - bb = ButtonBar(screen, (TEXT_OK_BUTTON, - (_("No password"), "nopass"))) - - text = _("A password will prevent unauthorized listeners " - "connecting and monitoring your installation progress. " - "Please enter a password to be used for the installation") - grid.add(TextboxReflowed(40, text), 0, 0, (0, 0, 0, 1)) - - entry1 = Entry (16, password = 1) - entry2 = Entry (16, password = 1) - passgrid = Grid (2, 2) - passgrid.setField (Label (_("Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1) - passgrid.setField (Label (_("Password (confirm):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1) - passgrid.setField (entry1, 1, 0) - passgrid.setField (entry2, 1, 1) - grid.add (passgrid, 0, 1, (0, 0, 0, 1)) - - grid.add(bb, 0, 8, (0, 1, 1, 0), growx = 1) - - while 1: - res = grid.run() - rc = bb.buttonPressed(res) - - if rc == "nopass": - screen.finish() - return "" - else: - pw = entry1.value() - cf = entry2.value() - if pw != cf: - ButtonChoiceWindow(screen, _("Password Mismatch"), - _("The passwords you entered were " - "different. Please try again."), - buttons = [ TEXT_OK_BUTTON ], - width = 50) - elif len(pw) < 6: - ButtonChoiceWindow(screen, _("Password Length"), - _("The password must be at least " - "six characters long."), - buttons = [ TEXT_OK_BUTTON ], - width = 50) - else: - screen.finish() - self.password = pw - return - - entry1.set("") - entry2.set("") - continue - continue - -def askVncWindow(title = None, message = None): - if not os.access('/usr/bin/Xvnc', os.X_OK): - return -1 - - if not network.hasActiveNetDev(): - return -1 - - if not title: - title = _("Unable to Start X") - if not message: - message = _("X was unable to start on your " - "machine. Would you like to " - "start VNC to connect to " - "this computer from another " - "computer and perform a " - "graphical install or continue " - "with a text mode install?") - - screen = SnackScreen() - vncpass = None - vncconnect = 0 - - STEP_MESSAGE = 0 - STEP_PASS = 1 - STEP_DONE = 3 - step = 0 - while step < STEP_DONE: - if step == STEP_MESSAGE: - button = ButtonChoiceWindow(screen, title, message, - buttons = [ _("Start VNC"), - _("Use text mode") ]) - - if button == string.lower (_("Use text mode")): - screen.finish() - return -1 - else: - step = STEP_PASS - continue - - if step == STEP_PASS: - grid = GridFormHelp(screen, _("VNC Configuration"), - "vnc", 1, 10) - - bb = ButtonBar(screen, (TEXT_OK_BUTTON, - (_("No password"), "nopass"), - TEXT_BACK_BUTTON)) - - text = _("A password will prevent unauthorized listeners " - "connecting and monitoring your installation progress. " - "Please enter a password to be used for the installation") - grid.add(TextboxReflowed(40, text), 0, 0, (0, 0, 0, 1)) - - entry1 = Entry (16, password = 1) - entry2 = Entry (16, password = 1) - passgrid = Grid (2, 2) - passgrid.setField (Label (_("Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1) - passgrid.setField (Label (_("Password (confirm):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1) - passgrid.setField (entry1, 1, 0) - passgrid.setField (entry2, 1, 1) - grid.add (passgrid, 0, 1, (0, 0, 0, 1)) - - grid.add(bb, 0, 8, (0, 1, 1, 0), growx = 1) - - while 1: - res = grid.run() - rc = bb.buttonPressed(res) - - if rc == TEXT_BACK_CHECK: - screen.popWindow() - step = STEP_MESSAGE - break - elif rc == "nopass": - screen.finish() - return None - else: - pw = entry1.value() - cf = entry2.value() - if pw != cf: - ButtonChoiceWindow(screen, _("Password Mismatch"), - _("The passwords you entered were " - "different. Please try again."), - buttons = [ TEXT_OK_BUTTON ], - width = 50) - elif len(pw) < 6: - ButtonChoiceWindow(screen, _("Password Length"), - _("The password must be at least " - "six characters long."), - buttons = [ TEXT_OK_BUTTON ], - width = 50) - else: - screen.finish() - return pw - - entry1.set("") - entry2.set("") - continue - continue - - screen.finish() - return -1 + message = _("VNC password provided was not at least 6 characters long.\n" + "Please enter a new one. Leave blank for no password.") + app = App("VNC PASSWORD") + spoke = VNCPassSpoke(app, self.anaconda.ksdata, None, None, None, + message) + app.schedule_screen(spoke) + app.run()
-if __name__ == "__main__": - askVncWindow() + self.password = self.anaconda.ksdata.vnc.password
On Fri, Sep 28, 2012 at 12:17:46PM -0700, Jesse Keating wrote:
This cleans up a lot of stuff in this file by making use of the spoke we have instead of newt. There are also a few whitespace fixes and removeals of unnecessary imports.
^^^ removals
On 09/28/2012 04:12 PM, Brian C. Lane wrote:
On Fri, Sep 28, 2012 at 12:17:46PM -0700, Jesse Keating wrote:
This cleans up a lot of stuff in this file by making use of the spoke we have instead of newt. There are also a few whitespace fixes and removeals of unnecessary imports.
^^^
removals
Nice catch, fixed locally.
This makes the specific test of changing the VNC password work, since it relies on that object existing. --- tests/pyanaconda_test/vnc_test.py | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tests/pyanaconda_test/vnc_test.py b/tests/pyanaconda_test/vnc_test.py index 8b703c8..80cc527 100644 --- a/tests/pyanaconda_test/vnc_test.py +++ b/tests/pyanaconda_test/vnc_test.py @@ -9,6 +9,9 @@ class VncTest(mock.TestCase): self.setupModules(["_isys", "block", "logging", "ConfigParser"]) self.fs = mock.DiskIO()
+ self.anaconda = mock.Mock() + self.anaconda.ksdata.vnc.password = '' + import pyanaconda pyanaconda.anaconda_log = mock.Mock()
@@ -36,6 +39,7 @@ class VncTest(mock.TestCase): def set_vnc_password_1_test(self): import pyanaconda.vnc server = pyanaconda.vnc.VncServer() + server.anaconda = self.anaconda pyanaconda.vnc.iutil = mock.Mock() pyanaconda.vnc.os.pipe.return_value = (1, 2)
anaconda-patches@lists.fedorahosted.org