³ò
OÉcIc        	   @   s  d  Z  d d k Z d d k Z d d k l Z d d k Z d d k Z d d k Z d a d Z	 d g Z d e f d „  ƒ  YZ d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   sÄ   Parse args and setup connections

The functions in this module are used once by Main to parse file
descriptions like bescoto@folly.stanford.edu:/usr/bin/ls and to set up
the related connections.

iÿÿÿÿN(   t   Logs   ssh -C %s rdiff-backup --servers   ssh %s rdiff-backup --servert   SetConnectionsExceptionc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR   *   s    c         C   sß   | o
 | a  n t i p
 t a  n t i o t  d t i 7a  n |  p g  Sn t t |  ƒ } t d „  | ƒ o | o t i	 d ƒ q© n | o t d d ƒ n t t
 | ƒ } | o | t d d f t d <n | S(   s·   Map the given file descriptions into command pairs

	Command pairs are tuples cmdpair with length 2.  cmdpair[0] is
	None iff it describes a local path, and cmdpair[1] is the path.

	s    --tempdir=c         S   s   |  d  S(   i    (    (   t   x(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   <lambda>=   s    sF   The --remote-cmd flag is not compatible with remote file descriptions.s;   Remote schema option ignored - no remote file descriptions.i   iÿÿÿÿi   (   t   __cmd_schemat   Globalst   ssh_compressiont   __cmd_schema_no_compresst   remote_tempdirt   mapt   parse_file_desct   filterR    t
   FatalErrort   desc2cmd_pairst	   cmd_pairs(   t   arglistt   remote_schemat
   remote_cmdt
   desc_pairst   cmdpairs(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   get_cmd_pairs,   s&     

 

 c         C   sB   |  \ } } | o t  | ƒ } n
 t i } t i | | ƒ i ƒ  S(   s<   Return normalized RPath from cmd_pair (remote_cmd, filename)(   t   init_connectionR   t   local_connectiont   rpatht   RPatht	   normalize(   t   cmd_pairt   cmdt   filenamet   conn(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt
   cmdpair2rpI   s
     	c         C   s5   |  \ } } | p d | f Sn t | ƒ | f Sd S(   s1   Return pair (remote_cmd, filename) from desc_pairN(   t   Nonet   fill_schema(   t	   desc_pairt	   host_infoR   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR   P   s     c            s  ‡  f d †  } g  d d } } } x¾ | t ˆ  ƒ j o d ˆ  f Sn ˆ  | d j o | d } | | ƒ d } nQ ˆ  | d j o9 | d j o, ˆ  | d d j o | o | i ƒ  Pn d } | i ˆ  | ƒ | d } q& | | d ƒ d i | ƒ ˆ  | d f S(   s&  Parse file description returning pair (host_info, filename)

	In other words, bescoto@folly.stanford.edu::/usr/bin/ls =>
	("bescoto@folly.stanford.edu", "/usr/bin/ls").  The
	complication is to allow for quoting of : by a \.  If the
	string is not separated by :, then the host_info is None.

	c            s+   |  t  ˆ  ƒ j o t d ˆ  ƒ ‚ n d  S(   Ns%   Unexpected end to file description %s(   t   lenR   (   t   i(   t	   file_desc(    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt	   check_len_   s    i    s   \i   t   :t    N(   R!   R%   t   popt   appendt   join(   R'   R(   t   host_info_listR&   t   last_was_quoted(    (   R'   s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR   V   s$    	


3
c         C   s   t  |  S(   s:   Fills host_info into the schema and returns remote command(   R   (   R$   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR"   x   s    c         C   sø   |  p t  i Sn t d |  d ƒ t i d j oP d d k } | i |  d t d d d	 | i d
 | i ƒ} | i	 | i
 } } n t i |  ƒ \ } } t t  i ƒ } t i | | | ƒ } t | |  ƒ t d | d ƒ t | | |  ƒ t | ƒ | S(   sò   Run remote_cmd, register connection, and then return it

	If remote_cmd is None, then the local connection will be
	returned.  This also updates some settings on the remote side,
	like global settings, its connection number, and verbosity.

	s
   Executing i   t   ntiÿÿÿÿNt   shellt   bufsizei    t   stdint   stdouts   Registering connection %di   (   R   R   R    t   ost   namet
   subprocesst   Popent   Falset   PIPER3   R4   t   popen2R%   t   connectionst
   connectiont   PipeConnectiont   check_connection_versiont   init_connection_routingt   init_connection_settings(   R   R7   t   processR3   R4   t   conn_numberR   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR   |   s"     	
c         C   s·   y |  i  i d ƒ } Wnl t i j
 o& } t i d | | t  i f ƒ n9 t j
 o, } t i d | | i d d ƒ f ƒ n X| t  i j o t d t  i | f d ƒ n d S(	   s/   Log warning if connection has different versiont   versionsW  %s

Couldn't start up the remote connection by executing

    %s

Remember that, under the default settings, rdiff-backup must be
installed in the PATH on the remote system.  See the man page for more
information on this.  This message may also be displayed if the remote
version of rdiff-backup is quite different from the local version (%s).s  Integer overflow while attempting to establish the 
remote connection by executing

    %s

Please make sure that nothing is printed (e.g., by your login shell) when this
command executes. Try running this command:

    %s
	
which should only print out the text: rdiff-backup <version>s   --servers	   --versions;   Warning: Local version %s does not match remote version %s.i   N(	   R   t   getR=   t   ConnectionReadErrorR    R   RD   t   OverflowErrort   replace(   R   R   t   remote_versiont	   exceptiont   exc(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR?   ˜   s     	
c         C   sy   |  t  i | <|  i i | ƒ x8 t  i d D]) } |  i i | i ƒ | i i | ƒ q+ Wt  i i |  ƒ t i | ƒ d S(   s7   Called by init_connection, establish routing, conn dicti   N(	   R   t   connection_dictt   SetConnectionst   init_connection_remoteR<   t   add_redirected_connRC   R,   t   __conn_remote_cmds(   R   RC   R   t   other_remote_conn(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyR@   ¹   s     	
c         C   s`   |  i  i i t i ƒ |  i  i i t i ƒ x- t i D]" } |  i i | t i	 | ƒ ƒ q6 Wd S(   s4   Tell new conn about log settings and updated globalsN(
   t   logR    t   setverbosityt	   verbosityt   setterm_verbosityt   term_verbosityR   t   changed_settingst   setRE   (   R   t   setting_name(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyRA   Æ   s
    
 c         C   s=   |  t  _ |  t  i _ t  i d t  i d <t  i t  i |  <d S(   s;   Run on server side to tell self that have given conn_numberi   i    N(   R   t   connection_numberR   RC   R<   RL   (   RC   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyRN   Í   s    	c         C   s   t  i |  ƒ t i |  <d S(   s5   Run on server side - tell about redirected connectionN(   R=   t   RedirectedConnectionR   RL   (   RC   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyRO   Ô   s    c         C   s+   x$ t  i D] } | i  i |  | ƒ q
 Wd S(   s6   Update value of global variable across all connectionsN(   R   R<   RX   (   RY   t   valR   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   UpdateGlobalÙ   s    
 c         C   sD   |  i  i d d ƒ | i  i d d ƒ t d |  ƒ t d | ƒ d S(   s)   Backup specific connection initializationt   isbackup_readeri   t   isbackup_writert   backup_readert   backup_writerN(   R   RX   R]   (   t   reading_connt   writing_conn(    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   BackupInitConnectionsÞ   s    c          C   sq   t  i p t ‚ x t  i D] }  |  i ƒ  q Wt  i d 3h  t  i d <t  _ d t  _ t  _	 t  _
 t  _ d S(   s%   Close all connections.  Run by clienti   i    N(   R   t   servert   AssertionErrorR<   t   quitR   RL   R!   R`   R^   Ra   R_   (   R   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   CloseConnectionså   s    
  
c          C   sP   t  t i ƒ d j o	 d GHn. x* t d t  t i ƒ ƒ D] }  t |  ƒ q8 Wd S(   s"   Test connections, printing resultsi   s   No remote connections specifiedN(   R%   R   R<   t   ranget   test_connection(   R&   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyt   TestConnectionsî   s
     	  c         C   s¿   d Gt  |  GHt i |  } yY | i i d ƒ d j p t ‚ t | i i ƒ  ƒ t	 j p t ‚ | i i d ƒ } Wn t
 i i d ƒ ‚  n X| t i j p d t i | f GHn d GHd S(   s7   Test connection.  conn_number 0 is the local connections   Testing server started by: t   current_timeRD   s   Server tests failed
sJ  Server may work, but there is a version mismatch:
Local version: %s
Remote version: %s

In general, an attempt is made to guarantee compatibility only between
different minor versions of the same stable series.  For instance, you
should expect 0.12.4 and 0.12.7 to be compatible, but not 0.12.7
and 0.13.3, nor 0.13.2 and 0.13.4.
s	   Server OKN(   RP   R   R<   RE   R!   Rf   t   typeR5   t   getuidt   intt   syst   stderrt   writeRD   (   RC   R   RD   (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pyRj   ô   s     #	(   t   __doc__R5   Rp   RR   R    R   R=   R   R   R	   R!   RP   t	   ExceptionR   R   R    R   R   R"   R   R?   R@   RA   RN   RO   R]   Rd   Rh   Rk   Rj   (    (    (    s@   /var/lib/python-support/python2.5/rdiff_backup/SetConnections.pys   <module>   s.   $				"			!									