From owner-p4-projects@FreeBSD.ORG Sat Aug 18 03:52:36 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5D7F416A418; Sat, 18 Aug 2007 03:52:36 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1696816A469 for ; Sat, 18 Aug 2007 03:52:36 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 03F5813C458 for ; Sat, 18 Aug 2007 03:52:36 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7I3qZEF054545 for ; Sat, 18 Aug 2007 03:52:35 GMT (envelope-from andrew@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7I3qZ4a054542 for perforce@freebsd.org; Sat, 18 Aug 2007 03:52:35 GMT (envelope-from andrew@freebsd.org) Date: Sat, 18 Aug 2007 03:52:35 GMT Message-Id: <200708180352.l7I3qZ4a054542@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andrew@freebsd.org using -f From: Andrew Turner To: Perforce Change Reviews Cc: Subject: PERFORCE change 125286 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Aug 2007 03:52:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=125286 Change 125286 by andrew@andrew_hermies on 2007/08/18 03:52:19 Remove most of the menu as it was unused Add a dialog box to add new computers Add a menu item to remove computers from the gui Affected files ... .. //depot/projects/soc2007/andrew-update/frontend/facund-fe.glade#5 edit .. //depot/projects/soc2007/andrew-update/frontend/facund.py#10 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/__init__.py#7 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#12 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/gui/__init__.py#5 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/gui/computer_model.py#7 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/gui/main_window.py#11 edit .. //depot/projects/soc2007/andrew-update/frontend/facund/network/__init__.py#12 edit Differences ... ==== //depot/projects/soc2007/andrew-update/frontend/facund-fe.glade#5 (text+ko) ==== @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -23,7 +23,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-new @@ -32,40 +32,22 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-open - True - True - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-save + gtk-delete True True - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-save-as - True - True - - - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-quit @@ -77,87 +59,6 @@ - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - _Edit - True - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-cut - True - True - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-copy - True - True - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-paste - True - True - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-delete - True - True - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - _View - True - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - _Help - True - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-about - True - True - - - - - - False @@ -209,19 +110,27 @@ 5 5 - + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Connect + 0 + + + + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Remove + Disconnect 0 1 2 - 1 - 2 @@ -239,29 +148,21 @@ - + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Disconnect + Remove 0 1 2 + 1 + 2 - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Connect - 0 - - False @@ -339,4 +240,140 @@ + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 + 2 + 3 + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Computer's description +This is a Human redable +name for the computer + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 2 + 3 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Computer's name +leave blank for the +local computer + + + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Socket location +Leave blank for +the default socket + + + 2 + 3 + + + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_END + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-save + True + 0 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + 0 + + + 1 + + + + + False + GTK_PACK_END + + + + + ==== //depot/projects/soc2007/andrew-update/frontend/facund.py#10 (text+ko) ==== @@ -38,9 +38,18 @@ # fc.interact() if __name__ == "__main__": + computerList = facund.ComputerList() + computers = computerList.getComputerList() + computerModel = facund.gui.ComputerTreeModel() - localComputer = facund.Computer("Local computer", '/tmp/facund') - computerModel.addComputer(localComputer) + for i in range(len(computers)): + computer = facund.Computer(computers[i][0], computers[i][1], + computers[i][2]) + computerModel.addComputer(computer) + + # If we nee the computer list again we gan get it in the same way + del computers + del computerList updateModel = facund.gui.UpdateListModel() ==== //depot/projects/soc2007/andrew-update/frontend/facund/__init__.py#7 (text+ko) ==== @@ -26,6 +26,7 @@ from call import * from computer import * +from computer_list import * from controller import * from data import * ==== //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#12 (text+ko) ==== @@ -45,17 +45,18 @@ class Computer(threading.Thread): '''A class to describe each computer able to be connected to''' - def __init__(self, name, host): + def __init__(self, name, host, socket): threading.Thread.__init__(self) self.__name = name self.__host = host + self.__socket = socket self.__dirs = [] self.__connected = False self.__connection = None self.__commands = ['Avaliable', 'Installed'] def __str__(self): - return self.__name + ": " + self.__host + return self.__name + ": " + (self.__host or self.__socket) def addDir(self, dir): '''Adds a directory to the avaliable directories to update''' @@ -77,6 +78,9 @@ '''Returns the hostname/ip of the computer''' return self.__host + def getSocket(self): + return self.__socket + def getCommands(self, dir): return self.__commands @@ -156,7 +160,7 @@ try: self.__connection = \ - facund.network.Connection(self.__host) + facund.network.Connection(self.__host, self.__socket) # Start the communication thread self.start() @@ -173,7 +177,7 @@ for dir in dirs: self.addDir(dir.getData()) except socket.error: - print "Couldn't connect to " + self.__host + print "Couldn't connect to %s " % (self.__host or self.__socket) del self.__connection self.__connection = None ==== //depot/projects/soc2007/andrew-update/frontend/facund/gui/__init__.py#5 (text+ko) ==== @@ -25,5 +25,6 @@ # from computer_model import ComputerTreeModel +from connection_dialog import ConnectionDialog from main_window import MainWindow from update_model import UpdateListModel ==== //depot/projects/soc2007/andrew-update/frontend/facund/gui/computer_model.py#7 (text+ko) ==== @@ -75,15 +75,11 @@ return self.__computers[name] def removeComputer(self, computer): - '''Removes a computer from the computer tree. TODO: Implement''' - iter = self.get_iter_from_string(computer) - print iter - - def addBaseDir(self, computer, dir): - '''Adds a base directory to manage to a computer. TODO: Implement''' - pass - - def removeBaseDir(self, computer, dir): - '''Removes a base directory from a computer. TODO: Implement''' - pass + '''Removes a computer from the computer tree''' + computer_name = computer.getName() + if self.__computers.has_key(computer_name) and \ + self.__iterators.has_key(computer): + del self.__computers[computer_name] + iter = self.__iterators[computer] + self.remove(iter) ==== //depot/projects/soc2007/andrew-update/frontend/facund/gui/main_window.py#11 (text+ko) ==== @@ -24,6 +24,7 @@ # SUCH DAMAGE. # +import facund import gtk import gtk.gdk import gtk.glade @@ -37,7 +38,79 @@ self.__xml = gtk.glade.XML(glade_file) self.__widget = self.__xml.get_widget('facundWindow') - self.__widget.connect('destroy', lambda *w: gtk.main_quit()) + self.__widget.connect('destroy', self.onQuit) + + # Open the new computer window on File > New + menuItem = self.__xml.get_widget('newConnection') + menuItem.connect('activate', self.newConnection) + + # Remove the selected computer on File > Delete + menuItem = self.__xml.get_widget('delConnection') + menuItem.connect('activate', self.delConnection) + + # Attach the quit signal to File > Quit + menuItem = self.__xml.get_widget('progQuit') + menuItem.connect('activate', self.onQuit) + + self.__newConnectionDialog = None + + # Connect the signals to the new connection dialog box + button = self.__xml.get_widget('newConnectionCancel') + button.connect('clicked', self.connectionCancel) + + button = self.__xml.get_widget('newConnectionSave') + button.connect('clicked', self.connectionSave) + + def onQuit(self, data): + gtk.main_quit() + + def newConnection(self, data): + widget = self.__xml.get_widget('newConnectionDialog') + self.__newConnectionDialog = widget + self.__newConnectionDialog.show() + + def delConnection(self, data): + # Make sure the we have disconnected + self.onDisconnectClick(data) + computer = self.__controller.getCurrentComputer() + computerList = facund.ComputerList() + computerList.delComputer(computer) + self.__computerTreeModel.removeComputer(computer) + del computerList + + def connectionCancel(self, data): + self.__newConnectionDialog.hide() + self.__newConnectionDialog = None + + self.__xml.get_widget('computerNameEntry').set_text('') + self.__xml.get_widget('computerEntry').set_text('') + self.__xml.get_widget('computerEntry').set_text('') + + def connectionSave(self, data): + item = self.__xml.get_widget('computerEntry') + server = item.get_text() + if server is '': + server = None + + item = self.__xml.get_widget('socketEntry') + socket = item.get_text() + if socket is '': + socket = '/tmp/facund' + + item = self.__xml.get_widget('computerNameEntry') + name = item.get_text() + if name is '': + name = server or 'Local Computer' + + computer = facund.Computer(name, server, socket) + computerList = facund.ComputerList() + computerList.addComputer(computer) + del computerList + self.__computerTreeModel.addComputer(computer) + + # Use the connectionCancel handler as it + # closes the dialog and cleans up the fields + self.connectionCancel(data) def setController(self, controller): self.__controller = controller ==== //depot/projects/soc2007/andrew-update/frontend/facund/network/__init__.py#12 (text+ko) ==== @@ -33,10 +33,10 @@ import xml.sax.handler class PipeComms: - def __init__(self, server): - self.popen = subprocess.Popen(["/usr/bin/ssh", server, "/usr/bin/nc -oU /tmp/facund"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) - print self.popen.stdout + def __init__(self, server, socket): + self.popen = subprocess.Popen(["/usr/bin/ssh", server, "/usr/bin/nc -oU %s" % socket], stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.stdout = self.popen.stdout.fileno() + print poll() def read(self, len): return os.read(self.stdout, len) @@ -57,7 +57,7 @@ class Connection(xml.sax.handler.ContentHandler): '''A class that works as a client with the Facund XML IPC''' - def __init__(self, server): + def __init__(self, server, socket): self.isReady = False self.connectionType = "unix" @@ -65,10 +65,10 @@ self.__calls = {} self.bufSize = 1024 - if self.connectionType == "unix": - self.__connection = SocketComms(server) - elif self.connectionType == "pipe": - self.__connection = PipeComms(server) + if server is None: + self.__connection = SocketComms(socket) + else: + self.__connection = PipeComms(server, socket) self.send("")