PERFORCE change 124292 for review

Andrew Turner andrew at FreeBSD.org
Sun Jul 29 03:26:37 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=124292

Change 124292 by andrew at andrew_hermies on 2007/07/29 03:25:55

	Attach the install/remove buttons up to a call to install_patches/rollback_patches

Affected files ...

.. //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#7 edit
.. //depot/projects/soc2007/andrew-update/frontend/facund/controller.py#4 edit
.. //depot/projects/soc2007/andrew-update/frontend/facund/gui/main_window.py#8 edit

Differences ...

==== //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#7 (text+ko) ====

@@ -27,6 +27,7 @@
 import socket
 import facund.network
 import threading
+import types
 
 class Directory:
 	def __init__(self, name, computer):
@@ -88,6 +89,41 @@
 		else:
 			print 'TODO: Handle this command (%d)' % (command,);
 
+	def buildInstallArg(self, location, patches):
+		arg = facund.Array()
+		arg.append(facund.String(location))
+
+		if isinstance(patches, types.StringTypes):
+			arg.append(facund.String(patches))
+		elif isinstance(patches, types.ListType):
+			items = facund.Array()
+			for patch in patches:
+				items.append(facund.String(patch))
+			arg.append(items)
+		return arg
+
+	def installUpdates(self, isInstall, installTypes):
+		args = facund.Array()
+		if isinstance(installTypes, types.TupleType):
+			args.append(self.buildInstallArg(installTypes[0],
+			    installTypes[1]))
+		elif isinstance(installTypes, types.ListType):
+			for item in installTypes:
+				args.append(self.buildInstallArg(item[0],
+				    item[1]))
+
+		if isInstall:
+			callType = "install_patches"
+		else:
+			callType = "rollback_patches"
+		call = facund.Call(callType, args)
+		self.__connection.doCall(call)
+		# Wait for the response
+		call.acquireLock()
+		call.releaseLock()
+		print call.getResponse()
+		
+
 	def getUpdateList(self, dir = None):
 		if dir is None:
 			for dir in self.__dirs:

==== //depot/projects/soc2007/andrew-update/frontend/facund/controller.py#4 (text+ko) ====

@@ -75,3 +75,11 @@
 
 	def getCurrentComputer(self):
 		return self.__currentComputer
+
+	def installUpdates(self, updates):
+		computer = self.getCurrentComputer()
+		computer.installUpdates(True, updates)
+
+	def removeUpdates(self, updates):
+		computer = self.getCurrentComputer()
+		computer.installUpdates(False, updates)

==== //depot/projects/soc2007/andrew-update/frontend/facund/gui/main_window.py#8 (text+ko) ====

@@ -42,6 +42,11 @@
 	def setController(self, controller):
 		self.__controller = controller
 
+		installButton = self.__xml.get_widget('installButton')
+		installButton.connect('clicked', self.onInstallClick)
+		removeButton = self.__xml.get_widget('deinstallButton')
+		removeButton.connect('clicked', self.onRemoveClick)
+
 	def setUpdateViewModel(self, model):
 		'''Sets the model to use to for the computer tree'''
 		self.__updateViewModel = model
@@ -85,7 +90,7 @@
 
 	def onConnectClick(self, widget):
 		'''Signal handler for the connect button'''
-		treeView = self.__xml.get_widget('computerView')
+		#treeView = self.__xml.get_widget('computerView')
 		computer = self.__controller.getCurrentComputer()
 		computer.connect()
 		self.setConnected(computer.getConnectionStatus())
@@ -95,7 +100,7 @@
 
 	def onDisconnectClick(self, widget):
 		'''Signal handler for the connect button'''
-		treeView = self.__xml.get_widget('computerView')
+		#treeView = self.__xml.get_widget('computerView')
 		computer = self.__controller.getCurrentComputer()
 		computer.disconnect()
 		self.setConnected(computer.getConnectionStatus())
@@ -104,6 +109,12 @@
 		# Disable the install/remove buttons
 		self.setInstallable(False, False)
 
+	def onInstallClick(self, widget):
+		self.__controller.installUpdates(('base', 'all'))
+
+	def onRemoveClick(self, widget):
+		self.__controller.installUpdates(('base', 'all'))
+
 	def onSelectComputer(self, widget):
 		'''Signal handler for when the selected item is changed'''
 		cursor = widget.get_cursor()


More information about the p4-projects mailing list