Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2005, 2006 Joint Institute for VLBI in Europe 2 # 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 2 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 13 # You should have received a copy of the GNU General Public License 14 # along with this program; if not, write to the Free Software 15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 17 """ 18 19 This module provides a simple XML-RPC server that can run classic AIPS 20 tasks and provide verb-like access to AIPS data on a machine. 21 22 """ 23 24 import sys 25 import xmlrpclib 26 # Stolen shamelessly from Thomas Bellman, on the Python-list, June 2006. 27 # WARNING: Dirty hack below. 28 # Replace the dumps() function in xmlrpclib with one that by default 29 # handles None, so SimpleXMLRPCServer can return None. 36 xmlrpclib.dumps = _xmldumps(xmlrpclib.dumps) 37 38 from SimpleXMLRPCServer import SimpleXMLRPCServer 39 from SocketServer import ThreadingMixIn 40 41 # Global AIPS defaults. 42 import AIPS 43 44 # Import AIPS modules. 45 import Proxy.AIPSTask 46 import Proxy.AIPSData 47 5174 75 # This bit of unpleasantness comes about from the ugly hack that is the 76 # _xmldumps class above. Python 2.5 supports the "allow_none" attribute for 77 # SimpleXMLRPCServer objects, whereas Python 2.1 t/m 2.4 require the 78 # _xmldumps redefinition above. However, these versions will break if 79 # "allow_none" is passed to the constructor, and the _xmldumps hack doesn't 80 # work with Python 2.5. So... 81 if sys.hexversion >= 0x020500f0 : 82 server = XMLRPCServer(('', 8000), allow_none = 1) 83 else : 84 server = XMLRPCServer(('', 8000)) 85 86 if __name__ == "__main__" : 87 server.register_instance(ServerFuncs()) 88 server.serve_forever() 8954 self.AIPSTask = Proxy.AIPSTask.AIPSTask() 55 self.AIPSUVData = Proxy.AIPSData.AIPSUVData() 56 self.AIPSImage = Proxy.AIPSData.AIPSImage() 57 self.AIPSCat = Proxy.AIPSData.AIPSCat() 58 return5961 # For security reasons, SimpleXMLRPCServer in Python 62 # 2.3.5/2.4.1, no longer resolves names with a dot in it. Se 63 # here we explicitly accept names starting with 'AIPS' and 64 # containing a single dot; that should be safe enough. 65 if name.startswith('AIPS') and name.count('.') == 1: 66 name = name.split('.') 67 inst = getattr(self, name[0]) 68 method = getattr(inst, name[1]) 69 return method(*args) 70 msg = "object has no attribute '%s'" % name 71 raise AttributeError, msg72 73 pass # class ServerFuncs
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Nov 28 17:13:11 2008 | http://epydoc.sourceforge.net |