The sys.exit(1) in vnc.py will eventually change to a raise in newui, but for now follows the example of other simliar code in vnc.py
-jlk
This is mostly code that was in vnc.py as well as anaconda itself. --- pyanaconda/network.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py index 2b8ca7d..103816e 100644 --- a/pyanaconda/network.py +++ b/pyanaconda/network.py @@ -566,6 +566,27 @@ class Network:
return ip
+ # Return a list of IP addresses for all active devices. + def getIPs(self): + ips = [] + for dev in getActiveNetDevs(): + devname = self.netdevices[dev].iface + try: + ips += (isys.getIPAddresses(devname, version=4) + + isys.getIPAddresses(devname, version=6)) + except Exception as e: + log.warning("Got an exception trying to get the ip addr " + "of %s: %s" % (devname, e)) + + return ips + + # Return the first real non-local IP we find + def getFirstRealIP(self): + for ip in self.getIPs(): + if ip not in ("127.0.0.1", "::1"): + return ip + return None + # Note that the file is written-out only if there is a value # that has changed. def writeIfcfgFiles(self):
--- anaconda | 20 ++++---------------- pyanaconda/vnc.py | 28 ++++++++++------------------ 2 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/anaconda b/anaconda index be8c7be..88335f8 100755 --- a/anaconda +++ b/anaconda @@ -611,23 +611,11 @@ def prompt_for_ssh(): # see if we can sniff out network info netinfo = network.Network()
- devices = netinfo.netdevices - active_devs = network.getActiveNetDevs() + ip = netinfo.getFirstRealIP()
- ip = None - if active_devs != []: - devname = devices[active_devs[0]].iface - try: - ips = (isys.getIPAddresses(devname, version=4) + - isys.getIPAddresses(devname, version=6)) - except Exception as e: - stdoutLog.warning("Got an exception trying to get the ip addr " - "of %s: %s" % (devname, e)) - else: - if ips and ips[0] not in ("127.0.0.1", "::1"): - stdoutLog.debug("IPs (using first) of device %s: %s" % (devname, - ips)) - ip = ips[0] + if not ip: + stdoutLog.error("No IP addresses found, cannot continue installation.") + sys.exit(1)
ipstr = ip
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index a7ccc76..2f87650 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -80,23 +80,11 @@ class VncServer: # see if we can sniff out network info netinfo = network.Network()
- devices = netinfo.netdevices - active_devs = network.getActiveNetDevs() - - self.ip = None - if active_devs != []: - devname = devices[active_devs[0]].iface - try: - ips = (isys.getIPAddresses(devname, version=4) + - isys.getIPAddresses(devname, version=6)) - except Exception as e: - log.warning("Got an exception trying to get the self.ip addr " - "of %s: %s" % (devname, e)) - else: - if ips and ips[0] not in ("127.0.0.1", "::1"): - log.info("IPs (using first) of device %s: %s" % (devname, - ips)) - self.ip = ips[0] + self.ip = netinfo.getFirstRealIP() + + if not self.ip: + # Raise this here which will be caught higher up + raise Exception("No IP addresses found.")
ipstr = self.ip
@@ -187,7 +175,11 @@ class VncServer: self.log.info(_("Starting VNC..."))
# Lets call it from here for now. - self.initialize() + try: + self.initialize() + except Exception, e: + stdoutLog.critical("Could not initialize the VNC server: %s" % e) + sys.exit(1)
if self.password and len(self.password) < 6: self.changeVNCPasswdWindow()
Looks good to me.
On 06/29/2012 01:46 AM, Jesse Keating wrote:
The sys.exit(1) in vnc.py will eventually change to a raise in newui, but for now follows the example of other simliar code in vnc.py
-jlk
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/anaconda-patches
anaconda-patches@lists.fedorahosted.org