test,examples: fix scripts to avoid 'has_key' for Python 3
'has_key' on Dictionaries is removed from Python3 in favor of 'in'. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -58,7 +58,7 @@ for c_path in settings.ListConnections():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# add IPv4 setting if it doesn't yet exist
|
# add IPv4 setting if it doesn't yet exist
|
||||||
if not c_settings.has_key('ipv4'):
|
if 'ipv4' not in c_settings:
|
||||||
c_settings['ipv4'] = {}
|
c_settings['ipv4'] = {}
|
||||||
|
|
||||||
# set the method and change properties
|
# set the method and change properties
|
||||||
|
@@ -711,16 +711,16 @@ class NetworkManager(ExportedObj):
|
|||||||
raise UnknownDeviceException("No device found for the requested iface.")
|
raise UnknownDeviceException("No device found for the requested iface.")
|
||||||
|
|
||||||
# See if we need secrets. For the moment, we only support WPA
|
# See if we need secrets. For the moment, we only support WPA
|
||||||
if hash.has_key('802-11-wireless-security'):
|
if '802-11-wireless-security' in hash:
|
||||||
s_wsec = hash['802-11-wireless-security']
|
s_wsec = hash['802-11-wireless-security']
|
||||||
if (s_wsec['key-mgmt'] == 'wpa-psk' and not s_wsec.has_key('psk')):
|
if (s_wsec['key-mgmt'] == 'wpa-psk' and 'psk' not in s_wsec):
|
||||||
secrets = agent_manager.get_secrets(hash, conpath, '802-11-wireless-security')
|
secrets = agent_manager.get_secrets(hash, conpath, '802-11-wireless-security')
|
||||||
if secrets is None:
|
if secrets is None:
|
||||||
raise NoSecretsException("No secret agent available")
|
raise NoSecretsException("No secret agent available")
|
||||||
if not secrets.has_key('802-11-wireless-security'):
|
if '802-11-wireless-security' not in secrets:
|
||||||
raise NoSecretsException("No secrets provided")
|
raise NoSecretsException("No secrets provided")
|
||||||
s_wsec = secrets['802-11-wireless-security']
|
s_wsec = secrets['802-11-wireless-security']
|
||||||
if not s_wsec.has_key('psk'):
|
if 'psk' not in s_wsec:
|
||||||
raise NoSecretsException("No secrets provided")
|
raise NoSecretsException("No secrets provided")
|
||||||
|
|
||||||
ac = ActiveConnection(self._bus, device, connection, None)
|
ac = ActiveConnection(self._bus, device, connection, None)
|
||||||
@@ -930,10 +930,10 @@ class Connection(dbus.service.Object):
|
|||||||
def __init__(self, bus, object_path, settings, remove_func):
|
def __init__(self, bus, object_path, settings, remove_func):
|
||||||
dbus.service.Object.__init__(self, bus, object_path)
|
dbus.service.Object.__init__(self, bus, object_path)
|
||||||
|
|
||||||
if not settings.has_key('connection'):
|
if 'connection' not in settings:
|
||||||
raise MissingSettingException('connection: setting is required')
|
raise MissingSettingException('connection: setting is required')
|
||||||
s_con = settings['connection']
|
s_con = settings['connection']
|
||||||
if not s_con.has_key('type'):
|
if 'type' not in s_con:
|
||||||
raise MissingPropertyException('connection.type: property is required')
|
raise MissingPropertyException('connection.type: property is required')
|
||||||
type = s_con['type']
|
type = s_con['type']
|
||||||
if not type in ['802-3-ethernet', '802-11-wireless', 'vlan', 'wimax']:
|
if not type in ['802-3-ethernet', '802-11-wireless', 'vlan', 'wimax']:
|
||||||
|
Reference in New Issue
Block a user