Viewing File: /usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyc

ó
 c‰`c@sWdZddddddddgZd	d
lZd	dlmZyejdd
ƒWnek
rmeZnAXyd	dlm	Z	e
ZWn#eeej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_importedRR
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_GENERATEDtNM_VOLATILEtAttributeErrortget_unsavedtget_zone(t
connectiontcontsetting_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ƒ}|||<x|D]}|||jƒ<q~Wq1WdS(snGet active connections from NM
    @param connections return dict
    @param connections_name return dict
    N(	tclearRRtget_active_connectionstget_vpntget_idtget_uuidtget_devicest	get_iface(tconnectionstconnections_nametactive_connectionst
active_contnametuuidtdevicestdev((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyRxs




cCsÃtƒg}x¯tƒjƒD]ž}|jƒr5qny6|jƒ}|jƒtjjtjj	B@rjwnWn#t
k
r|jƒr‘qq‘nXx'|jƒD]}|j
|jƒƒqžWqW|S(sGGet active interfaces from NM
    @returns list of interface names
    (RRR'R(tget_connectionRR	RRRRRR+tappendR,(tactive_interfacesR0RR4((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pytnm_get_interfaces’s 


cCsLg}x?tƒD]4}t|ƒ}|t|ƒkr|j|ƒqqW|S(N(R8RRR6(R!t
interfacest	interfacetconn((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pytnm_get_interfaces_in_zone°scCstƒtƒj|ƒ}|dkr)dS|jƒ}|dkrEdSy*|jƒ}|jƒtjj	@rndSWn!t
k
r’|jƒr“dSnX|jƒS(s‰Get connection from NM that is using the interface
    @param interface name
    @returns connection that is using interface or None
    N(
RRtget_device_by_ifaceRtget_active_connectionR5RR	RRRRR*(R:tdeviceR0R((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyR¹s
cCsjts
dSy;tjƒ}|jtjtjƒ}|j}~~|SWnt	k
ret
jdƒnXdS(Ns(Failed to get bus name of NetworkManager(R
Rtdbust	SystemBust
get_objectR	tDBUS_INTERFACEt	DBUS_PATHtbus_namet	ExceptionRtdebug2(tbustobjR1((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyRÔs	
cCsts
dStjS(NR(R
R	RC(((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyRás(!t__doc__t__all__tgit
gi.repositoryRtrequire_versiont
ValueErrorR"R
R	R%tImportErrortErrorRRtfirewallR
tfirewall.errorsRtfirewall.core.loggerRR@RRRRRRR8R<RRR(((s7/usr/lib/python2.7/site-packages/firewall/core/fw_nm.pyt<module>s>



												
Back to Directory File Manager