288
|
1 from twisted.web import soap
|
|
2 from twisted.internet import reactor
|
|
3 import sys,os
|
|
4 class Inkscape(object):
|
|
5 def __init__(self):
|
|
6 self.server = soap.Proxy('http://localhost:8080')
|
|
7 def PUBLISH(self):
|
|
8 return self.server.callRemote('PUBLISH')
|
|
9 def SCENE(self,n):
|
|
10 return self.server.callRemote('SCENE',n)
|
|
11 def START(self):
|
|
12 return self.server.callRemote('START')
|
|
13 def INSERTKEY(self,layer,n):
|
|
14 return self.server.callRemote('INSERTKEY',layer,n)
|
|
15 def EXTENDSCENE(self,layer,n):
|
|
16 return self.server.callRemote('EXTENDSCENE',layer,n)
|
|
17 def GETDOC(self):
|
|
18 return self.server.callRemote('GETDOC')
|
|
19
|
|
20
|
|
21 def quitSession(result):
|
|
22 print [result]
|
|
23 reactor.stop()
|
|
24 def quitError(result):
|
|
25 print "Error"
|
|
26 print[result]
|
|
27 reactor.stop()
|
|
28
|
|
29
|
|
30 ink = Inkscape()
|
|
31
|
|
32 if sys.argv[1] == 'PUBLISH':
|
|
33 d = ink.PUBLISH()
|
|
34 elif sys.argv[1] == 'SCENE':
|
|
35 d = ink.SCENE(sys.argv[2])
|
|
36 elif sys.argv[1] == 'START':
|
|
37 d = ink.START()
|
|
38 elif sys.argv[1] == 'INSERTKEY':
|
|
39 d = ink.INSERTKEY(sys.argv[2], sys.argv[3])
|
|
40 elif sys.argv[1] == 'GETDOC':
|
|
41 d = ink.GETDOC()
|
|
42 elif sys.argv[1] == 'EXTENDSCENE':
|
|
43 d = ink.EXTENDSCENE(sys.argv[2],sys.argv[3])
|
|
44 else:
|
|
45 print 'Unknown command %s' % sys.argv[1]
|
|
46 sys.exit(-1)
|
|
47 d.addCallback(quitSession)
|
|
48 d.addErrback(quitError)
|
|
49
|
|
50
|
|
51 reactor.run()
|