1
2
3
4
5
6
7 import xmlrpclib
8 import xml.sax.saxutils
9 import urllib
10
11 DECODE={
12 '"':'\"',
13 ' ':'',
14 ' ':'\n',
15 '	':'\t',
16 '/':'/',
17 }
18
19 DEFAULT_SERVER='http://127.0.0.1'
20 DEFAULT_PORT='9112'
21
23 "This class implements an XML RPC Client"
25 """
26 The constructor establish a connection to the given server.
27
28 @type url: string
29 @param url: the address of the XML RPC host. The port must be specified as well. If nothing is specified the connection is made to localhost on the Supremica default port 9112.
30 @return: void
31 """
32 self.__server=xmlrpclib.Server(url)
33
35 """
36 This method upload to the connected server the given XML file.
37
38 @type filename: string
39 @param filename: the filename to upload to the server
40 @return: void
41 """
42 f=open(filename, 'r')
43 self.__server.addAutomata(str(f.read()))
44 f.close()
45
47 """
48 This method download to the given file the automata present to the connected server.
49
50 @type filename: string
51 @param filename: the filename where to download the automata from the server
52 @return: void
53 """
54 f=open(filename,'w')
55
56 v=[]
57 for x in self.__server.getAutomataIdentities():
58 v.append(x.strip('\''))
59
60 f.write(xml.sax.saxutils.unescape(self.__server.getAutomata(v),DECODE))
61 f.close()
62
64 """
65 This method download to the given file the given automaton present to the connected server.
66
67 @type filename: string
68 @param filename: the filename where to download the automaton from the server
69 @type automaton: string
70 @param automaton: the name of the automaton to download
71 @return: void
72 """
73 f=open(filename,'w')
74 f.write(xml.sax.saxutils.unescape(self.__server.getAutomaton(automaton.strip('\'')),DECODE))
75 f.close()
76