
ic           @   s-  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z e j j e j d  d Z	 e j j e j d  d Z
 e e d  Z e Z y) e j e j d d d g  \ Z Z Wn1 e j k
 r e j j d  e j d  n Xe d	 k rg  e D] Z e d d
 k re ^ qZ e j   e re d e d e  Z e d e d e  Z e e j j e d d d  d  Z e j e  e j   e e j j e d d d  d  Z e j e  e j   e j d  n  n  d d l  Z  d d l! Z! d d l Z d d l" Z" d d l# Z# e j$ j d  d d k rQd d l% Z& n d d l& Z& d d l' Z( d d l  Z  d d l) Z) d d l* Z* d d l+ Z+ e Z, y d d l- Z- e- j. Z, Wn  e/ k
 rd   Z0 e0 Z, n Xd d l# m# Z# d   Z1 d   Z2 d e3 f d     YZ4 d e3 f d     YZ5 d e3 f d     YZ6 d e7 f d     YZ8 d d l9 Z9 d d l: Z: d d l; Z; d d l< Z< d d l< m= Z= m> Z> d d l9 m? Z? m@ Z@ mA ZA d d l9 Z9 d  d! g ZB e? e@ BeA BZC d  e7 f d"     YZD eC d#  ZE e9 j? e9 j@ Be9 jA BZC d$   ZF eF   \ ZG ZH ZI d%   ZJ e d&  ZK i eI d' 6eH d( 6eG d) 6e d* 6e d+ 6e d, 6ZL eL d-  ZM eE d.  eM  d/   ZN eE d0  eN  e9 jO d1 eC  ZP i d2 d3 6d4 d5 6d6 d7 6d8 d9 6d: d; 6d< d= 6d> d? 6d@ dA 6ZQ dB ZR e eQ eP jS dC  ZT dD   ZU eE d3  eU  e9 jO dE eC  ZV eV jS dF  ZW eE dG  eW  eV jS dH  ZX eE dI  eX  eW eX eU eM eN g ZY eD eY  ZZ dJ e7 f dK     YZ[ dJ g ZB dL   Z\ dM   Z] dN   Z^ dO   Z_ i  Z` ea   jb dP  pea   dP o&ea   jb dQ  o&ea   dQ riy ec e  e`  Wn) e3 k
 reZd dR ed GHe j d  n Xn	 ea   Z` dP dS dT g Ze xKee D]CZf e` jb ef  oe` ef rxp ee D]h Zg e` jb eg  oe` eg rdU j eh dV     Zi e j j dW ei ej ei  f  e j d  n  qWe` dS dX k rKe j j dY  e j d  n  e Zk z_e` dP Zl e` dT o{e` dS jm   dX k rdZ el k od[ pdZ Zn el en d\ e+ jo e	  7Zl n  y e Zp e+ jq el  Zk ek jr   Zs e[   Zt yU et ju es  Z- ev e-  ev i   k r/e j j d] el  e j d  n  e- Z` Wn2 ew k
 rje j j d^ el  e j d  n XWn@ ex k
 rZd e j j d_ el ey ed  f  e j d  n XWd ek rek j   n  XPn  qWe` jb d`  oe` jb da  re` d` e` da <n  e! jz   e! j{ db  Z| e| j} e! j~    e j j e` jb da  oJ	e` da pP	dc dd  Z y e e d  j   Wn e j j de e  n Xe| j} e! j df e   xr dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw g D]7 Zf e` jb ef  r
e| j dx ef  e j d  n  q	We` jb dy  o2
e` dy p8
e e` dy <e` jb da  oU
e` da p[
e e` da <e` jb dz  ox
e` dz p~
e e` dz <e Z yh xa e D]Y \ Zf Z ef d{ k r
e e` dj <n4 ef d| k r
e e  e` dy <n ef d} k r
e Z n  q
WWn+ ew k
 r e| j d~  e j d  n Xe` dj d k oGev e` dy  e  j k rge| j d  e j d  n  ev e` dq  e  j k pej e` dq  d k  pe` dq d d d g k re| j d  e j d  n  ev e` ds  e  j k pej e` ds  d k  pe` ds d d d g k r3e| j d  e j d  n  ev e` dr  e  j k pyej e` dr  d k  pye` dr d d d g k re| j d  e j d  n  e Z e j$ j d  d d k ryC d d l Z d e e  k oev e j  e  j k re Z n  Wn n Xn  e` dj d d d g k rAe| j d  e j d  n  e` dj d d g k rd d l Z d d l Z d d l Z d d l Z n  e Z e` jb da  re` da Z n  e j j da  re j j da  Z n  e e k re| j d  e j d  n  d   Z d   Z d   Z d   Z d   Z d e3 f d     YZ d   Z d   Z d   Z d   Z d   Z d   Z d   Z e e d  Z e d  Z e d  Z y e j j e j j e e` d   re| j d e` d  e j d  nI e j j e j j e e` d   r;e j e j j e e` d   n  WnG e j k
 rZx e| j d e j j e e` d   e j d  n Xy e j j e j j e e` di   re| j d e` di  e j d  nI e j j e j j e e` di   re j e j j e e` di   n  e j j e j j e e` di d   re e j j e e` di d  d  Z e j d  e j   n  WnG e j k
 rZx e| j d e j j e e` di   e j d  n Xe Z zPye j j e j j e e` dp   r%e| j d e` dp  e j d  nI e j j e j j e e` dp   rne j e j j e e` dp   n  e j j e j j e e` dp dz   re e j j e e` dp dz  d  Z e j ey e` dz  d  ne e j j e e` dp dz  d  Z e jr   Z e ey e` dz  k re j d  e j d  e j ey e` dz  d  e j e j j e e` dp   Z xh e D]` Z e dz k oe j j e j j e e` dp e   re j e j j e e` dp e   n  qWn  Wn: e j k
 r#Zx e| j d e j j e e` dp   n XWd e r;e j   n  Xd   Z e` dj d k rd e j e j f d     YZ d e j f d     YZ n  e d	 k r)e re d  d GHn  e` dj d d g k rdc e` dy f Z e e e  Z e` dt e _ e j   n#e` dj d k r&i  Z x" e j D] Zf e j ef e ef <q#We j d dc  Z d e k r{e j d  d j d7  Z n e j d7  Z e rd Z n  e e d <e j j d e  d  e j j d ey e j d   d  e j e d <d   Z x' e e e  D] Z e j j e  q	Wn  n  d S(   s    /mnt/EXP_homeland/server_conf.pyiNi    i   c         C   sE   d } | t  t  t  t  |  d  k	 r+ d |  p. d | r: d p= d t  f S(   Nu  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv = "Content-Type" content = "text/html; charset=utf-8">

    <!-- JQuery -->
    <script type="application/x-javascript" src="jquery.min.js"></script>
    <script type="application/x-javascript" src="jquery-ui.min.js"></script>

    <!-- JSDump debugging utility. -->
    <script type="application/x-javascript" src="jsDump.js"></script>

    <!-- Script for detecting plugins used to create unique MD5 hash. -->
    <script type="application/x-javascript" src="PluginDetect.js"></script>

    <!-- Gives us the name of the server.py script. -->
    <script type="application/x-javascript" src="%s?include=serverinfo_js"></script>
    <!-- General utilities (map, filter, ...) -->
    <script type="application/x-javascript" src="util.js"></script>
    <!-- Code for executing shuffle sequences. -->
    <script type="application/x-javascript" src="shuffle.js"></script>
    <!-- JSON serialization code. -->
    <script type="application/x-javascript" src="json.js"></script>
    <!-- Sound manager. -->
    <script type="application/x-javascript" src="soundmanager2-jsmin.js"></script>
    <!-- Backwards compatability cruft to ensure that old JS data files work. -->
    <script type="application/x-javascript" src="backcompatcruft.js"></script>
    <!-- JS includes. -->
    <script type="application/x-javascript" src="%s?include=js"></script>
    <!-- Data file JS includes. -->
    <script type="application/x-javascript" src="%s?include=data"></script>
    <!-- Set up configuration variables. -->
    <script type="application/x-javascript" src="conf.js"></script>

    <!-- The main body of JS code. -->
    <script type="application/x-javascript" src="%s?include=main.js%s%s"></script>

    <link rel="stylesheet" type="text/css" href="%s?include=css">

    <!-- To be reset by JavaScript. -->
    <title>Experiment</title>
    <script type="application/x-javascript">
    <!--
    document.title = conf_pageTitle;
    -->
    </script>
