Date: Sun, 8 Jul 2007 06:24:49 GMT From: Andrew Turner <andrew@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 123090 for review Message-ID: <200707080624.l686OnPk040797@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123090 Change 123090 by andrew@andrew_hermies on 2007/07/08 06:24:02 Add a Directory class to define a base directory within a computer Allow calls to be sent to the back end Fix a typo Affected files ... .. //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#3 edit Differences ... ==== //depot/projects/soc2007/andrew-update/frontend/facund/computer.py#3 (text+ko) ==== @@ -28,6 +28,20 @@ import facund.network import threading +class Directory: + def __init__(self, name, computer): + self.__name = name + self.__computer = computer + + def getName(self): + return self.__name + + def getCommands(self): + return self.__computer.getCommands(self.__name) + + def runCommand(self, position): + return self.__computer.runCommand(position, self.__name) + class Computer(threading.Thread): '''A class to describe each computer able to be connected to''' def __init__(self, name, host): @@ -37,13 +51,14 @@ self.__dirs = [] self.__connected = False self.__connection = None + self.__commands = ['Avaliable', 'Downloaded', 'Installed'] def __str__(self): return self.__name + ": " + self.__host def addDir(self, dir): '''Adds a directory to the avaliable directories to update''' - self.__dirs.append(dir) + self.__dirs.append(facund.Directory(dir, self)) def getConnectionStatus(self): '''Returns the connection state''' @@ -54,13 +69,35 @@ return self.__dirs def getName(self): - '''Returns the Human redable name for the computer''' + '''Returns the Human readable name for the computer''' return self.__name def getHost(self): '''Returns the hostname/ip of the computer''' return self.__host + def getCommands(self, dir): + return self.__commands + + def runCommand(self, command, dir = None): + print self.__commands[command] + if self.__commands[command] == 'Avaliable': + return self.getUpdateList(dir) + else: + print 'TODO: Handle this command (%d)' % (command,); + + def getUpdateList(self, dir = None): + if dir is None: + for dir in self.__dirs: + args = None + else: + args = facund.Array() + args.append(facund.String("base")) + args.append(facund.String(dir)) + + call = facund.Call("list_updates", args) + self.__connection.doCall(call) + def connect(self): '''Connects to the remote computer''' if self.__connection is not None:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707080624.l686OnPk040797>