Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Aug 2007 22:36:15 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125570 for review
Message-ID:  <200708222236.l7MMaFOf092820@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125570

Change 125570 by ivoras@ivoras_finstall on 2007/08/22 22:35:59

	Implement tiles: root password change, user add

Affected files ...

.. //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#14 edit

Differences ...

==== //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#14 (text+ko) ====

@@ -54,6 +54,16 @@
 		{ "tile" : "nfinish" }
 	]
 
+	Steps_Config = [
+		{ "tile" : "intro" },	# "intro" must appear everywhere
+		{ "tile" : "hostroot" },
+		{ "tile" : "createuser" },
+		{ "tile" : "netconf" },
+		{ "tile" : "x11conf" },
+		{ "tile" : "soundconf" },
+		{ "tile" : "nfinish" }
+	]
+
 
 	def __init__(self):
 		BaseWin.__init__(self, "mainwin")
@@ -62,17 +72,15 @@
 		self["img_logo"].set_from_file("img/logo.jpg")
 		# img_logo stretches the window vertically, so calling window.set_position() has no affect
 		self._center_window(self.window)
-		self.step_current = -1
-		self.step_next = 0
-		self.step_track = MainWin.Steps_Novice
-		self._load_tile_nr(self.step_next)
-		self.backtrack = []
+		self._load_track(self.Steps_Novice)
 
 
 	def __getitem__(self, key):
-		"""Make convenient shortcut to window widgets. This is actually not
+		"""
+		Make convenient shortcut to window widgets. This is actually not
 		easy as it seems, since we use different Glade XML files for different
-		tiles of the wizard dialog."""
+		tiles of the wizard dialog.
+		"""
 		if self.tile_xml:
 			w = self.tile_xml.get_widget(key)
 			if w == None:
@@ -83,6 +91,14 @@
 			return self.xml.get_widget(key)
 
 
+	def _load_track(self, track):
+		self.step_current = -1
+		self.step_next = 0
+		self.step_track = track
+		self._load_tile_nr(self.step_next)
+		self.backtrack = []
+
+
 	def _load_tile(self, tile_name):
 		"""Loads a tile by it's name and integrates it in the wizard window"""
 		glade_name = "glade/%s.glade" % tile_name
@@ -91,11 +107,11 @@
 				glade_name = "glade/%s" % t["glade"]
 		self._clear_container(self.xml.get_widget("vbox_container"))
 		self.tile_xml = gtk.glade.XML(glade_name)
-		self.tile_handlers = self._get_event_handlers(tile_name)
-		self.tile_xml.signal_autoconnect(self.tile_handlers)
 		w = self.tile_xml.get_widget("vbox_container").get_children()[0]
 		w.reparent(self.xml.get_widget("vbox_container"))
 		self.xml.get_widget("vbox_container").resize_children()
+		self.tile_handlers = self._get_event_handlers(tile_name)
+		self.tile_xml.signal_autoconnect(self.tile_handlers)
 		if "on_load" in self.tile_handlers:
 			try:
 				if not self.tile_handlers["on_load"]():
@@ -224,11 +240,16 @@
 	def intro_on_next(self):
 		if self["radio_novice"].get_active():
 			logging.info("track=Novice")
+			self._load_track(self.Steps_Novice)
 			pass # The default track is Novice
 		elif self["radio_standard"].get_active():
 			print "standard"
 		elif self["radio_expert"].get_active():
 			print "expert"
+		elif self["radio_config"].get_active():
+			logging.info("track=config")
+			self._load_track(self.Steps_Config)
+			self.server.SetDestRoot("/")
 		self.trackdata = {}
 		return True
 
@@ -617,17 +638,21 @@
 			self.server.DismantleJob(self.trackdata["pkginstall_job"])
 			del self.trackdata["pkginstall_job"]
 			logging.info("PkgInstall finished")
-			self._load_tile("hostusername")
+			self["button_cancel"].set_sensitive(True)
+			self["button_previous"].set_sensitive(True)
+			self["button_next"].set_sensitive(True)
+			self._load_tile("hostroot")
 			return False
 		return True
 
 
 	def hostroot_on_load(self):
 		self._load_label(self["label2"], "hostroot.txt")
+		self["entry_hostname"].set_text(self.server.GetHostName())
 		return True
 
 
-	def on_button_generate_clicked(self, evt):
+	def hostroot_on_button_generate_password_clicked(self, evt):
 		seq = ""
 		for x in xrange(8):
 			seq += chr(random.randint(0, 255))
@@ -652,6 +677,12 @@
 
 	def createuser_on_load(self):
 		self._load_label(self["label2"], "createuser.txt")
+		shells = self.server.GetShells()
+		ls = gtk.ListStore(gobject.TYPE_STRING)
+		for sh in shells:
+			ls.append([sh])
+		self["combo_shell"].set_model(ls)
+		self["combo_shell"].set_active(1)
 		return True
 
 
@@ -660,10 +691,15 @@
 			self._show_message("Passwords do not match! Please enter the same password\nin the Password and Confirm password fields", "Password mismatch")
 			return False
 		username = self["entry_username"].get_text()
-		if username.find(" ") == -1:
+		if username.find(" ") != -1:
 			self._show_message("Invalid username. No whitespace, please.", "Error")
 			return False
-		code, result = self.server.AddUser(username, self["entry_user"].get_text(), self["entry_password"].get_text())
+		if self["cb_wheel"].get_active():
+			groups = ["wheel"]
+		else:
+			groups = []
+		shell = self["combo_shell"].get_active_text()
+		code, result = self.server.AddUser(username, self["entry_user"].get_text(), self["entry_password"].get_text(), shell, groups)
 		if code != 0:
 			self._show_message(result, "Error")
 			return False



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708222236.l7MMaFOf092820>