Ñò
ubSc           @   sÏ   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z d  d k l Z d  d k l Z l	 Z	 l
 Z
 l Z l Z l Z d  d k l Z d e i f d „  ƒ  YZ d „  Z d	 „  Z d
 „  Z d „  Z d S(   iÿÿÿÿN(   t   Queue(   t   sleep(   t   bcolt   tickert	   calcWidtht   getColst   checkSummaryt	   openPorts(   t   callt   LoginInfoWorkerc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   t  i i |  ƒ | |  _ d  S(   N(   t	   threadingt   Threadt   __init__t   queue(   t   selfR   (    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyR      s    c         C   s¥   xž t  o– |  i i ƒ  } | d  j o Pn | i ƒ  | i o t i | i t i	 Gd Gq | i
 o t i | i t i	 Gd Gq t i | i t i	 Gd Gq Wd  S(   Ns	   checked..(   t   TrueR   t   gett   Nonet   refreshInfot   cpanelR   t   OKGREENt   usernamet   ENDCt   ftpt   WARNINGt   FAIL(   R   t   acct(    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt   run   s     


(   t   __name__t
   __module__R   R   (    (    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyR	      s   	c         C   s  t  ƒ  zÿ t t i d t i d ƒ } | i ƒ  t ƒ  } x$ t | ƒ D] } t | ƒ i	 ƒ  qH WxL t
 |  ƒ D]> \ } } | i | ƒ | t |  ƒ d j o t | ƒ qo qo Wx! t | ƒ D] } | i d  ƒ q¾ Wx- t o% | i ƒ  o
 d GHd  St d ƒ qØ WWd  | i ƒ  Xd  S(   Ns   [*] s(   Making sure we can access the accounts..i   s    done.(   R   R   R   t   OKBLUER   t	   __enter__R    t   rangeR	   t   startt	   enumeratet   putt   lenR   R   R   t   emptyt   __exit__(   t   acctst   threadst   waittimet   tR   t   it   indexR   (    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt   loginInfoChecker   s.    
	    c         C   s!   y t  |  ƒ t SWn t SXd  S(   N(   t   floatR   t   False(   t   s(    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt	   is_number5   s
    
c      	   C   s  t  ƒ  } t } d } Ht i d i | d ƒ t i GHt | d d d d ƒ } d i | d	 ƒ d
 i | d ƒ d i | d ƒ d i | d ƒ GHt	 i
 d ƒ } h g  d 6g  d 6g  d 6h  d 6g  d 6} d	 } xŠ|  D]‚} | d i | i ƒ t | i d ƒ d j o | i d | d | i <n | i p: t i | i d | i t i }	 t i d t i }
 n | i pp | d i d t i | i d | i t i d t i | i t i ƒ t i | i d | i t i }	 n= t i | i d | i t i }	 t | i ƒ p
 t } n t i | i d t i } t i | i d t i } | i d } | i d } | i d } | i d } | o! t | ƒ o | t | ƒ 7} n | i d } | i d  } | i d! } | i d } | i d" } | p
 d# } n | p
 d# } n | p
 d# } n | d$ j o
 d% } n | p
 d# } n | p
 d# } n | p
 d# } n | p
 d# } n t i }
 | o… | d# j ox t | ƒ d& j o t i }
 n t | ƒ d' j o! | d i | i ƒ t i }
 n t | ƒ d& j  o t i }
 qn y> t | ƒ t d( ƒ j o! | d i | i ƒ t i }
 n Wn t j
 o n X|
 | d) | d* | d+ | d, t i }
 | p  t | ƒ d- | d | } n/ t | ƒ d- t i d. t i | d | } t | ƒ t | i d/ | ƒ ƒ } t |	 d0 d1 ƒ} t | ƒ t | i d/ | ƒ ƒ } | d | d | } t | ƒ t | i d/ | ƒ ƒ } |
 } t | ƒ t | i d/ | ƒ ƒ } | i | d	 | ƒ | i | d | ƒ | i | d | ƒ | i | d | ƒ GHt | i ƒ oG t i  i! t i ƒ x | i D] } d2 | GHq%Wt i  i! t i ƒ n | d 7} q× Wd3 } t | ƒ t | i d/ | ƒ ƒ } d4 t i | t i f } t | ƒ t | i d/ | ƒ ƒ } | i | d	 | ƒ d/ i | d ƒ d/ i | d ƒ | i | d | ƒ GHt" | ƒ | S(5   Ni   s   ___Pre-Transfer checkt   _i    i   i   i   s   #  Primary Domaini    s   User / Passs   Adns/DBs/@si   s   Disk usage  i   s   \x1B\[[^A-Za-z]*[A-Za-z]t   toobigt   nospacet   noaccesst   domainst   userss    / s   ??? s   U/P: s	    Server: t   primarydomaint   hostnamet	   diskusaget	   disklimitt   diskusageperct   diskspaceunitst	   numaddonst   dbst	   numemailst   resellert   ?t	   unlimitedt   NAi<   iK   i¬  t   /t    s    (s   %) s   . s   (Reseller) t    t   encodings   utf-8s      s   
