c`c@sWdZddddddddgZd d lZd d lmZyejd d Wnek rmeZnAXyd dlm Z e ZWn#e eej fk reZnXd ad dlmZd dlmZd dlmZd d lZdZdZdZdZdZdZdZdZdZdZdZ d S(s(Functions for NetworkManager interactiontcheck_nm_importedtnm_is_importedtnm_get_zone_of_connectiontnm_set_zone_of_connectiontnm_get_connectionstnm_get_connection_of_interfacetnm_get_bus_nametnm_get_dbus_interfaceiN(tGLibtNMs1.0(R (terrors(t FirewallError(tlogcCststtjdndS(sNCheck function to raise a MISSING_IMPORT error if the import of NM failed sgi.repository.NM = 1.0N(t _nm_importedR R tMISSING_IMPORT(((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyR0scCstS(snReturns true if NM has been properly imported @return True if import was successful, False otherwirse (R (((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyR6scCststjjdantS(sReturns the NM client object or None if the import of NM failed @return NM.Client instance if import was successful, None otherwise N(t _nm_clientR tClienttnewtNone(((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyt nm_get_client<scCsttj|}|dkr)dS|j}|dkrEdSy(|jtjjtjj B@rldSWn!t k r|j rdSnX|j }|dkrd}n|S(sGet zone of connection from NM @param connection name @return zone string setting of connection, empty string if not set, None if connection is unknown tN( RRtget_connection_by_uuidRtget_setting_connectiont get_flagsR tSettingsConnectionFlagst NM_GENERATEDt NM_VOLATILEtAttributeErrort get_unsavedtget_zone(t connectiontcont setting_contzone((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyREs$        cCszttj|}|dkr)tS|j}|dkrEtS|dkrZd}n|jd||jtdS(sSet the zone for a connection @param zone name @param connection name @return True if zone was set, else False RR!N( RRRRtFalseRt set_propertytcommit_changestTrue(R!RRR ((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyRcs     cCs|j|jttj}xo|D]g}|jrIq1n|j}|j}|j}|||s>