<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>Are you getting data to send? Does the loop stop?<br><br></div>Please give us the context (what is this self._client?).<br><br></div>Thanks,<br></div>Sam<br><br><br>
</div>P.S. Don't use `while quit_loop:`, use `while True` and `break` to quit the loop<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 16, 2014 at 5:08 PM, Puneet Kaur <span dir="ltr"><<a href="mailto:puneet.gkaur@gmail.com" target="_blank">puneet.gkaur@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><b>Hey,</b><div><b><br></b></div><div><b>I am working on camera plugin for sugar cordova.</b></div><div>
<b><br></b></div><div><b>I used pygame to click the user's photograph by the following code : </b></div>
<div><br></div><div><div><font color="#990000"><br></font></div><div><font color="#990000"> def camera(self,request):</font></div><div><font color="#990000"> os.environ['SDL_VIDEO_CENTERED'] = '1'</font></div>
<div><font color="#990000"> pygame.init()</font></div><div><font color="#990000"><span style="white-space:pre-wrap"> </span>pygame.camera.init()</font></div><div><font color="#990000"> screen=pygame.display.set_mode((640,480),pygame.NOFRAME )</font></div>
<div><font color="#990000"> <span style="white-space:pre-wrap"> </span>camlist = pygame.camera.list_cameras()</font></div><div><font color="#990000"> <span style="white-space:pre-wrap"> </span>if camlist:</font></div>
<div><font color="#990000"> cam = pygame.camera.Camera(camlist[0],(640,480))</font></div><div><font color="#990000"><span style="white-space:pre-wrap"> </span>cam.start()</font></div><div><font color="#990000"> quit_loop=0</font></div>
<div><font color="#990000"> base64data=None</font></div><div><font color="#990000"> while quit_loop == 0:</font></div><div><font color="#990000"><span style="white-space:pre-wrap"> </span> cam_image=cam.get_image()</font></div>
<div><font color="#990000"><span style="white-space:pre-wrap"> </span> screen.blit(cam_image,(0,0))</font></div><div><font color="#990000"><span style="white-space:pre-wrap"> </span> pygame.display.update()</font></div>
<div><font color="#990000"><span style="white-space:pre-wrap"> </span> for event in pygame.event.get():</font></div><div><font color="#990000"><span style="white-space:pre-wrap"> </span>if event.type == MOUSEBUTTONDOWN:</font></div>
<div><font color="#990000"> data = pygame.image.tostring(screen,"RGBA")</font></div><div><font color="#990000"> base64data = base64.b64encode(data)</font></div><div><font color="#990000"> #logging.error("base64 :\n %s",base64data)</font></div>
<div><font color="#990000"><span style="white-space:pre-wrap"> </span> </font><span style="color:rgb(153,0,0)">cam.stop()</span></div><div><font color="#990000"> pygame.display.quit()</font></div>
<div><font color="#990000"> quit_loop=1</font></div><div><font color="#990000"> logging.error("got base64 image")</font></div><div><font color="#990000"> self._client.send_result(request,base64data)</font></div>
<div><font color="#990000"> </font></div></div><div><br></div><div><br></div><div><b><br></b></div><div><b>The issue is that I am not able to send data back to the javascript side from python side.</b></div>
<div><b><br></b></div><div><b>I am attaching shell.log along if anyone wishes to have a look over it.</b></div><div><br></div><div><b>would be nice if someone can help me know why am I not able to send the data to javascript side.</b></div>
<div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div>Regards,</div><div>Puneet</div><div><b><br></b></div><div><b> </b></div>
</div>
<br>_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br></blockquote></div><br></div>