ó
Ü`c           @   sŬ   d  d l  Z  d  d l Z d  d l Z d  d l Td  d l Z d  d l Z d  d l m Z d  d l Z d  d l Td  d l	 Z	 d  d l
 Z
 e Z d   Z d   Z d   Z d   Z d e	 j e	 j d	  Z d
   Z d   Z d S(   i˙˙˙˙N(   t   *(   t   callc         C   sy   |  j  d  } t |  d k ro xQ | D]@ } | j   ra t |  t d d  k ra t } q( q( t } Pq( Wn t } | S(   Nt   .i   i    i   (   t   splitt   lent   isdigitt   intt   ranget   Truet   False(   t   addresst   ip_addrt   it   res(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   cfgValidate   s    'c         C   s   d } d } t  |   } | t  |  } | d k rF | j d  } n< | d k rd | j d  } n | d k r | j d  } n  | |  t |  } | S(	   Nt   0000s   </msg>i	   t   0ic   t   00iç  t   000(   R   t   rfindt   str(   t   messaget   lengtht   tailt   length_messaget   kt
   msg_length(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   ccm_msg_length%   s    c         C   s7   t  |   } d j | |   } t j t | g  } d  S(   Ns   </msg>{0}{1}</msg>(   R   t   formatt
   subprocessR   t   CGIpath(   R   R   t
   socket_cmdt   process1(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   send_ccm_msg4   s    c         C   s   d } t  t |   | } d } xB | d k  rd t j j |  rJ d } q# | d } t j d  q# Wt | d  } | j   } | j	   | S(   Ns   ccm_response.txti    id   ie   i   gı?t   r(
   t   gui_pathR   t   ost   patht   isfilet   timet   sleept   opent   readt   close(   t   uuidt   filenamet   ccm_response_filet   filet   fot   CcmResponse(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   get_ccm_response9   s    	

i   c            s#   d j    f d   t |   D  S(   Nt    c         3   s   |  ] } t  j    Vq d  S(   N(   t   randomt   choice(   t   .0t   _(   t   chars(    s$   /var/www/pilotV12/cgi/global_func.pys	   <genexpr>L   s    (   t   joinR   (   t   sizeR8   (    (   R8   s$   /var/www/pilotV12/cgi/global_func.pyt   id_generatorK   s    c          C   s   t    }  |  S(   N(   R;   (   t
   command_id(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   get_ccm_command_idN   s    	c         C   s5   d } t  t |   | } d | } t j |  d  S(   Ns   ccm_response.txts   rm -rf (   R#   R   R$   t   system(   R,   R-   R.   t   cmd_rm(    (    s$   /var/www/pilotV12/cgi/global_func.pyt   delete_ccm_responseS   s    
(   t   sockett   sysR'   t   arrayt   loggingR   R   R$   t   globalSettingst   stringR4   t
   DeviceNamet   deviceR   R   R!   R2   t   ascii_uppercaset   digitsR;   R=   R@   (    (    (    s$   /var/www/pilotV12/cgi/global_func.pyt   <module>   s$   

					