;ò
\µa@c           @   s‹   d  k  Z  d  k Z d  k Z d Z d Z d „  Z d „  Z d „  Z e e e d „ Z	 e
 d j o& e ƒ  Z e e e i ƒ  d ƒ GHn d  S(	   Ns   /usr/bin/nmblookups   /usr/bin/smbclientc          C   sû  h  } t i t t i ƒ o | Sn g  } t i t i t i ƒ xR t i	 d t d ƒ i
 ƒ  D]4 } | i d ƒ o | i | i d ƒ d ƒ q^ q^ WxZ| D]R} t }  h  d | <} t i t i t i ƒ xt i	 d t | f d ƒ i
 ƒ  D]á } | i ƒ  } | i d ƒ d	 j o qñ n y¨ | i d ƒ d } | i d
 ƒ d	 j o wñ n | i d ƒ d	 j o | i d ƒ o | i d ƒ d | d <n3 | i d ƒ o! | i d ƒ d }  |  | d <n Wqñ qñ Xqñ W|  o q n | | |  <q W| Sd S(   sŠ   Return a dict, indexed by SMB name, of host dicts for this network.

    A host dict has 'NAME' and 'IP' keys, and may have a 'GROUP' key.s   LANG=C %s '*'s   rs    *<00>
s    i    s   IPs   LANG=C %s -A '%s's    <00> iÿÿÿÿs   ~s	    <GROUP> s   GROUPs   NAMEN(   s   hostss   oss   accesss	   nmblookups   X_OKs   ipss   signals   SIGCHLDs   SIG_DFLs   popens	   readliness   ls   endswiths   appends   splits   ips   Nones   names   dicts   strips   finds   vals   has_key(   s   names   vals   ips   ls   ipss   hostss   dict(    (    s"   /usr/share/printconf/util/pysmb.pys   get_host_list   sH      "  'c         C   sû   h  d |  <d d <d d <} xÏ t i d t |  f d ƒ i ƒ  D]« } | i ƒ  } | i d ƒ o | i	 d ƒ d	 | d <qD n | i
 d
 ƒ d j o qD n | i
 d ƒ d j o | i	 d ƒ d	 | d <qD | i	 d ƒ d	 } | | d <qD W| Sd S(   s.   Given an SMB name, returns a host dict for it.s   NAMEs   IPs    s   GROUPs   LANG=C %s -S '%s's   rs   <00>s    i    s    <00> iÿÿÿÿs	    <GROUP> N(   s   smbnames   dicts   oss   popens	   nmblookups	   readliness   ls   strips   endswiths   splits   finds   name(   s   smbnames   names   ls   dict(    (    s"   /usr/share/printconf/util/pysmb.pys   get_host_infoK   s      ! c   
      C   sÇ  h  } t i t t i ƒ o | Sn d t |  d f } |  i d ƒ o | d |  d 7} n |  i d ƒ o | d |  d 7} n t i t i	 t i
 ƒ d }	 xt i | d ƒ D]} | i ƒ  } | d	 j o q´ n | d d
 j o# |	 d 7}	 |	 d j o Pq´ q´ n |	 d j o q´ n | | i d ƒ  } | t | ƒ i ƒ  } | i d ƒ } | d j o | } d	 } n* | | i d ƒ  } | t | ƒ i ƒ  } | d j o | | | <q´ q´ W| Sd S(   sy   Given a host dict, returns a dict of printer shares for that host.
    The value for a printer share name is its comment.s   LANG=C %s -N -L '%s's   NAMEs   IPs    -I '%s's   GROUPs    -W '%s'i    s   rs    s   -i   s    iÿÿÿÿs   PrinterN(   s   printerss   oss   accesss	   smbclients   X_OKs   hosts   strs   has_keys   signals   SIGCHLDs   SIG_DFLs   sections   popens   ls   strips   finds   shares   lens   rests   ends   types   comment(
   s   hosts   comments   ends   types   shares   ls   rests   strs   printerss   section(    (    s"   /usr/share/printconf/util/pysmb.pys   get_printer_list`   sD      

c         C   sú  t  i t t  i ƒ o t Sn t |  g } | o | i | ƒ n | i d ƒ | o | i
 d | g ƒ n | i
 d d g ƒ | o | i
 d | g ƒ n t  i ƒ  \ }	 } t i t i t i ƒ t  i ƒ  } | d j o` t  i |	 ƒ | d j o t  i | d ƒ n d t  i d	 <t  i | d | ƒ t i d ƒ n h  d
 d <}
 t  i | ƒ xl t  i |	 d ƒ i ƒ  D]R } | i d ƒ o | i d ƒ d j o& | t  d ƒ i! d ƒ d |
 d
 <PququWt  i" | d ƒ \ } } | o t Sn |
 Sd S(   sŒ   Returns None if the share is inaccessible.  Otherwise,
    returns a dict with 'GROUP' associated with the workgroup name
    of the server.s   -Ns   -Ws   -cs   quits   -Ui    i   s   Cs   LANGs   GROUPs    s   rs   Domain=[s   ]iÿÿÿÿN($   s   oss   accesss	   smbclients   X_OKs   Nones   shares   argss   passwds   appends   groups   extends   users   pipes   reads   writes   signals   SIGCHLDs   SIG_DFLs   forks   pids   closes   dup2s   environs   execvs   syss   exits   dicts   fdopens	   readliness   ls
   startswiths   finds   lens   splits   waitpids   status(   s   shares   groups   users   passwds   statuss   pids   argss   ls   writes   reads   dict(    (    s"   /usr/share/printconf/util/pysmb.pys   printer_share_accessible   sB      &!	s   __main__i    (   s   oss   signals   syss	   nmblookups	   smbclients   get_host_lists   get_host_infos   get_printer_lists   Nones   printer_share_accessibles   __name__s   hostss   keys(
   s	   nmblookups   get_host_infos   printer_share_accessibles   get_host_lists   signals   syss   hostss   get_printer_lists   oss	   smbclient(    (    s"   /usr/share/printconf/util/pysmb.pys   ?   s   				-		//	