Mercurial > MadButterfly
comparison inkscape/firefox/helper_mb.py @ 339:63aaf96209cd
* Move location of files so that we can produce XPI file from them.
* Add the produce to compile the inkscape for madbutterfly
* Add makefile to produce inkscape and madbuilder.xpi
author | wycc |
---|---|
date | Sun, 08 Mar 2009 10:05:22 +0800 |
parents | d5327265da1e |
children | 3d03451be435 |
comparison
equal
deleted
inserted
replaced
336:995eb2c1a1aa | 339:63aaf96209cd |
---|---|
69 | 69 |
70 d = defer.Deferred() | 70 d = defer.Deferred() |
71 self.client.SCENE(n).addCallback(self.generic_return,d) | 71 self.client.SCENE(n).addCallback(self.generic_return,d) |
72 return d | 72 return d |
73 def generic_return(self,result,d): | 73 def generic_return(self,result,d): |
74 print "Get result:" | |
74 print [result] | 75 print [result] |
75 d.callback(result) | 76 d.callback(result) |
76 def generic_error(self,result,d): | 77 def generic_error(self,result,d): |
78 print "Error:" | |
77 print [result] | 79 print [result] |
78 d.errback(result) | 80 d.errback(result) |
79 def soap_START(self): | 81 def soap_START(self): |
80 if self.client == None: | 82 if self.client == None: |
81 os.kill(self.pid,12) | 83 os.kill(self.pid,12) |
82 time.sleep(1) | 84 time.sleep(1) |
83 self.client = Client() | 85 self.client = Client() |
84 return "OK" | 86 return "OK" |
87 def getdoc_error(self,result,d): | |
88 try: | |
89 print "reconnect" | |
90 time.sleep(1) | |
91 os.kill(self.pid,12) | |
92 op = self.client.GETDOC() | |
93 op.addCallback(self.generic_return,d) | |
94 op.addErrback(self.getdoc_error,d) | |
95 except: | |
96 traceback.print_exc() | |
85 def soap_GETDOC(self): | 97 def soap_GETDOC(self): |
86 try: | 98 try: |
87 print "xxxxx" | 99 print "xxxxx" |
88 if self.client == None: | 100 if self.client == None: |
89 os.kill(self.pid,12) | 101 while os.kill(self.pid,12)<0: |
90 time.sleep(1) | 102 time.sleep(1) |
103 | |
91 self.client = Client() | 104 self.client = Client() |
92 d = defer.Deferred() | 105 d = defer.Deferred() |
93 self.client.GETDOC().addCallback(self.generic_return,d) | 106 op = self.client.GETDOC() |
107 op.addCallback(self.generic_return,d) | |
108 op.addErrback(self.getdoc_error,d) | |
94 print "yyy" | 109 print "yyy" |
95 return d | 110 return d |
96 except: | 111 except: |
97 traceback.print_exc() | 112 traceback.print_exc() |
98 | 113 |
107 def SCENE(self,n): | 122 def SCENE(self,n): |
108 return self.proxy.callRemote('SCENE',n) | 123 return self.proxy.callRemote('SCENE',n) |
109 def INSERTKEY(self,layer,n): | 124 def INSERTKEY(self,layer,n): |
110 return self.proxy.callRemote('INSERTKEY',layer,n) | 125 return self.proxy.callRemote('INSERTKEY',layer,n) |
111 def GETDOC(self): | 126 def GETDOC(self): |
112 return self.proxy.callRemote('GETDOC') | 127 doc = self.proxy.callRemote('GETDOC') |
128 return doc | |
113 def EXTENDSCENE(self,layer,n): | 129 def EXTENDSCENE(self,layer,n): |
114 return self.proxy.callRemote('EXTENDSCENE',layer,n) | 130 return self.proxy.callRemote('EXTENDSCENE',layer,n) |
115 def DELETESCENE(self,layer,n): | 131 def DELETESCENE(self,layer,n): |
116 return self.proxy.callRemote('DELETESCENE',layer,n) | 132 return self.proxy.callRemote('DELETESCENE',layer,n) |
117 | 133 |
118 os.system("killall -9 inkscape-mb") | 134 os.system("killall -9 inkscape-mb") |
135 try: | |
136 f = open("/tmp/madbuilder.pid","r") | |
137 pid = int(f.read()) | |
138 f.close() | |
139 os.system("kill -9 %d" % pid) | |
140 f = open("/tmp/madbuilder.pid","w") | |
141 f.write("%d\n" % os.getpid()) | |
142 f.close() | |
143 except: | |
144 traceback.print_exc() | |
145 | |
119 pid = os.fork() | 146 pid = os.fork() |
120 if pid==0: | 147 if pid==0: |
121 os.execvp("inkscape-mb",["inkscape-mb","/tmp/scene.mbsvg"]) | 148 os.execvp("inkscape-mb",["inkscape-mb","/tmp/scene.mbsvg"]) |
122 s = Server() | 149 s = Server() |
123 s.client = None | 150 s.client = None |
124 s.pid = pid | 151 s.pid = pid |
125 site = server.Site(s) | 152 site = server.Site(s) |
153 # Sleep for two seconds to wait for the inkscape become ready. It seems that our inkscape modification has | |
154 # semaphore issue so that it will be blocked if we connect to it in early stage. We need to check it and | |
155 # remove the following wait in the future. | |
126 reactor.listenTCP(19192,site) | 156 reactor.listenTCP(19192,site) |
157 time.sleep(5) | |
127 reactor.run() | 158 reactor.run() |
128 | 159 |
129 | 160 |