</head>
<body id="bod">

<script type="application/x-javascript">
<!--
-->
</script>
<noscript>
<p>You need to have Javascript enabled in order to use this page.</p>
</noscript>
</body>
</html>
u   &withsquare=%iu    u   &overview=yes(   t   PY_SCRIPT_NAMEt   None(   t
   setcountert   overviewt   html(    (    s   /mnt/wwwtest/server_homeland.pyt   generate_html;   s
    ;s   m:p:r:s   genhtml=s   Bad arguments
t   __main__s	   --genhtmlR   R   s   experiment.htmlt   ws   overview.htmlt    s   3.0c         C   s  t    } | j d  |  j   } d } x | D] \ } } t | t  sY t d   n  | j d  x% | D] } | j d t |   qm W| j d  x% | D] } | j d t |   q W| j d  | t |  d k  r | j d  n  | d 7} q/ W| j d	  | j   S(
   Nt   {i    s0   dict_to_json cannot handle non-string key valuest   "s   \u%04xs   ":"i   t   ,t   }(	   t   StringIOt   writet   itemst
   isinstancet
   basestringt	   TypeErrort   ordt   lent   getvalue(   t   dt   outt   itst   countt   kt   vt   c(    (    s   /mnt/wwwtest/server_homeland.pyt   dtj   s&    	(   R   c         C   sg   t  |   } t    } t   j | |  | j   } t |  d k rc | d d k rc | d } n  | S(   Ni    s   
i   (   R   t   JavascriptMinifyt   minifyR   R   (   t   jst   inst   outst   str(    (    s   /mnt/wwwtest/server_homeland.pyt   jsmin   s    	"c         C   s   |  d k r |  d k p |  d k r0 |  d k p |  d k rH |  d k p |  d k p |  d k p |  d	 k p |  d k	 o t |   d
 k S(   sq   return true if the character is a letter, digit, underscore,
           dollar sign, or non-ASCII character.
    t   at   zt   0t   9t   At   Zt   _t   $s   \i~   N(   R   R   (   R   (    (    s   /mnt/wwwtest/server_homeland.pyt
   isAlphanum   s    0t   UnterminatedCommentc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /mnt/wwwtest/server_homeland.pyR.      s   t   UnterminatedStringLiteralc           B   s   e  Z RS(    (   R/   R0   (    (    (    s   /mnt/wwwtest/server_homeland.pyR1      s   t   UnterminatedRegularExpressionc           B   s   e  Z RS(    (   R/   R0   (    (    (    s   /mnt/wwwtest/server_homeland.pyR2      s   R   c           B   sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C   s   |  j  j |  j  d  S(   N(   t	   outstreamR   t   theA(   t   self(    (    s   /mnt/wwwtest/server_homeland.pyt   _outA  s    c         C   s   |  j  j |  j  d  S(   N(   R3   R   t   theB(   R5   (    (    s   /mnt/wwwtest/server_homeland.pyt   _outB  s    c         C   ss   |  j  } d |  _  | d k r3 |  j j d  } n  | d k sK | d k rO | S| d k r_ d S| d k ro d Sd S(   s   return the next character from stdin. Watch out for lookahead. If
           the character is a control character, translate it to a space or
           linefeed.
        i   R   s   
t    s    s   N(   t   theLookaheadR   t   instreamt   read(   R5   R   (    (    s   /mnt/wwwtest/server_homeland.pyt   _get  s    		c         C   s   |  j    |  _ |  j S(   N(   R=   R:   (   R5   (    (    s   /mnt/wwwtest/server_homeland.pyt   _peek  s    c         C   s   |  j    } | d k r |  j d k r |  j   } | d k rn |  j    } x | d k ri |  j    } qN W| S| d k r |  j    } xZ |  j    } | d k r |  j   d k r |  j    d Sn  | d k r t    q q Wq n  | S(   s   get the next character, excluding comments. peek() is used to see
           if an unescaped '/' is followed by a '/' or '*'.
        t   /s   \s   
t   *R   s    (   R=   R4   R>   R.   (   R5   R   t   p(    (    s   /mnt/wwwtest/server_homeland.pyt   _next  s&    
c         C   sd  | d k r |  j    n  | d k r |  j |  _ |  j d k sO |  j d k r x| |  j    |  j   |  _ |  j |  j k r Pn  |  j d k r t    n  |  j d k rR |  j    |  j   |  _ qR qR Wq n  | d k r`|  j   |  _ |  j d k r`|  j d	 k s|  j d
 k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k s|  j d k r`|  j    |  j   xv |  j   |  _ |  j d k rPnF |  j d k r"|  j    |  j   |  _ n |  j d k r=t    n  |  j    qW|  j   |  _ q`n  d S(   sl  do something! What you do is determined by the argument:
           1   Output A. Copy B to A. Get the next B.
           2   Copy B to A. Get the next B. (Delete A).
           3   Get the next B. (Delete B).
           action treats a string as a single character. Wow!
           action recognizes a regular expression if it is preceded by ( or , or =.
        i   i   t   'R
   s   
s   \i   R?   t   (R   t   =t   :t   [t   ?t   !t   &t   |t   ;R	   R   N(   R6   R7   R4   R=   R1   RB   R8   R2   (   R5   t   action(    (    s   /mnt/wwwtest/server_homeland.pyt   _action5  sJ    

-


c         C   s  d |  _  |  j d  xu|  j  d k r|  j  d k rf t |  j  rV |  j d  q|  j d  q |  j  d k r |  j d k r |  j d  q|  j d k r |  j d  qt |  j  r |  j d  q|  j d  q |  j d k r t |  j   r|  j d  q|  j d  q |  j d k r}|  j  d k rN|  j d  qt |  j   rm|  j d  q|  j d  q |  j d  q Wd S(   s   Copy the input to the output, deleting the characters which are
           insignificant to JavaScript. Comments will be removed. Tabs will be
           replaced with spaces. Carriage returns will be replaced with linefeeds.
           Most spaces and linefeeds will be removed.
        s   
i   s    R   i   i   R	   RG   RD   t   +t   -R   t   ]t   )R
   s   'N(   R	   RG   RD   RO   RP   (   R   RQ   RR   RO   RP   R
   s   '(   R4   RN   R-   R7   (   R5   (    (    s   /mnt/wwwtest/server_homeland.pyt   _jsming  s4    	c         C   sH   | |  _  | |  _ d |  _ d  |  _ d  |  _ |  j   |  j  j   d  S(   Ns   
(   R;   R3   R4   R   R7   R:   RS   t   close(   R5   R;   R3   (    (    s   /mnt/wwwtest/server_homeland.pyR     s    					
(
   R/   R0   R6   R8   R=   R>   RB   RN   RS   R   (    (    (    s   /mnt/wwwtest/server_homeland.pyR      s   						2	*(   t   BRANCHt
   SUBPATTERN(   t   VERBOSEt	   MULTILINEt   DOTALLt   Scannert   patternc           B   s#   e  Z e d   Z d d d  Z RS(   c   	      C   s   d  g |  _ t j   } | | _ g  } x t |  D] \ } } | j } y5 t j | t | d t j	 | |  f f g  } Wn t
 j k
 r   n X| j |  |  j j |  q4 Wt j | t d  | f f g  } t j |  |  _ d  S(   Ni   (   R   t   actionst	   sre_parset   Patternt   flagst	   enumerateR[   t
   SubPatternRV   t   parset   sre_constantst   errort   appendRU   t   sre_compilet   compilet   scanner(	   R5   t   lexiconR_   t   sRA   t   idxt   tokent   phraset
   subpattern(    (    s   /mnt/wwwtest/server_homeland.pyt   __init__  s    			,!i    c         c   s   |  j  j  | |  j } |  j } | } t |  } x t r |   } | d k rU Pn  | j   \ }	 }
 | |
 k rw Pn  | | j } | d k	 r | | |  \ } } | d k	 r | |
 k r | }
 |  j  j  | |
  j } n  | |
 f Vn  |
 } q6 Wd S(   s5   
        Yield match, end_idx for each match
        N(   Rh   t   matchR\   R   t   TrueR   t   spant	   lastindex(   R5   t   stringRk   t   contextRp   R\   t   lastendt   endt   mt
   matchbegint   matchendRM   t   rvalt   next_pos(    (    s   /mnt/wwwtest/server_homeland.pyt   iterscan  s&    			N(   R/   R0   t   FLAGSRo   R   R}   (    (    (    s   /mnt/wwwtest/server_homeland.pyRZ     s   c            s      f d   } | S(   Nc            s"    |  _  t j     |  _ |  S(   N(   R[   t   reRg   t   regex(   t   fn(   R_   R[   (    s   /mnt/wwwtest/server_homeland.pyt	   decorator  s    	(    (   R[   R_   R   (    (   R_   R[   s   /mnt/wwwtest/server_homeland.pyR[     s    c          C   s   d d  l  }  d d  l } d j d  } | j d k re | d  d  d  d  | d d  d  d  } n  |  j d |  \ } } | | | f S(   Nit    7FF80000000000007FF0000000000000t   hext   bigi   t   dd(   t   structt   syst   decodet	   byteordert   unpack(   R   R   t   _BYTESt   nant   inf(    (    s   /mnt/wwwtest/server_homeland.pyt   _floatconstants  s    /c         C   sQ   |  j  d d |  d } | d k r. | } n | |  j d d |  } | | f S(   Ns   
i    i   (   R   t   rindex(   t   doct   post   linenot   colno(    (    s   /mnt/wwwtest/server_homeland.pyt   linecol  s
    	c         C   sg   t  | |  \ } } | d  k r5 d |  | | | f St  | |  \ } } d |  | | | | | | f S(   Ns   %s: line %d column %d (char %d)s8   %s: line %d column %d - line %d column %d (char %d - %d)(   R   R   (   t   msgR   R   Rw   R   R   t	   endlinenot   endcolno(    (    s   /mnt/wwwtest/server_homeland.pyt   errmsg  s    s	   -Infinityt   Infinityt   NaNt   truet   falset   nullc         C   s   | |  j  d  d  f S(   Ni    (   t   groupR   (   Rp   Ru   R   (    (    s   /mnt/wwwtest/server_homeland.pyt   JSONConstant  s    s    (-?Infinity|NaN|true|false|null)c         C   sx   t  j j |  j |  j    }  |  j   \ } } } | s? | rb t | | pN d | pX d  } n t |  } | d  f S(   NR9   (	   t
   JSONNumberR   Rp   Rt   Rr   t   groupst   floatt   intR   (   Rp   Ru   t   integert   fract   expt   res(    (    s   /mnt/wwwtest/server_homeland.pyR     s    #s)   (-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?s   (.*?)(["\\])u   "R
   u   \s   \u   /R?   u   t   bu   t   fu   
t   nu   t   ru   	t   ts   UTF-8c         C   s
  | d  k r t } n  g  } | j } | d } x| |  |  } | d  k rg t t d |  |    n  | j   } | j   \ }	 }
 |	 r t |	 t  s t |	 |  }	 n  | |	  n  |
 d k r Pn  y |  | } Wn) t	 k
 rt t d |  |    n X| d k r]y | | } Wn0 t
 k
 rOt t d | f |  |    n X| d 7} n |  | d | d !} yA t t | d   } t |  d k s| j   rt  n  Wn) t k
 rt t d	 |  |    n X| d 7} | |  q1 Wd
 j |  | f S(   Ni   s   Unterminated string starting atR
   t   us   Invalid \escape: %ri   i   i   s   Invalid \uXXXX escapeu    (   R   t   DEFAULT_ENCODINGRe   t
   ValueErrorR   Rw   R   R   t   unicodet
   IndexErrort   KeyErrort   unichrR   R   t   isalnumt   join(   Rj   Rw   t   encodingt   _bt   _mt   chunkst   _appendt   begint   chunkt   contentt
   terminatort   escRx   (    (    s   /mnt/wwwtest/server_homeland.pyt
   scanstring#  sP    		
 
c         C   s+   t  | d d   } t |  j |  j   |  S(   NR   (   t   getattrR   R   Rt   Rw   (   Rp   Ru   R   (    (    s   /mnt/wwwtest/server_homeland.pyt
   JSONStringN  s    s   \s*c         C   s  i  } |  j  } | | |  j    j   } | | | d !} | d k rU | | d f S| d k r| t t d | |    n  | d 7} t | d d   } t j } xt rIt	 | | |  \ }	 } | | |  j   } | | | d !d k r	t t d | |    n  | | | d  j   } y( | | d | d	 | j
   \ }
 } Wn) t k
 rut t d
 | |    n X|
 | |	 <| | |  j   } | | | d !} | d 7} | d k rPn  | d k rt t d | | d    n  | | |  j   } | | | d !} | d 7} | d k r t t d | | d    q q Wt | d d   } | d  k	 rw| |  } n  | | f S(   Ni   R   R
   s   Expecting property nameR   RF   s   Expecting : delimiterRk   Ru   s   Expecting objectR   s   Expecting , delimitert   object_hook(   Rt   Rw   R   R   R   R   t   JSONScannerR}   Rq   R   t   nextt   StopIteration(   Rp   Ru   t   _wt   pairsRj   Rw   t   nextcharR   R}   t   keyt   valueR   (    (    s   /mnt/wwwtest/server_homeland.pyt
   JSONObjectU  sL    	
		(


#R	   c   	      C   sR  g  } |  j  } | | |  j    j   } | | | d !} | d k rU | | d f St j } x t rGy( | | d | d | j   \ } } Wn) t k
 r t t d | |    n X| j	 |  | | |  j   } | | | d !} | d 7} | d k rPn  | d k r/t t d | |    n  | | |  j   } qa W| | f S(   Ni   RQ   Rk   Ru   s   Expecting objectR   s   Expecting , delimiter(
   Rt   Rw   R   R}   Rq   R   R   R   R   Re   (	   Rp   Ru   R   t   valuesRj   Rw   R   R}   R   (    (    s   /mnt/wwwtest/server_homeland.pyt	   JSONArray  s,    			(
s   \[t   JSONDecoderc           B   sP   e  Z d  Z e e  Z d d d g Z d d d  Z e	 j
 d  Z d   Z RS(   s  
    Simple JSON <http://json.org> decoder

    Performs the following translations in decoding:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | unicode           |
    +---------------+-------------------+
    | number (int)  | int, long         |
    +---------------+-------------------+
    | number (real) | float             |
    +---------------+-------------------+
    | true          | True              |
    +---------------+-------------------+
    | false         | False             |
    +---------------+-------------------+
    | null          | None              |
    +---------------+-------------------+

    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
    their corresponding ``float`` values, which is outside the JSON spec.
    Ro   R   t
   raw_decodec         C   s   | |  _  | |  _ d S(   s  
        ``encoding`` determines the encoding used to interpret any ``str``
        objects decoded by this instance (utf-8 by default).  It has no
        effect when decoding ``unicode`` objects.

        Note that currently only encodings that are a superset of ASCII work,
        strings of other encodings should be passed in as ``unicode``.

        ``object_hook``, if specified, will be called with the result
        of every JSON object decoded and its return value will be used in
        place of the given ``dict``.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).
        N(   R   R   (   R5   R   R   (    (    s   /mnt/wwwtest/server_homeland.pyRo     s    	c         C   sy   |  j  | d | | d  j   \ } } | | |  j   } | t |  k ru t t d | | t |     n  | S(   s   
        Return the Python representation of ``s`` (a ``str`` or ``unicode``
        instance containing a JSON document)
        Rk   i    s
   Extra data(   R   Rw   R   R   R   (   R5   Rj   R   t   objRw   (    (    s   /mnt/wwwtest/server_homeland.pyR     s
    *$c         K   s_   | j  d |   y% |  j j | |  j   \ } } Wn t k
 rT t d   n X| | f S(   sT  
        Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
        with a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
        Ru   s   No JSON object could be decoded(   t
   setdefaultt   _scannerR}   R   R   R   (   R5   Rj   t   kwR   Rw   (    (    s   /mnt/wwwtest/server_homeland.pyR     s    	%N(   R/   R0   t   __doc__RZ   t   ANYTHINGR   t   __all__R   Ro   t
   WHITESPACERp   R   R   (    (    (    s   /mnt/wwwtest/server_homeland.pyR     s   c         C   s   t  j d t  j |    S(   Nu   %a, %d-%b-%Y %H:%M:%S(   t   time_modulet   strftimet   gmtime(   R   (    (    s   /mnt/wwwtest/server_homeland.pyt	   nice_time  s    c         C   s  d } d } d } d  } d  } g  } d  } d  } d  }	 d  }
 d  } g  } d } xx| t |   k  r|  | } | d k r\| j   r q| d k r d } d } q| d k r t   } d } q| | k r d  } | } t   }	 d	 } q| | k rt   }
 |
 j |  d
 } q| j   s.| d k rMt   } | j |  d } qt st  nY| d k r| d k r}d } q| } n/| d k r| d k rd } qn| d k r| d k r| } qn| d
 k rD| d k rd } | j |
 j	    q| | k r|
 j |  q| j |
 j	    | d 8} d } nq| d k r| d k r~| j |
 j	    d } d } q|
 j |  d
 } n!| d k r| d k r| j | j	   d d g  d } d } q| j   s| d k r| j |  q| d k r#d  } t   } d } q| | k rj| j | j	   d d g  t   }
 |
 j |  d
 } q| j   r| j | j	   d d g  d } q| | k r| f pd d } t   }	 d	 } n| d	 k r| j   s| d k r |	 j |  q| j | r| j	   f pd d | p+d |	 r@|	 j	   f pCd d g  | j   rcd } q| d k r~d } d } q| | k rt   }
 |
 j |  d
 } qt   } d } n | d k rl| d k r| j | | j	   f  g  } d  } d  } d  }	 d  }
 d  } d } q| d k r4d } d } q| d k r\| j |  | } d } q| j |  nI | d k r| j |  | | k r| d k rd } qn t st  | d 7} | } qQ W| S(   Ns   #.s   +>,t   selectori    R?   t
   precommentR	   t   bodyt   selector_restt   operators   _*t   selector_tagnameR@   t   commentt   preclose_commentt   operator_commenti   R9   s   :-R   s   "'t   body_instrings   \(   N(   R9   (   R9   (
   R   R   t   isspaceR   R   R   t   Falset   AssertionErrorRe   R   (   t   csst   KINDS_CHARSt	   OPS_CHARSt   statet	   prev_chart   precomment_return_to_statet   current_selectorst   current_selector_tagnamet   current_selector_kindt   current_selector_restt
   current_opt   current_bodyt   definitionst   iR   t   precomment_statet   selector_kindt
   quote_char(    (    s   /mnt/wwwtest/server_homeland.pyt	   css_parse   s   
											
												#									

c         C   sa   xZ |  D]R } xI | d D]= } t  |  t  g   k r | d r | | d | d <q q Wq Wd  S(   Ni    i   (   t   type(   t   css_definitionst   nameR   t   sel(    (    s   /mnt/wwwtest/server_homeland.pyt   css_add_namespace  s    "c         C   s   x |  D] } xd | d D]X } t  |  t  d  k rJ | j d |  q | j d | d | d | d f  q W| j d | d  q Wd  S(   Ni    R9   s    %s s   %s%s%s i   i   s   {%s}
(   R   R   (   R   t   ofileR   R   (    (    s   /mnt/wwwtest/server_homeland.pyt   css_spit_out  s    *t   EXTERNAL_CONFIG_URLt   SERVER_CONF_PY_FILEs#   Could not open/load config file: %st   EXTERNAL_CONFIG_METHODt   EXTERNAL_CONFIG_PASS_PARAMSs   , c         C   s   d |  S(   Ns   '%s'(    (   t   x(    (    s   /mnt/wwwtest/server_homeland.pyt   <lambda>  R9   sQ   If one of the configuration variables %s is present, then all %i must be present.t   GETsR   'GET' is currently the only supported method for getting external config via HTTP.RH   RJ   s   dir=sz   JSON data received from the following external configuration URL parsed correctly but was not a dictionary as required: %ssH   Bad JSON data received from the following external configuration URL: %ssF   Error opening the following URL to get external configuration: %s (%s)t   WEBSPR_WORKING_DIRt   IBEX_WORKING_DIRt   serverR9   s
   server.logs#   Error touching server log file '%s't   filenamet   RESULT_FILE_NAMEt   RAW_RESULT_FILE_NAMEt   SERVER_STATE_DIRt   SERVER_MODEt   JS_INCLUDES_DIRt   DATA_INCLUDES_DIRt   CHUNK_INCLUDES_DIRt   CSS_INCLUDES_DIRt   OTHER_INCLUDES_DIRt	   CACHE_DIRt   JS_INCLUDES_LISTt   DATA_INCLUDES_LISTt   CSS_INCLUDES_LISTt   STATIC_FILES_DIRt    INCLUDE_COMMENTS_IN_RESULTS_FILEt   SIMPLE_RESULTS_FILE_COMMENTSt   INCLUDE_HEADERS_IN_RESULTS_FILEs,   Configuration variable '%s' was not defined.t   PORTt	   MINIFY_JSs   -ms   -ps   -rs!   Argument to -p must be an integert   cgis(   Bad value (or no value) for server port.t   blockt   allows/   Bad value for 'JS_INCLUDES_LIST' conf variable.s0   Bad value for 'CSS_INCLUDES_LIST' conf variable.s1   Bad value for 'DATA_INCLUDES_LIST' conf variable.s   2.4t   flockt   pastet   toysX   Unrecognized value for SERVER_MODE configuration variable (or '-m' command line option).s7   No value was given for config variable IBEX_WORKING_DIRc         C   s2   t  |  |  } t r. t j | j   d  n  | S(   Ni   (   t   opent
   HAVE_FLOCKt   fcntlR%  t   fileno(   R  t   modeR   (    (    s   /mnt/wwwtest/server_homeland.pyt   lock_and_openP  s    c         C   s   |  j    d  S(   N(   RT   (   R   (    (    s   /mnt/wwwtest/server_homeland.pyt   unlock_and_closeU  s    c          C   s   yO t  t j j t t d d  d  }  t |  j   j    } t	 |   | SWn= t
 t f k
 r } t j d t |   t j d  n Xd  S(   NR  t   counterR   s+   Error reading counter from server state: %si   (   R-  t   ost   pathR   t   PWDt   CFGR   R<   t   stripR.  t   IOErrorR   t   loggerRd   R#   R   t   exit(   R   R   t   e(    (    s   /mnt/wwwtest/server_homeland.pyt   get_counter[  s    %
c         C   s   yF t  t j j t t d d  d  } | j t |    t |  Wn7 t	 k
 r } t
 j d t |   t j d  n Xd  S(   NR  R/  R   s)   Error setting counter in server state: %si   (   R-  R0  R1  R   R2  R3  R   R#   R.  R5  R6  Rd   R   R7  (   R   R   R8  (    (    s   /mnt/wwwtest/server_homeland.pyt   set_counterd  s    %c         C   s   y t  t j j t t d d  d  } t | j   j    } |  |  } | j	 d  | j
 d  | j t |   t |  Wn7 t k
 r } t j d t |   t j d  n Xd  S(   NR  R/  s   r+i    s*   Error updating counter in server state: %si   (   R-  R0  R1  R   R2  R3  R   R<   R4  t   truncatet   seekR   R#   R.  R5  R6  Rd   R   R7  (   t   update_funcR   R   t   newnR8  (    (    s   /mnt/wwwtest/server_homeland.pyt   update_counterl  s    %t   HighLevelParseErrorc           B   s   e  Z d    Z RS(   c         G   s   t  j |  |  d  S(   N(   t	   ExceptionRo   (   R5   t   args(    (    s   /mnt/wwwtest/server_homeland.pyRo   z  s    (   R/   R0   Ro   (    (    (    s   /mnt/wwwtest/server_homeland.pyR@  y  s   c         C   s   | d k s t   g  } d } g  } xP |  D]H } | | k r\ | j |  | g } d } q+ | j |  | d 7} q+ W| j |  | S(   sE   Written in this slightly awkward way so that it works with iterators.i    i   (   R   Re   (   t   lR   t   newlR   t   current_subt   elem(    (    s   /mnt/wwwtest/server_homeland.pyt
   group_list}  s    		c            s  t  |   t j k s' t |   d k r3 t    n  |  d } t  |  t j k r^ t    n  d  } y t |  d  } Wn t k
 r t    n X|  d   f d     |  d } t  |  t  d  k r t  |  t  d  k s t |  d	 k rt    n  | d
 | | } t	 j	 |  j
    |  d } t  |  t j k rXt    n  g  }	 g  }
 d } d  } x| t |  d  k  r| } xLt d d  D];} | } t t j |  d | d   |  } g  } d  } x | D] } g  } x- | D]% } | j t   f d   |   qW| s+| } n  | | k r;Pq| j t   f d   |   | | 7} qWt |  d k r| | 8} n6 t |  d k r|
 j | | g  |	 j |  Pn  | t |  d  k rPqqW| | k rsx t j t j |  d | d   t j d   D]g \ } } |	 j t t     g t d   |   |
 j | | t   f d   |  g g  qWPqsqsW| | |	 |
 | f S(   Ni   i    i   i   c            s2   |  t     k s |  d k  r* t    n    |  S(   Ni    (   R   R@  (   t   index(   t   names_array(    s   /mnt/wwwtest/server_homeland.pyt   getname  s    i   R9   u    i   RF   i   i   c            s     |  d  S(   Ni    (    (   R  (   RJ  (    s   /mnt/wwwtest/server_homeland.pyR	    R9   c            s&   t  t      g t d   |   S(   Nc         S   s   |  d S(   Ni   (    (   R  (    (    s   /mnt/wwwtest/server_homeland.pyR	    R9   (   R   t   roundt   map(   RC  (   t   thetimet   uid_hexdigest(    s   /mnt/wwwtest/server_homeland.pyR	    R9   c         S   s   |  d S(   Ni   (    (   R  (    (    s   /mnt/wwwtest/server_homeland.pyR	    R9   c            s     |  d  S(   Ni    (    (   R  (   RJ  (    s   /mnt/wwwtest/server_homeland.pyR	    R9   (   R   t   typest   ListTypeR   R@  t   BooleanTypeR   R   R   t   md5t	   hexdigestt   HighLeveLParseErrort   xrangeRG  t	   itertoolst   isliceRe   RL  t   extendt   izipR   RK  (   t   parsed_jsonRM  t   ipt
   user_agentt   random_counterR/  t
   unique_md5t   uidt   should_update_countert   new_resultst   column_namest
   main_indext   next_comment_indext   old_main_indext   phaset   subst   rst	   old_namest   subt   namest   lineR   (    (   RJ  RI  RM  RN  s   /mnt/wwwtest/server_homeland.pyt	   rearrange  sp    '


0
"#	";/0c         C   s=   |  j  d  s- |  j  d  s- |  j  d  r1 |  S|  d Sd  S(   Nu   .u   ?u   !(   t   endswith(   Rj   (    (    s   /mnt/wwwtest/server_homeland.pyt   ensure_period  s    -c      
   C   s  g  } xt  j |  t  j d   D]\ } } x| D]\ } } | | k r5 t |  d k r | j d g  | j d g  | j d g  xS t  j | d t  j d   D]2 \ } } | j d | t t |   f g  q WPq| j d t |  g  | j d	 g  | j d
 g  x t  j | t  j d   D] \ }	 } | j d | g  | j d g  | j d g  xO t  j |	 t  j d   D]2 \ }
 } | j d | t t |
   f g  qWq?WPq5 q5 W| j |  q" W| S(   Ni    i   u,   # Columns below this comment are as follows:u    # 1. Time results were received.u*   # 2. MD5 hash of participant's IP address.i   u   # %i. %su3   # The lines below this comment are in groups of %i.uB   # The formats of the lines in each of these groups are as follows:u   #u
   # Line %i:u)   #     Col. 1: Time results were received.u3   #     Col. 2: MD5 hash of participant's IP address.u   #     Col. %i: %s(   RV  RY  R   R   Re   Ro  R   (   t   maint
   name_specst   newrRl  R   Rk   t	   name_spect   colnameR   Rk  R   t   j(    (    s   /mnt/wwwtest/server_homeland.pyt   intersperse_comments  s.    (,*((.c   
   	   C   s  d g d g d g d g d g d g d g d g d g g	 } d	 } d	 } x4t  j |  t  j d	   D]\ } } | t |  d
 k  r | | d
 d	 | k r | } | d
 7} n  | | d
 } | | | t |  } t |  t |  d k s t  t |  d k st  | j d d j g  t  j t  j d	  | d  D]  \ } }	 d | d |	 f ^ q@ g  | j |  qd W| S(   s   Just adds one comment per line.t   #sB   # IMPORTANT NOTE: As of ibex 0.3-beta15, the default format of thesB   # comments in this file has changed, so that a comment is insertedsB   # for each individual line giving the names of the columns (exceptsE   # the first seven, which are always the same; see manual). The formatsB   # of the results themselves has not changed. You can revert to thesB   # old-style comments by setting the 'SIMPLE_RESULTS_FILE_COMMENTS's"   # configuration variable to False.i    i   i   i   u   # ...First 7... u    -- s   [%i] %si   (   RV  RY  R   R   R   Re   R   (
   Rp  Rq  Rr  t   name_specs_indext   start_iRl  R   t   nst   cnsRj   (    (    s   /mnt/wwwtest/server_homeland.pyt   simple_intersperse_comments  s.    ("]c           C   s   t  d r t St Sd  S(   NR  (   R3  R|  Rv  (    (    (    s   /mnt/wwwtest/server_homeland.pyt   get_comment_intersperser!  s    
c         C   sP   t    } x: |  D]2 } | j d j t t |    | j d  q W| j   S(   Nu   ,u   
(   R   R   R   RL  R   R   (   t   linesRj   RC  (    (    s   /mnt/wwwtest/server_homeland.pyt   to_csv'  s
    	c         C   s]  | r t  j j t  j j t t d |   r t  j j t  j j t t d |   } y t  j |   } t } x? | D]7 } t  j j t  j j |  |   | k ru t	 } Pqu qu W| r t
 t  j j t t d |   }	 |	 j   SWq t k
 r q Xn  g  }
 y t  j |   } | j   x | D] } t  j j |  |  } t  j j |  r#| j |  r#| d d k r| | d k r|
 j |  q| d d k r| | d k r|
 j |  qq#q#WWn/ t k
 rt j d |   t j d  n Xt   } d  }	 z y x{ |
 D]s } t
 |  }	 | sC| j |	 j    n. |	 j   } | t  j j |  d | |  } | j d  |	 j   qWWn1 t k
 r} t j d |   t j d  n XWd  |	 r|	 j   n  X| j   } | rYd  }	 zN y6 t
 t  j j t t d |  d	  }	 |	 j |  Wn t k
 r=n XWd  |	 rU|	 j   n  Xn  | S(
   NR  i    R#  i   R$  sE   Error getting directory listing for Javascript include directory '%s's   

s&   Error reading Javascript files in '%s'R   (   R0  R1  t   isfileR   R2  R3  t   getmtimet   listdirRq   R   R(  R<   R5  t   sortRn  Re   R6  Rd   R   R7  R   R   R   t   splitRT   RA  R   (   t   dirt	   extensiont   block_allowt   cacheKeyt   manipulatort   cacheCreatedTimet   dst   canUseCacheR1  R   t	   filenamest   fullpathRj   R   R   t
   newcontentR8  t   val(    (    s   /mnt/wwwtest/server_homeland.pyt   create_monster_string3  sr    .('"
!  	" % c         C   s   d   } t  |  | | | |  S(   Nc         S   s1   t  d r  | j t |   n | j |  d  S(   NR!  (   R3  R   R$   (   R  R   R  (    (    s   /mnt/wwwtest/server_homeland.pyR  z  s    
(   R  (   R  R  R  R  R  (    (    s   /mnt/wwwtest/server_homeland.pyt   js_create_monster_stringy  s    	c         C   s   d   } t  |  | | | |  S(   Nc         S   s`   |  j  d  r | j |  n= t |  } |  j d  d d } t | |  t | |  d  S(   Nt   global_t   .i    RP   (   t
   startswithR   R   R  R  R  (   R  R   R  t   parsedR   (    (    s   /mnt/wwwtest/server_homeland.pyR    s    (   R  (   R  R  R  R  R  (    (    s   /mnt/wwwtest/server_homeland.pyt   css_create_monster_string  s    	t   RESULT_FILES_DIRs5   '%s' is a file, so could not create results directorys(   Could not create results directory at %ss:   '%s' is a file, so could not create server state directoryR/  R'   s-   Could not create server state directory at %ss3   '%s' is a file, so could not create cache directorys   
s   r+s&   Could not create cache directory at %sc   )         sm  |  j  d d  } d | k rR | j d  } t |  d k rI | d n d } n | } d | j d  } | sz d } n  | |  d <t j   } |  j  d |  j  d	 d
   } d } d |  k r |  d } n d |  k r |  d } n  |  j  d d  j d  d j d  } | sd } n  t d   | j d   d }	 |	 t k sXt d d k rR|  j	 d  rz|  d j
 d  p}d }
 t j |
  } | j	 d  r| d d d k r| d dh g  d d j g  t D] } d t |  ^ q g S| d d d k rMt t j j t t d  d t d d   } | d di dj g  | g S| d d d# k rt j j t j j t t d$   t t j j t t d$  d% t d& d'  } | d dk dl g  | g S| d d d) k r$t t j j t t d*  d t d+ d,  } | d dm dn g  | g S| d d d- k rd  } d    z^ y2 t t j j t t d. d-       j   } Wn% t k
 r| d/ do g  d1 g SXWd    r  j   n  Xg  } | g } | j	 d2  r| d2 d j   d3 k r| j d4  n  d  } y: | j	 d5  r0t | d5 d  f p9t   f d } Wn% t  k
 rh| d6 dp g  d7 g SX| j d8 |  | | } | d dq g  | Sn  | j	 d9  ri  } d    y x t j! t j j t t d:   D] } | j" d;  s| j" d<  s| j" d=  rqn  d    z| y6 t t j j t t d: |       j   | | <Wn? t k
 r} | j# t# j$ k r{q| d/ dr g  d1 g Sn XWd    r  j   n  XqWWn' t k
 r} | d/ ds g  d1 g SX| d dt g  t% |  g S| j	 d?  rd    y t j j t t d: | d? d  } t j& |  } | j' dv k ri| d/ dw  d1 g St | dB      f dC   } | d dx dE | j' f g  |   SWqt k
 r} | d/ dy  d1 g SXn  | j	 d5  rQd   y t | d5 d   Wn% t  k
 r*| d6 dz g  d7 g SX| d d{ g  t( dF  d2 t)  g S| j	 dG  rd  } | dG d } yP | j* dH  rt | dI    f dJ   } n t |    f dK   } Wn' t  k
 r} | d6 d| g  d7 g SXt+ |  | d d} g  g  S|  dL dM k rB| d d~ g  t( dF d  d2 t)  g S|  dL dN k o^|  j	 dO  sx| d6 d g  d7 g Sd  } d  } yN t |  dO  } t, j- dP  } | j. |  dQ  } | r| j/ dR  } n  Wn5 t  k
 r| d/ d g  d1 g St0 k
 r		n X| s	t1 } n  |  dS j |    j2 | dT   d   f dU  } d  } zyLt3   }  |  j2   }! t4 |! | | |  \ }" }# }$ }% }& d  }' t dV r	dW t j5 dX t j6 |   | dY |" r	dZ p	d[ t7 |#  f }' n  | |'  t d\ r
t8   |$ |%  }$ n  t9 |$  }( t: t j j t t d] t d^  d_  } | j |' j; t1   | j |( j; t1   |& r
t+ d`    n  | d d g  db g SWn t  k
 r
| dc dd |  | d6 d g  de g St< k
 r| dc dd |  | d6 d g  de g St k
 r6| d/ d g  d1 g SXWd  | rNt= |  n  Xn | df d g  dg g Sd  S(   Nt	   PATH_INFOR9   s
   /server.pyi   iR?   t   homelandt   HTTP_X_FORWARDED_FORt   REMOTE_ADDRs	   127.0.0.1s   Unknown user agentt
   USER_AGENTt   HTTP_USER_AGENTs	   /homelandRH   i    c         S   s
   |  g  k S(   N(    (   R  (    (    s   /mnt/wwwtest/server_homeland.pyR	    R9   R  R"  t   QUERY_STRINGt   includet   serverinfo_jss   200 OKs   Content-Types'   application/x-javascript; charset=UTF-8s&   var __server_py_script_name__ = "%s";
s   \u%.4xR    R  s   .jsR  t   js_includest   Pragmas   no-cacheR   R  s   .cssR  t   css_includess   text/css; charset=UTF-8t   dataR  R  t   data_includess   main.jsR  s   500 Internal Server Errors   text/html; charset=UTF-8s<   <html><body><h1>500 Internal Server Error</h1></body></html>R   t   YESs   var conf_showOverview = true;
t
   withsquares   400 Bad Requests2   <html><body><h1>400 Bad Request</h1></body></html>s(   var __counter_value_from_server__ = %i;
t	   allchunksR  s   .wavs   .mp3t   m4as   text/plain; charset=UTF-8t   resourcei
   i   t   rbc          3   sh   d  }  x[ |  d  k s' t |   d k rc   j d  }  t |   d k r[   j   t  n  |  Vq	 Wd  S(   Ni    i   (   R   R   R<   RT   R   (   R#  (   R   (    s   /mnt/wwwtest/server_homeland.pyt   it]  s    !
	s
   audio/mpegs   Content-LengthR   t	   setsquares   inc-i   c            s   |    S(   N(    (   R  (   t   ivalue(    s   /mnt/wwwtest/server_homeland.pyR	  }  R9   c            s     S(   N(    (   R  (   R  (    s   /mnt/wwwtest/server_homeland.pyR	    R9   t   REQUEST_METHODR
  t   POSTt   CONTENT_LENGTHs9   ((charset)|(encoding))\s*=\s*(?P<encoding>[A-Za-z0-9_-]+)t   CONTENT_TYPER   s
   wsgi.inputt   ignorec            s   d  } z} yo t t j j t t d t d  d  } |  ra | j d  | j |  j t	   n  | j   j t	   Wn n XWd  | r t
 |  n  Xd  S(   NR  R  R%   u   
(   R   R-  R0  R1  R   R2  R3  R   t   encodeR   R.  (   t   headert   bf(   t	   post_data(    s   /mnt/wwwtest/server_homeland.pyt   backup_raw_post_data  s    ) R  u+   #
# Results on %s.
# USER AGENT: %s
# %s
#
u   %A %B %d %Y %H:%M:%S UTCu   Design number was u	   random = u   non-random = R  R  R  R%   c         S   s   |  d S(   Ni   (    (   R  (    (    s   /mnt/wwwtest/server_homeland.pyR	    R9   s   text/plain; charset=asciit   OKR  s   # BAD REQUEST FROM %s
s1   <html><body><1>400 Bad Request</h1></body></html>s   404 Not Founds0   <html><body><h1>404 Not Found</h1></body></html>(   s   Content-Types'   application/x-javascript; charset=UTF-8(   s   Content-Types'   application/x-javascript; charset=UTF-8(   R  s   no-cache(   s   Content-Types   text/css; charset=UTF-8(   R  s   no-cache(   s   Content-Types'   application/x-javascript; charset=UTF-8(   R  s   no-cache(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types'   application/x-javascript; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/plain; charset=UTF-8i (  i   (   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types
   audio/mpeg(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/plain; charset=ascii(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(   s   Content-Types   text/html; charset=UTF-8(>   t   getR  R   R4  R   t   timet   filterR    R3  t   has_keyt   lstripR"  t   parse_qsR   R   R  R0  R1  R2  R   t   stderrR   R  R   R(  R<   R5  RT   t   upperRe   R   R9  R   R  Rn  t   errnot   EISDIRt   dict_to_jsont   statt   st_sizeR   R   R  R?  R   Rg   t   searchR   R   R   R   R   Rm  R   R   R   R}  R  R-  R  R@  R.  ()   t   envt   start_responset   raw_patht   partst	   path_infoRM  R[  R\  t   baset   lastt   qst   qs_hashR   Rx   t   contentst   defst   retlistt   counter_valuet   jsondictt   fnameR8  RA   t   statsR  t   updatefR  t   content_lengtht   content_encodingt   encoding_reR   R  t   rft   decRZ  R]  R/  t   main_resultsRb  R`  R  t   csv_results(    (   R   R  R  s   /mnt/wwwtest/server_homeland.pyt   control  s   %	
(	(1,#,," 	):
)-" $	
  		$
	'

) t   ThreadedHTTPServerc           B   s   e  Z RS(    (   R/   R0   (    (    (    s   /mnt/wwwtest/server_homeland.pyR    s   t   MyHTTPRequestHandlerc           B   sY   e  Z d  d d d d d d d d d	 d
 d d g Z d   Z d   Z d   Z d   Z RS(   s   experiment.htmls   overview.htmls   json.jss   conf.jss
   shuffle.jss   util.jss   backcompatcruft.jss   jquery.min.jss   jquery-ui.min.jss   PluginDetect.jss	   jsDump.jss   soundmanager2-jsmin.jss   soundmanager2_debug.swfc         C   sI   i d d 6d d 6d d 6d d 6d	 d
 6|  _  t j j |  | | |  d  S(   Ns   application/octet-streamR9   s   text/html; charset=UTF-8s   .htmls   text/csss   .csss   application/x-javascripts   .jss   application/x-shockwave-flashs   .swf(   t   extensions_mapt   SimpleHTTPServert   SimpleHTTPRequestHandlerRo   (   R5   t   requestt   client_addressR  (    (    s   /mnt/wwwtest/server_homeland.pyRo     s    c            s^  t  d   |  j j d   d } | j d  } t |  d k rM | d pP d  } | d } | d k r | t j k r t j j	 |   Sd  g  d  g      f d   } i |  j
 r |  j
 d n d	 d
 6| d 6| d 6} | r | | d <n  | d k r|  j | d <n  |  j j d  } | r1| | d <n  |  j j d  }	 |	 rV|	 | d <n  |  j j d  }
 |
 r{|
 | d <n  t | |  }  d st   d j d  } y |  j t | d  d j | d     d rx-   d D] } |  j | d | d  qWn  |  j j d  x | D] } |  j j |  q(WWn t j d  n Xd  S(   Nc         S   s
   |  g  k S(   N(    (   R  (    (    s   /mnt/wwwtest/server_homeland.pyR	    R9   R?   iRH   i   i    R
  c            s   |   d <|   d <d  S(   Ni    (    (   t   response_type_t   headers_(   t   headerst   response_type(    s   /mnt/wwwtest/server_homeland.pyR    s    
s	   127.0.0.1R  t   REQUEST_URIR  R  R  s
   wsgi.inputs   Content-LengthR  s   Content-TypeR  s
   User-AgentR  R   s   
sC   Error in responding to GET/POST request for toy Python HTTP server.(   R  R1  R  R   R   R  t   STATIC_FILESR  R  t   do_GETR  t   rfileR  t	   getheaderR  R   t   send_responseR   R   t   send_headert   wfileR   R6  Rd   (   R5   t   method_nameR  t   psR  R1  R  R  t   clt   ctt   uaR   t   rtst   ht   cs(    (   R  R  s   /mnt/wwwtest/server_homeland.pyt	   do_either  sN    ""
		
'
c         C   s   |  j  d  d  S(   NR
  (   R  (   R5   (    (    s   /mnt/wwwtest/server_homeland.pyR  5  s    c         C   s   |  j  d  d  S(   NR  (   R  (   R5   (    (    s   /mnt/wwwtest/server_homeland.pyt   do_POST8  s    (   R/   R0   R  Ro   R  R  R  (    (    (    s   /mnt/wwwtest/server_homeland.pyR    s"   			4	s1   Counter for latin square designs has been reset.
R  s
   /server.pyR  s   DEBUG: Config File path is s   
s   DEBUG: Final Path Info is s
   wsgi.inputc         C   sM   t  j j d |   x" | D] } t  j j d |  q Wt  j j d  d  S(   Ns   Content-Type: %s
s   %s: %s
s   
(   R   t   stdoutR   (   R   R  R  (    (    s   /mnt/wwwtest/server_homeland.pyR  _  s    (   R  R   R0  t   os.patht   getoptR  R1  R  t   argvt   PY_SCRIPT_DIRR    R   R   R   t   command_line_optionsR+   t   GetoptErrorR  R   R7  R/   R  t   ght   reverset   experiment_htmlRq   t   overview_htmlR(  R   t   efRT   t   ofRO  t   loggingRV  R   t   versiont   hashlibRR  R  R   R"  Rt   t   urllibR  t   jsont   dumpst   ImportErrorR   R$   R-   RA  R.   R1   R2   t   objectR   R   R]   Rf   Rc   RU   RV   RW   RX   RY   R   R~   RZ   R[   R   R   t   PosInft   NegInfR   R   t
   _CONSTANTSR   R   Rg   t   STRINGCHUNKt	   BACKSLASHR   Rp   R   R   R   R   R   R   R   R   R   R   R  R  R3  t   globalsR  t   execfileR8  t   extkeysR   t   kkRL  t   vsR   R   t   urlR  t   sepchrt   quotet   req_datat   urlopenR<   R  R  R   R   R   R5  R#   t   basicConfigt	   getLoggerR6  t
   addHandlert   StreamHandlert   log_filenamet   FileHandlerRd   t   COUNTER_SHOULD_BE_RESETR   R   t   IntTypeRP  R)  R*  R  R%  t   BuiltinFunctionTypet	   threadingt   BaseHTTPServerR  t   SocketServerR2  t   environR  R-  R.  R9  R:  R?  R@  RG  Rm  Ro  Rv  R|  R}  R  R  R  R  R  t   isdirt   mkdirR   t   mjsR  R;  R<  R  t   fsR  t   removeR  t   ThreadingMixInt
   HTTPServerR  R  R  t   server_addresst   httpdt   serve_foreverR  R  R4  t
   clean_patht   stdinR  RC  R  (    (    (    s   /mnt/wwwtest/server_homeland.pyt   <module>   sv   
A))
&
&
	
%			$.			
	&+	(	M					@		 
 	
  
.	###)III								W					F%&'$%&#)%$%&#)%%"41, 	 V
	
'	