Total Diskusage:s   %s%.2f MB%s
(#   R   R/   R   t   HEADERt   ljustR   R   t   centert   rjustt   ret   compilet   appendR   R$   t   infoR   R   t   passwordR   t   serverR   R   t   errorsR   R1   R.   t   intt
   ValueErrort   strt   subt   unicodet   syst   stdoutt   writeR   (   R'   t   columnst   successt   countt   colst   aansit   checkst   totalduR   t   userpasst   diskinfot   domainR9   t   dut   dlt   dupt   duuR>   R?   t   emailst
   isresellert   c1t   a1t   c2t   a2t   c3t   a3t   c4t   a4t   error(    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt   preCheck<   sÄ    	E

 
"
J&"
  
 
 
 
 
 
 
 
	- .""""U
 ""M
c         C   s·  d } t  ƒ  } Ht i d i | d ƒ t i GHt | d d ƒ } d i | d ƒ d i | d ƒ GHt i d	 ƒ } h g  d
 6g  d 6g  d 6h  d 6g  d 6} x
|  D]} | d i | i	 ƒ t
 | i ƒ d j p | i ƒ  n t
 | i d ƒ d j o | i d | d | i	 <n | i p(| d i d t i | i	 d | i t i d t i | i t i ƒ t i d | i	 d t i } t i | i d t i d | } t | ƒ d | }	 t
 |	 ƒ t
 | i d |	 ƒ ƒ }
 t i d t i } t
 | ƒ t
 | i d | ƒ ƒ } |	 i | d |
 ƒ | i | d | ƒ GHPn t i d | i	 d t i } t i | i d t i d | } t i | i d t i } t | ƒ d | d | }	 t
 |	 ƒ t
 | i d |	 ƒ ƒ }
 | i o­| i d d d j o t i d } n7 | i d d d j o t i d } n t i d } | | i d d  t i 7} t
 | ƒ t
 | i d | ƒ ƒ } |	 i | d |
 ƒ | i | d | ƒ GHt
 | i ƒ d! j oË xÈ | i d D]µ } | d d j o t i d } n0 | d d j o t i d } n t i d } | | d  t i 7} t
 | ƒ t
 | i d | ƒ ƒ } d i | d ƒ | i | d | ƒ GHqÚWq›n | d 7} q£ Wt | ƒ d  S("   Ni   s   ___Available backupsR2   i    iD   s   #  Primary Domaini    t   Backupss   \x1B\[[^A-Za-z]*[A-Za-z]R3   R4   R5   R6   R7   s   U/P: s    / s	    Server: t   (t   )R8   RF   s   . RG   s=   Unable to access the cPanel account with the provided detailsR9   t   statust   completes
   complete: t
   inprogresss   in progress: s   failed: t   filei   (   R   R   RI   RJ   R   R   RM   RN   RO   R   R$   t   backupst   getBackupListRP   R   RQ   R   RR   R   RV   RW   R   R   R   (   R'   R^   R\   R_   R`   Ra   R   t   userRe   Rl   Rm   Rn   Ro   R9   t   backup(    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt   listBackups°   sp    	#

 
J#""+#"
"+ "3(   t   osRM   RY   R
   R    t   timeR   t   helpersR   R   R   R   R   R   t
   subprocessR   R   R	   R-   R1   Ru   R   (    (    (    s)   /root/bin/ikeamodules/ikea/pretransfer.pyt   <module>   s   .			t