Thread: PHP to Python?
View Single Post
Old Sep 21st, 2007, 9:35 PM   #1
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Smile PHP to Python?

Is there anyone that is able to convert this small php snippet
 fputs($sock,"\\status\\"); $gotfinal=False; $data="";
 socket_set_timeout($sock,0,200000);
 $starttime=Time();
 while(!($gotfinal==True||feof($sock))) {
  if(($buf=fgetc($sock))==FALSE) usleep(100);
  $data.=$buf;
  if(strpos($data,"final\\")!=False) $gotfinal=True;
  if((Time() - $starttime)>2) { 
    $gotfinal=True;
   }
 }
 fclose($sock);
 $chunks=split('[\]',$data);

to Python??
I've got

    global chunks
    s.send("\\status\\")
    final = False
    while(final != True):
        data = s.recv(1024)
        if (len(data) <= 0): sleep(1); data = data, s.recvfrom(1024)
        if(data.find("final\\") != False): final = True
    chunks = data.split('\\')

But as you'll notice tis is not really a good match !!
Thanks for anyone that is able to help!
It would be greatly appriciated!! :banana:
__________________
while me is alive:
	make(life,simple)
SaturN is offline   Reply With Quote