U
    9_i                     @   s0   d dl Z d dlmZ ddlT G dd deZdS )    N)TimedOperation   )*c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )CheckLocalServerPublishingc                 C   sJ   t | |d | tdtdd td d tt }|||  d S )NzIs local server publishing?zServer Not Exporting Printersz|Although one or more printers are marked as being shared, this print server is not exporting shared printers to the network.z

zEnable the 'Publish shared printers connected to this system' option in the server settings using the printing administration tool. )Question__init__Zinitial_vbox_ZTEXT_start_print_admin_toolZnew_page)selftroubleshooterZvbox r   K/usr/share/system-config-printer/troubleshoot/CheckLocalServerPublishing.pyr      s    

z#CheckLocalServerPublishing.__init__c                 C   s   i | _ td | j }zx| jtj|d }| j|j|d }t	|dkrVW dS |
 D ]\}}|ddr^ qxq^| j|j|f|d }W n, tk
r   Y dS  tjk
r   Y dS X |ddsdS |ddrdS dS )	N )parentr   Fzprinter-is-shared)argsr   zserver-is-sharing-printersT)ZanswerscupsZ	setServerr   Z
get_windowtimedopZ
ConnectionrunZgetPrinterslenitemsgetZgetPrinterAttributesRuntimeErrorZIPPError)r
   r   cZprintersnameZprinterattrr   r   r   display(   s0    

z"CheckLocalServerPublishing.displayc                 C   s   | j rddiS i S )NZlocal_server_exporting_printersF)Z	displayedr
   r   r   r   collect_answerG   s    z)CheckLocalServerPublishing.collect_answerc                 C   s   | j   d S N)opZcancelr   r   r   r   cancel_operationM   s    z+CheckLocalServerPublishing.cancel_operationc                 O   s   t ||| _| jS r   )r   r   )r
   r   kwargsr   r   r   r   P   s    z"CheckLocalServerPublishing.timedopN)__name__
__module____qualname__r   r   r   r    r   r   r   r   r   r      s
   r   )r   Ztimedopsr   baser   r   r   r   r   r   <module>   s   