ó }”ÍZc@sEdZddddddddgZd 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 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ƒ}x|D]y}|jƒ|kr|jƒ}|dkrSqn|jƒ}|dkrqqn|jƒ}|dkr’d}n|SqWdS(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_active_connectionstget_idtget_connectionRtget_setting_connectiontget_zone(t connectiontactive_connectionst active_contcont setting_contzone((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyREs        cCs²tƒtƒjƒ}x•|D]}|jƒ}|dkrAqn|jƒ|kr|jƒ}|dkrqqn|dkr†d}n|jd|ƒ|jt dƒt SqWt S(sSet the zone for a connection @param zone name @param connection name @return True if zone was set, else False RRN( RRRRRRRt set_propertytcommit_changestTruetFalse(RRRRRR((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyR]s        cCs |jƒ|jƒtƒtƒjƒ}xo|D]g}|jƒrIq1n|jƒ}|jƒ}|jƒ}|||s: