<div dir="ltr">Para los que quereis liaros con sockets, aqui teneis un wrapper, que funciona fino para mandar y recibir comandos del servidor del juego:<div><br></div><div><pre class="" style="line-height:16px;word-wrap:break-word;width:738px;margin-top:0px;margin-bottom:0px;padding:0px;color:rgb(0,0,0)">
<div class="" id="file-game-2-py-LC24"><font face="courier new, monospace" size="1"><span class="" style="font-weight:bold">class</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">Connection</span><span class="">(</span><span class="" style="color:rgb(0,134,179)">object</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC25"><font face="courier new, monospace" size="1">    <span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">__init__</span><span class="">(</span><span class="" style="color:rgb(153,153,153)">self</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">host</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">port</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC26"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">host</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(51,51,51)">host</span></font></div>
<div class="" id="file-game-2-py-LC27"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">port</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(51,51,51)">port</span></font></div>
<div class="" id="file-game-2-py-LC28"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">buff</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(51,51,51)">b</span><span class="" style="color:rgb(221,17,68)">""</span></font></div>
<div class="" id="file-game-2-py-LC30"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">s</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(51,51,51)">socket</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">socket</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">socket</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">AF_INET</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">socket</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">SOCK_STREAM</span><span class="">)</span></font></div>
<div class="" id="file-game-2-py-LC31"><font face="courier new, monospace" size="1"> </font></div><div class="" id="file-game-2-py-LC32"><font face="courier new, monospace" size="1">    <span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">connect</span><span class="">(</span><span class="" style="color:rgb(153,153,153)">self</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC33"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">s</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">connect</span><span class="">((</span><span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">host</span><span class="">,</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">port</span><span class="">))</span></font></div>
<div class="" id="file-game-2-py-LC34"><font face="courier new, monospace" size="1"> </font></div><div class="" id="file-game-2-py-LC35"><font face="courier new, monospace" size="1">    <span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">send_command</span><span class="">(</span><span class="" style="color:rgb(153,153,153)">self</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">data</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC36"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">if</span> <span class="" style="color:rgb(0,134,179)">isinstance</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">data</span><span class="">,</span> <span class="" style="color:rgb(0,134,179)">bytes</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC37"><font face="courier new, monospace" size="1">            <span class="" style="font-weight:bold">raise</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">RuntimeError</span><span class="">()</span></font></div>
<div class="" id="file-game-2-py-LC38"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">return</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">send_raw</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">"{0}</span><span class="" style="color:rgb(221,17,68)">\r\n</span><span class="" style="color:rgb(221,17,68)">"</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">format</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">data</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">strip</span><span class="">()))</span></font></div>
<div class="" id="file-game-2-py-LC39"><font face="courier new, monospace" size="1"> </font></div><div class="" id="file-game-2-py-LC40"><font face="courier new, monospace" size="1">    <span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">send_raw</span><span class="">(</span><span class="" style="color:rgb(153,153,153)">self</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">data</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC41"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">if</span> <span class="" style="color:rgb(0,134,179)">isinstance</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">data</span><span class="">,</span> <span class="" style="color:rgb(0,134,179)">str</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC42"><font face="courier new, monospace" size="1">            <span class="" style="color:rgb(51,51,51)">data</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(51,51,51)">data</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">encode</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">'utf-8'</span><span class="">)</span></font></div>
<div class="" id="file-game-2-py-LC43"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">return</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">s</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">send</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">data</span><span class="">)</span></font></div>
<div class="" id="file-game-2-py-LC44"><font face="courier new, monospace" size="1"> </font></div><div class="" id="file-game-2-py-LC45"><font face="courier new, monospace" size="1">    <span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">recv_command</span><span class="">(</span><span class="" style="color:rgb(153,153,153)">self</span><span class="">):</span></font></div>
<div class="" id="file-game-2-py-LC46"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">while</span> <span class="" style="color:rgb(51,51,51)">b</span><span class="" style="color:rgb(221,17,68)">"</span><span class="" style="color:rgb(221,17,68)">\n</span><span class="" style="color:rgb(221,17,68)">"</span> <span class="" style="font-weight:bold">not</span> <span class="" style="font-weight:bold">in</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">buff</span><span class="">:</span></font></div>
<div class="" id="file-game-2-py-LC47"><font face="courier new, monospace" size="1">            <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">buff</span> <span class="" style="font-weight:bold">+=</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">s</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">recv</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">BUFFER_SIZE</span><span class="">)</span></font></div>
<div class="" id="file-game-2-py-LC48"><font face="courier new, monospace" size="1"> </font></div><div class="" id="file-game-2-py-LC49"><font face="courier new, monospace" size="1">        <span class="" style="color:rgb(51,51,51)">data</span><span class="">,</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">buff</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(153,153,153)">self</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">buff</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">split</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">b</span><span class="" style="color:rgb(221,17,68)">"</span><span class="" style="color:rgb(221,17,68)">\n</span><span class="" style="color:rgb(221,17,68)">"</span><span class="">,</span> <span class="" style="color:rgb(0,153,153)">1</span><span class="">)</span></font></div>
<div class="" id="file-game-2-py-LC50"><font face="courier new, monospace" size="1">        <span class="" style="font-weight:bold">return</span> <span class="" style="color:rgb(51,51,51)">data</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">decode</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">'utf-8'</span><span class="">)</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(51,51,51)">strip</span><span class="">()</span></font></div>
<div class="" id="file-game-2-py-LC50"><font face="courier new, monospace" size="1"><span class=""><br></span></font></div><div class="" id="file-game-2-py-LC50"><font face="courier new, monospace" size="1"><span class=""><br>
</span></font></div><div class="" id="file-game-2-py-LC50"><font face="courier new, monospace" size="1"><span class="">;)</span></font></div></pre></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">El 16 de abril de 2013 15:06, Pablo Lobariñas <span dir="ltr"><<a href="mailto:plobarinas@jcea.es" target="_blank">plobarinas@jcea.es</a>></span> escribió:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="im">
    <br>
    -----BEGIN PGP SIGNED MESSAGE-----<br>
    Hash: SHA1<br>
    <br></div>
    He actualizado el post, disculpad el despiste.<br>
    <br>
    El 16/04/13 14:25, Jesus Cea escribió:<br>
    <span style="white-space:pre-wrap"><div class="im">> On 16/04/13 13:50, Kiko wrote:<br>
      ><br>
      > > El otro día, uno de los requisitos era PIL/pillow y no
      se había<br>
      > > mencionado antes. Se mencionó PIP, que no usamos para
      nada, supongo<br>
      > > que fue un typo.<br>
      ><br>
      > PIP es necesario para instalar más dependencias, si fuesen
      necesario.<br>
      > Gracias a ello, se pudo instalar "pillow", que fue una
      dependencia<br>
      > declarada durante el evento, no antes.<br>
      ><br>
      > Así que yo recomiendo venir con PIP instalado, para poder
      instalar más<br>
      > cosas rápido si fuese necesario.<br>
      ><br></div><div class="im">
      > -- <br>
      > Jesús Cea Avión                         _/_/     
      _/_/_/        _/_/_/<br>
      > <a href="mailto:jcea@jcea.es" target="_blank">jcea@jcea.es</a> - <a href="http://www.jcea.es/" target="_blank">http://www.jcea.es/</a>     _/_/    _/_/  _/_/   
      _/_/  _/_/<br>
      > Twitter: @jcea                        _/_/    _/_/         
      _/_/_/_/_/<br>
      > jabber / <a>xmpp:jcea@jabber.org</a>  _/_/  _/_/    _/_/         
      _/_/  _/_/<br>
      > "Things are not so easy"      _/_/  _/_/    _/_/  _/_/   
      _/_/  _/_/<br>
      > "My name is Dump, Core Dump"   _/_/_/        _/_/_/     
      _/_/  _/_/<br>
      > "El amor es poner tu felicidad en la felicidad de otro" -
      Leibniz<br></div><div class="im">
      > _______________________________________________<br>
      > Madrid mailing list<br>
      > <a href="mailto:Madrid@lists.es.python.org" target="_blank">Madrid@lists.es.python.org</a><br>
      > <a href="https://lists.es.python.org/listinfo/madrid" target="_blank">https://lists.es.python.org/listinfo/madrid</a></div></span><br>
    <br>
    -----BEGIN PGP SIGNATURE-----<div class="im"><br>
    Version: GnuPG v1.4.11 (Darwin)<br>
    Comment: GPGTools - <a href="http://gpgtools.org" target="_blank">http://gpgtools.org</a><br>
    <br></div>
    iEYEARECAAYFAlFtTMwACgkQnPFBatEMYOdblACgwy1sAdgIRqKYpFKh19uTEl1Y<br>
    scIAn3CI24KRvZpob7Fbu4wdC2RjWPjS<br>
    =7AFs<br>
    -----END PGP SIGNATURE-----<br>
    <br>
  </div>

<br>_______________________________________________<br>
Madrid mailing list<br>
<a href="mailto:Madrid@lists.es.python.org">Madrid@lists.es.python.org</a><br>
<a href="https://lists.es.python.org/listinfo/madrid" target="_blank">https://lists.es.python.org/listinfo/madrid</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Andrey Antukh - Андрей Антух - <<a href="mailto:niwi@niwi.be" target="_blank">niwi@niwi.be</a>><br>
<a href="http://www.niwi.be/about.html" target="_blank">http://www.niwi.be/about.html</a><br><a href="http://www.kaleidos.net/A5694F/" target="_blank">http://www.kaleidos.net/A5694F/</a><br><br>"Linux is for people who hate Windows, BSD is for people who love UNIX"<br>
"Social Engineer -> Because there is no patch for human stupidity"
</div>