ó  c‰`c@sWdZddddddddgZd d lZd d lmZyejd d ƒWnek rmeZnAXyd dlm Z e ZWn#e eej fk r­eZnXd ad dlmZd dlmZd dlmZd d lZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z 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_interfaceiÿÿÿÿN(tGLibtNMs1.0(R (terrors(t FirewallError(tlogcCststtjdƒ‚ndS(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.pyR6scCststjjdƒantS(sŒReturns 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<scCs¶tƒtƒj|ƒ}|dkr)dS|jƒ}|dkrEdSy(|jƒtjjtjj B@rldSWn!t k r|j ƒr‘dSnX|j ƒ}|dkr²d}n|S(s¤Get 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$        cCsztƒtƒj|ƒ}|dkr)tS|jƒ}|dkrEtS|dkrZd}n|jd|ƒ|jtdƒS(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ƒ|jƒtƒtƒjƒ}xo|D]g}|jƒrIq1n|jƒ}|jƒ}|jƒ}|||s>