tests: Use python3 compatible "except" statement

This patch is made by using 2to3 command.

$ find . -name *.py | xargs 2to3 -f except -w -n

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2019-01-24 16:45:41 +09:00 committed by Jouni Malinen
parent 0dab477335
commit bab493b904
55 changed files with 331 additions and 331 deletions

View File

@ -42,7 +42,7 @@ def wpas_connect():
if os.path.isdir(wpas_ctrl): if os.path.isdir(wpas_ctrl):
try: try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error: except OSError as error:
print "Could not find hostapd: ", error print "Could not find hostapd: ", error
return None return None
@ -54,7 +54,7 @@ def wpas_connect():
try: try:
wpas = wpaspy.Ctrl(ctrl) wpas = wpaspy.Ctrl(ctrl)
return wpas return wpas
except Exception, e: except Exception as e:
pass pass
return None return None
@ -134,7 +134,7 @@ class HandoverServer(nfc.handover.HandoverServer):
summary("HandoverServer - request received") summary("HandoverServer - request received")
try: try:
print "Parsed handover request: " + request.pretty() print "Parsed handover request: " + request.pretty()
except Exception, e: except Exception as e:
print e print e
print str(request).encode("hex") print str(request).encode("hex")
@ -161,7 +161,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "Handover select:" print "Handover select:"
try: try:
print sel.pretty() print sel.pretty()
except Exception, e: except Exception as e:
print e print e
print str(sel).encode("hex") print str(sel).encode("hex")
@ -236,7 +236,7 @@ def rdwr_connected(tag):
print "NDEF tag: " + tag.type print "NDEF tag: " + tag.type
try: try:
print tag.ndef.message.pretty() print tag.ndef.message.pretty()
except Exception, e: except Exception as e:
print e print e
success = wps_tag_read(tag) success = wps_tag_read(tag)
if only_one and success: if only_one and success:
@ -324,7 +324,7 @@ def main():
llcp={'on-startup': llcp_startup, llcp={'on-startup': llcp_startup,
'on-connect': llcp_connected}): 'on-connect': llcp_connected}):
break break
except Exception, e: except Exception as e:
print "clf.connect failed" print "clf.connect failed"
global srv global srv

View File

@ -629,7 +629,7 @@ class FstAP (FstDevice):
self.remove_all_sessions() self.remove_all_sessions()
try: try:
self.send_iface_detach_request(self.iface) self.send_iface_detach_request(self.iface)
except Exception, e: except Exception as e:
logger.info(str(e)) logger.info(str(e))
self.reg_ctrl.stop() self.reg_ctrl.stop()
del self.global_instance del self.global_instance

View File

@ -65,7 +65,7 @@ class HWSimRadio(object):
raise Exception("Failed to create radio (err:%d)" % self._radio_id) raise Exception("Failed to create radio (err:%d)" % self._radio_id)
try: try:
iface = os.listdir('/sys/class/mac80211_hwsim/hwsim%d/net/' % self._radio_id)[0] iface = os.listdir('/sys/class/mac80211_hwsim/hwsim%d/net/' % self._radio_id)[0]
except Exception,e: except Exception as e:
self._controller.destroy_radio(self._radio_id) self._controller.destroy_radio(self._radio_id)
raise e raise e
return self._radio_id, iface return self._radio_id, iface

View File

@ -198,7 +198,7 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
broadcast=broadcast, send_len=send_len) broadcast=broadcast, send_len=send_len)
success = True success = True
break break
except Exception, e: except Exception as e:
last_err = e last_err = e
if i + 1 < max_tries: if i + 1 < max_tries:
time.sleep(1) time.sleep(1)

View File

@ -227,7 +227,7 @@ def go_neg_init(i_dev, r_dev, pin, i_method, i_intent, res):
try: try:
i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=20, go_intent=i_intent) i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=20, go_intent=i_intent)
logger.debug("i_res: " + str(i_res)) logger.debug("i_res: " + str(i_res))
except Exception, e: except Exception as e:
i_res = None i_res = None
logger.info("go_neg_init thread caught an exception from p2p_go_neg_init: " + str(e)) logger.info("go_neg_init thread caught an exception from p2p_go_neg_init: " + str(e))
res.put(i_res) res.put(i_res)
@ -305,7 +305,7 @@ def go_neg_init_pbc(i_dev, r_dev, i_intent, res, freq, provdisc):
timeout=20, go_intent=i_intent, freq=freq, timeout=20, go_intent=i_intent, freq=freq,
provdisc=provdisc) provdisc=provdisc)
logger.debug("i_res: " + str(i_res)) logger.debug("i_res: " + str(i_res))
except Exception, e: except Exception as e:
i_res = None i_res = None
logger.info("go_neg_init_pbc thread caught an exception from p2p_go_neg_init: " + str(e)) logger.info("go_neg_init_pbc thread caught an exception from p2p_go_neg_init: " + str(e))
res.put(i_res) res.put(i_res)

View File

@ -47,7 +47,7 @@ def reset_devs(dev, apdev):
for d in dev: for d in dev:
try: try:
d.reset() d.reset()
except Exception, e: except Exception as e:
logger.info("Failed to reset device " + d.ifname) logger.info("Failed to reset device " + d.ifname)
print str(e) print str(e)
ok = False ok = False
@ -59,7 +59,7 @@ def reset_devs(dev, apdev):
for iface in ifaces: for iface in ifaces:
if iface.startswith("wlan"): if iface.startswith("wlan"):
wpas.interface_remove(iface) wpas.interface_remove(iface)
except Exception, e: except Exception as e:
pass pass
if wpas: if wpas:
wpas.close_ctrl() wpas.close_ctrl()
@ -74,7 +74,7 @@ def reset_devs(dev, apdev):
hapd.remove('wlan3-2') hapd.remove('wlan3-2')
for ap in apdev: for ap in apdev:
hapd.remove(ap['ifname']) hapd.remove(ap['ifname'])
except Exception, e: except Exception as e:
logger.info("Failed to remove hostapd interface") logger.info("Failed to remove hostapd interface")
print str(e) print str(e)
ok = False ok = False
@ -93,7 +93,7 @@ def add_log_file(conn, test, run, type, path):
try: try:
conn.execute(sql, params) conn.execute(sql, params)
conn.commit() conn.commit()
except Exception, e: except Exception as e:
print "sqlite: " + str(e) print "sqlite: " + str(e)
print "sql: %r" % (params, ) print "sql: %r" % (params, )
@ -112,7 +112,7 @@ def report(conn, prefill, build, commit, run, test, result, duration, logdir,
conn.execute(sql, params) conn.execute(sql, params)
if sql_commit: if sql_commit:
conn.commit() conn.commit()
except Exception, e: except Exception as e:
print "sqlite: " + str(e) print "sqlite: " + str(e)
print "sql: %r" % (params, ) print "sql: %r" % (params, )
@ -180,7 +180,7 @@ def rename_log(logdir, basename, testname, dev):
if dev: if dev:
dev.relog() dev.relog()
subprocess.call(['chown', '-f', getpass.getuser(), srcname]) subprocess.call(['chown', '-f', getpass.getuser(), srcname])
except Exception, e: except Exception as e:
logger.info("Failed to rename log files") logger.info("Failed to rename log files")
logger.info(e) logger.info(e)
@ -303,7 +303,7 @@ def main():
params = (name, t.__doc__) params = (name, t.__doc__)
try: try:
conn.execute(sql, params) conn.execute(sql, params)
except Exception, e: except Exception as e:
print "sqlite: " + str(e) print "sqlite: " + str(e)
print "sql: %r" % (params,) print "sql: %r" % (params,)
if conn: if conn:
@ -477,7 +477,7 @@ def main():
if not d.global_ping(): if not d.global_ping():
raise Exception("Global PING failed for {}".format(d.ifname)) raise Exception("Global PING failed for {}".format(d.ifname))
d.request("NOTE TEST-START " + name) d.request("NOTE TEST-START " + name)
except Exception, e: except Exception as e:
logger.info("Failed to issue TEST-START before " + name + " for " + d.ifname) logger.info("Failed to issue TEST-START before " + name + " for " + d.ifname)
logger.info(e) logger.info(e)
print "FAIL " + name + " - could not start test" print "FAIL " + name + " - could not start test"
@ -522,15 +522,15 @@ def main():
print "Country code remains set - expect following test cases to fail" print "Country code remains set - expect following test cases to fail"
logger.info("Country code remains set - expect following test cases to fail") logger.info("Country code remains set - expect following test cases to fail")
break break
except HwsimSkip, e: except HwsimSkip as e:
logger.info("Skip test case: %s" % e) logger.info("Skip test case: %s" % e)
result = "SKIP" result = "SKIP"
except NameError, e: except NameError as e:
import traceback import traceback
logger.info(e) logger.info(e)
traceback.print_exc() traceback.print_exc()
result = "FAIL" result = "FAIL"
except Exception, e: except Exception as e:
import traceback import traceback
logger.info(e) logger.info(e)
traceback.print_exc() traceback.print_exc()
@ -542,7 +542,7 @@ def main():
try: try:
d.dump_monitor() d.dump_monitor()
d.request("NOTE TEST-STOP " + name) d.request("NOTE TEST-STOP " + name)
except Exception, e: except Exception as e:
logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname)) logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname))
logger.info(e) logger.info(e)
result = "FAIL" result = "FAIL"
@ -556,7 +556,7 @@ def main():
rename_log(args.logdir, 'log5', name, wpas) rename_log(args.logdir, 'log5', name, wpas)
if not args.no_reset: if not args.no_reset:
wpas.remove_ifname() wpas.remove_ifname()
except Exception, e: except Exception as e:
pass pass
if wpas: if wpas:
wpas.close_ctrl() wpas.close_ctrl()
@ -565,7 +565,7 @@ def main():
rename_log(args.logdir, 'log' + str(i), name, dev[i]) rename_log(args.logdir, 'log' + str(i), name, dev[i])
try: try:
hapd = HostapdGlobal() hapd = HostapdGlobal()
except Exception, e: except Exception as e:
print "Failed to connect to hostapd interface" print "Failed to connect to hostapd interface"
print str(e) print str(e)
reset_ok = False reset_ok = False

View File

@ -485,7 +485,7 @@ def get_rx_spec(phy, gtk=False):
continue continue
with open(keydir + "/rx_spec") as f: with open(keydir + "/rx_spec") as f:
return f.read() return f.read()
except OSError, e: except OSError as e:
raise HwsimSkip("debugfs not supported in mac80211") raise HwsimSkip("debugfs not supported in mac80211")
return None return None
@ -501,7 +501,7 @@ def get_tk_replay_counter(phy, gtk=False):
continue continue
with open(keydir + "/replays") as f: with open(keydir + "/replays") as f:
return int(f.read()) return int(f.read())
except OSError, e: except OSError as e:
raise HwsimSkip("debugfs not supported in mac80211") raise HwsimSkip("debugfs not supported in mac80211")
return None return None

View File

@ -206,7 +206,7 @@ def invalid_ap(ap):
try: try:
hapd.enable() hapd.enable()
started = True started = True
except Exception, e: except Exception as e:
started = False started = False
if started: if started:
raise Exception("ENABLE command succeeded unexpectedly") raise Exception("ENABLE command succeeded unexpectedly")
@ -516,7 +516,7 @@ def test_ap_duplicate_bssid(dev, apdev):
try: try:
hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf') hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
raise Exception("BSS add succeeded unexpectedly") raise Exception("BSS add succeeded unexpectedly")
except Exception, e: except Exception as e:
if "Could not add hostapd BSS" in str(e): if "Could not add hostapd BSS" in str(e):
pass pass
else: else:

View File

@ -2881,7 +2881,7 @@ def test_ap_wpa2_eap_eke_server_oom(dev, apdev):
if hapd.request("GET_ALLOC_FAIL").startswith('0'): if hapd.request("GET_ALLOC_FAIL").startswith('0'):
break break
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
except Exception, e: except Exception as e:
if str(e) == "Allocation failure did not trigger": if str(e) == "Allocation failure did not trigger":
if count < 30: if count < 30:
raise Exception("Too few allocation failures") raise Exception("Too few allocation failures")
@ -3699,7 +3699,7 @@ def test_ap_wpa2_eap_fast_cipher_suites(dev, apdev):
ca_cert="auth_serv/ca.pem", phase2="auth=GTC", ca_cert="auth_serv/ca.pem", phase2="auth=GTC",
pac_file="blob://fast_pac_ciphers", pac_file="blob://fast_pac_ciphers",
report_failure=True) report_failure=True)
except Exception, e: except Exception as e:
if cipher == "RC4-SHA" and \ if cipher == "RC4-SHA" and \
("Could not select EAP method" in str(e) or \ ("Could not select EAP method" in str(e) or \
"EAP failed" in str(e)): "EAP failed" in str(e)):

View File

@ -446,7 +446,7 @@ def test_ap_ft_ocv(dev, apdev):
params["ocv"] = "1" params["ocv"] = "1"
try: try:
hapd0 = hostapd.add_ap(apdev[0], params) hapd0 = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -582,7 +582,7 @@ def test_ap_ft_over_ds_ocv(dev, apdev):
params["ocv"] = "1" params["ocv"] = "1"
try: try:
hapd0 = hostapd.add_ap(apdev[0], params) hapd0 = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise

View File

@ -4853,7 +4853,7 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False):
try: try:
hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0") hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0")
except Exception, e: except Exception as e:
logger.info("test_connectibity_iface failed: " + str(e)) logger.info("test_connectibity_iface failed: " + str(e))
raise HwsimSkip("Assume kernel did not have the required patches for proxyarp") raise HwsimSkip("Assume kernel did not have the required patches for proxyarp")
hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0") hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0")
@ -5110,7 +5110,7 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False):
try: try:
hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0") hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0")
except Exception, e: except Exception as e:
logger.info("test_connectibity_iface failed: " + str(e)) logger.info("test_connectibity_iface failed: " + str(e))
raise HwsimSkip("Assume kernel did not have the required patches for proxyarp") raise HwsimSkip("Assume kernel did not have the required patches for proxyarp")
hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0") hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0")

View File

@ -330,7 +330,7 @@ def _test_ap_open_wpas_in_bridge(dev, apdev):
try: try:
wpas.interface_add(ifname, br_ifname=br_ifname) wpas.interface_add(ifname, br_ifname=br_ifname)
raise Exception("Interface addition succeeded unexpectedly") raise Exception("Interface addition succeeded unexpectedly")
except Exception, e: except Exception as e:
if "Failed to add" in str(e): if "Failed to add" in str(e):
logger.info("Ignore expected interface_add failure due to missing bridge interface: " + str(e)) logger.info("Ignore expected interface_add failure due to missing bridge interface: " + str(e))
else: else:

View File

@ -666,7 +666,7 @@ def test_ap_missing_psk(dev, apdev):
# "WPA-PSK enabled, but PSK or passphrase is not configured." # "WPA-PSK enabled, but PSK or passphrase is not configured."
hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[0], params)
raise Exception("AP setup succeeded unexpectedly") raise Exception("AP setup succeeded unexpectedly")
except Exception, e: except Exception as e:
if "Failed to enable hostapd" in str(e): if "Failed to enable hostapd" in str(e):
pass pass
else: else:

View File

@ -67,7 +67,7 @@ def test_ocv_sa_query(dev, apdev):
params["ocv"] = "1" params["ocv"] = "1"
try: try:
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -104,7 +104,7 @@ def test_ocv_sa_query_csa(dev, apdev):
params["ocv"] = "1" params["ocv"] = "1"
try: try:
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -194,7 +194,7 @@ def test_ap_pmf_negative(dev, apdev):
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[1], hapd) hwsim_utils.test_connectivity(dev[1], hapd)
raise Exception("PMF required STA connected to no PMF AP") raise Exception("PMF required STA connected to no PMF AP")
except Exception, e: except Exception as e:
logger.debug("Ignore expected exception: " + str(e)) logger.debug("Ignore expected exception: " + str(e))
wt.require_ap_no_pmf(apdev[0]['bssid']) wt.require_ap_no_pmf(apdev[0]['bssid'])

View File

@ -428,7 +428,7 @@ def test_ap_open_tdls_vht80(dev, apdev):
res = cmd.stdout.read() res = cmd.stdout.read()
cmd.stdout.close() cmd.stdout.close()
logger.info("Station dump on dev[%d]:\n%s" % (i, res)) logger.info("Station dump on dev[%d]:\n%s" % (i, res))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -472,7 +472,7 @@ def test_ap_open_tdls_vht80plus80(dev, apdev):
res = cmd.stdout.read() res = cmd.stdout.read()
cmd.stdout.close() cmd.stdout.close()
logger.info("Station dump on dev[%d]:\n%s" % (i, res)) logger.info("Station dump on dev[%d]:\n%s" % (i, res))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -516,7 +516,7 @@ def test_ap_open_tdls_vht160(dev, apdev):
res = cmd.stdout.read() res = cmd.stdout.read()
cmd.stdout.close() cmd.stdout.close()
logger.info("Station dump on dev[%d]:\n%s" % (i, res)) logger.info("Station dump on dev[%d]:\n%s" % (i, res))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")

View File

@ -74,7 +74,7 @@ def test_ap_vht80(dev, apdev):
raise Exception("Missing STA flag: HT") raise Exception("Missing STA flag: HT")
if "[VHT]" not in sta['flags']: if "[VHT]" not in sta['flags']:
raise Exception("Missing STA flag: VHT") raise Exception("Missing STA flag: VHT")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -104,7 +104,7 @@ def vht80_test(apdev, dev, channel, ht_capab):
dev.connect("vht", key_mgmt="NONE", scan_freq=str(5000 + 5 * channel)) dev.connect("vht", key_mgmt="NONE", scan_freq=str(5000 + 5 * channel))
hwsim_utils.test_connectivity(dev, hapd) hwsim_utils.test_connectivity(dev, hapd)
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -165,7 +165,7 @@ def test_ap_vht80_params(dev, apdev):
raise Exception("dev[0] did not support SGI") raise Exception("dev[0] did not support SGI")
if capab2 & 0x60 != 0: if capab2 & 0x60 != 0:
raise Exception("dev[2] claimed support for SGI") raise Exception("dev[2] claimed support for SGI")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -194,7 +194,7 @@ def test_ap_vht80_invalid(dev, apdev):
ev = hapd.wait_event(["AP-DISABLED"], timeout=5) ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
if ev is None: if ev is None:
raise Exception("AP-DISABLED not reported") raise Exception("AP-DISABLED not reported")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -225,7 +225,7 @@ def test_ap_vht80_invalid2(dev, apdev):
ev = hapd.wait_event(["AP-DISABLED"], timeout=5) ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
if ev is None: if ev is None:
raise Exception("AP-DISABLED not reported") raise Exception("AP-DISABLED not reported")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -371,7 +371,7 @@ def test_ap_vht160(dev, apdev):
raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
if "WIDTH=160 MHz" not in sig: if "WIDTH=160 MHz" not in sig:
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -445,7 +445,7 @@ def test_ap_vht160b(dev, apdev):
raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
if "WIDTH=160 MHz" not in sig: if "WIDTH=160 MHz" not in sig:
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -525,7 +525,7 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab):
raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
if "WIDTH=160 MHz" not in sig: if "WIDTH=160 MHz" not in sig:
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -567,7 +567,7 @@ def test_ap_vht160_no_ht40(dev, apdev):
if "AP-ENABLED" in ev: if "AP-ENABLED" in ev:
# This was supposed to fail due to sec_channel_offset == 0 # This was supposed to fail due to sec_channel_offset == 0
raise Exception("Unexpected AP-ENABLED") raise Exception("Unexpected AP-ENABLED")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -634,7 +634,7 @@ def test_ap_vht80plus80(dev, apdev):
raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
if "CENTER_FRQ2=5775" not in sig: if "CENTER_FRQ2=5775" not in sig:
raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig)) raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -671,7 +671,7 @@ def test_ap_vht80plus80_invalid(dev, apdev):
ev = hapd.wait_event(["AP-DISABLED"], timeout=5) ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
if ev is None: if ev is None:
raise Exception("AP-DISABLED not reported") raise Exception("AP-DISABLED not reported")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
@ -723,7 +723,7 @@ def test_ap_vht80_csa(dev, apdev):
# extra code coverage. # extra code coverage.
hapd.request("CHAN_SWITCH 5 5745") hapd.request("CHAN_SWITCH 5 5745")
hapd.wait_event(["AP-CSA-FINISHED"], timeout=1) hapd.wait_event(["AP-CSA-FINISHED"], timeout=1)
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -969,7 +969,7 @@ def test_ap_vht80_pwr_constraint(dev, apdev):
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
dev[0].wait_regdom(country_ie=True) dev[0].wait_regdom(country_ie=True)
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -1003,7 +1003,7 @@ def test_ap_vht_use_sta_nsts(dev, apdev):
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -1050,7 +1050,7 @@ def test_ap_vht_tkip(dev, apdev):
raise Exception("Unexpected STATUS ieee80211ac value") raise Exception("Unexpected STATUS ieee80211ac value")
if status["secondary_channel"] != "0": if status["secondary_channel"] != "0":
raise Exception("Unexpected STATUS secondary_channel value") raise Exception("Unexpected STATUS secondary_channel value")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -1122,7 +1122,7 @@ def test_ap_vht80_to_24g_ht(dev, apdev):
hapd.enable() hapd.enable()
dev[0].connect("vht", key_mgmt="NONE", scan_freq="2412") dev[0].connect("vht", key_mgmt="NONE", scan_freq="2412")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")

View File

@ -294,7 +294,7 @@ def generic_ap_vlan_wpa2_radius_id_change(dev, apdev, tagged):
ifname2="brvlan1") ifname2="brvlan1")
else: else:
hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
except Exception, e: except Exception as e:
# It is possible for new bridge setup to not be ready immediately, so # It is possible for new bridge setup to not be ready immediately, so
# try again to avoid reporting issues related to that. # try again to avoid reporting issues related to that.
logger.info("First VLAN-ID 1 data test failed - try again") logger.info("First VLAN-ID 1 data test failed - try again")

View File

@ -2329,7 +2329,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev):
try: try:
[name,value] = l.split('=', 1) [name,value] = l.split('=', 1)
vals[name] = value vals[name] = value
except ValueError, e: except ValueError as e:
if "# WPS configuration" in l: if "# WPS configuration" in l:
pass pass
else: else:
@ -3322,7 +3322,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
try: try:
conn.request(cmd, "hello") conn.request(cmd, "hello")
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3330,7 +3330,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("HEAD", "hello", "\r\n\r\n", headers) conn.request("HEAD", "hello", "\r\n\r\n", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3338,7 +3338,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("HEAD", "hello", "\r\n\r\n", headers) conn.request("HEAD", "hello", "\r\n\r\n", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3346,7 +3346,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("HEAD", "hello", "\r\n\r\nhello", headers) conn.request("HEAD", "hello", "\r\n\r\nhello", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3368,7 +3368,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("HEAD", 5000 * 'A') conn.request("HEAD", 5000 * 'A')
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3383,7 +3383,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("POST", "hello", 10 * 'A' + "\r\n\r\n", headers) conn.request("POST", "hello", 10 * 'A' + "\r\n\r\n", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3396,7 +3396,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev):
conn.request("POST", "hello", 60000 * 'A' + "\r\n\r\n") conn.request("POST", "hello", 60000 * 'A' + "\r\n\r\n")
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -3442,7 +3442,7 @@ def test_ap_wps_upnp_http_proto_chunked(dev, apdev):
conn.send("0\r\n\r\n") conn.send("0\r\n\r\n")
resp = conn.getresponse() resp = conn.getresponse()
completed = True completed = True
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
if completed: if completed:
@ -3452,14 +3452,14 @@ def test_ap_wps_upnp_http_proto_chunked(dev, apdev):
conn.request("POST", "hello", "80000000\r\na", headers) conn.request("POST", "hello", "80000000\r\na", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
conn.request("POST", "hello", "10000000\r\na", headers) conn.request("POST", "hello", "10000000\r\na", headers)
try: try:
resp = conn.getresponse() resp = conn.getresponse()
except Exception, e: except Exception as e:
pass pass
conn.close() conn.close()
@ -4203,7 +4203,7 @@ def send_wlanevent(url, uuid, data, no_response=False):
if no_response: if no_response:
try: try:
conn.getresponse() conn.getresponse()
except Exception, e: except Exception as e:
pass pass
return return
resp = conn.getresponse() resp = conn.getresponse()
@ -5127,7 +5127,7 @@ def wps_run_pbc_fail_ap(apdev, dev, hapd):
try: try:
dev.flush_scan_cache() dev.flush_scan_cache()
break break
except Exception, e: except Exception as e:
if str(e).startswith("Failed to trigger scan"): if str(e).startswith("Failed to trigger scan"):
# Try again # Try again
time.sleep(1) time.sleep(1)

View File

@ -51,7 +51,7 @@ def prepare_dbus(dev):
path = wpas.GetInterface(dev.ifname) path = wpas.GetInterface(dev.ifname)
if_obj = bus.get_object(WPAS_DBUS_SERVICE, path) if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
return (bus,wpas_obj,path,if_obj) return (bus,wpas_obj,path,if_obj)
except Exception, e: except Exception as e:
raise HwsimSkip("Could not connect to D-Bus: %s" % e) raise HwsimSkip("Could not connect to D-Bus: %s" % e)
class TestDbus(object): class TestDbus(object):
@ -182,7 +182,7 @@ def test_dbus_getall_oom(dev, apdev):
try: try:
props = net_obj.GetAll(WPAS_DBUS_NETWORK, props = net_obj.GetAll(WPAS_DBUS_NETWORK,
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
def dbus_get(dbus, wpas_obj, prop, expect=None, byte_arrays=False): def dbus_get(dbus, wpas_obj, prop, expect=None, byte_arrays=False):
@ -210,7 +210,7 @@ def test_dbus_properties(dev, apdev):
try: try:
dbus_set(dbus, wpas_obj, "DebugLevel", val) dbus_set(dbus, wpas_obj, "DebugLevel", val)
raise Exception("Invalid DebugLevel value accepted: " + str(val)) raise Exception("Invalid DebugLevel value accepted: " + str(val))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
dbus_set(dbus, wpas_obj, "DebugLevel", "msgdump") dbus_set(dbus, wpas_obj, "DebugLevel", "msgdump")
@ -222,7 +222,7 @@ def test_dbus_properties(dev, apdev):
try: try:
dbus_set(dbus, wpas_obj, "DebugTimestamp", "foo") dbus_set(dbus, wpas_obj, "DebugTimestamp", "foo")
raise Exception("Invalid DebugTimestamp value accepted") raise Exception("Invalid DebugTimestamp value accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
dbus_set(dbus, wpas_obj, "DebugTimestamp", True) dbus_set(dbus, wpas_obj, "DebugTimestamp", True)
@ -234,7 +234,7 @@ def test_dbus_properties(dev, apdev):
try: try:
dbus_set(dbus, wpas_obj, "DebugShowKeys", "foo") dbus_set(dbus, wpas_obj, "DebugShowKeys", "foo")
raise Exception("Invalid DebugShowKeys value accepted") raise Exception("Invalid DebugShowKeys value accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
dbus_set(dbus, wpas_obj, "DebugShowKeys", True) dbus_set(dbus, wpas_obj, "DebugShowKeys", True)
@ -261,7 +261,7 @@ def test_dbus_properties(dev, apdev):
try: try:
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray('\x00')) dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray('\x00'))
raise Exception("Invalid WFDIEs value accepted") raise Exception("Invalid WFDIEs value accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray('')) dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(''))
@ -275,7 +275,7 @@ def test_dbus_properties(dev, apdev):
try: try:
dbus_set(dbus, wpas_obj, "EapMethods", res) dbus_set(dbus, wpas_obj, "EapMethods", res)
raise Exception("Invalid Set accepted") raise Exception("Invalid Set accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: Property is read-only" not in str(e): if "InvalidArgs: Property is read-only" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -283,7 +283,7 @@ def test_dbus_properties(dev, apdev):
wpas_obj.SetFoo(WPAS_DBUS_SERVICE, "DebugShowKeys", True, wpas_obj.SetFoo(WPAS_DBUS_SERVICE, "DebugShowKeys", True,
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Unknown method accepted") raise Exception("Unknown method accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownMethod" not in str(e): if "UnknownMethod" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -291,7 +291,7 @@ def test_dbus_properties(dev, apdev):
wpas_obj.Get("foo", "DebugShowKeys", wpas_obj.Get("foo", "DebugShowKeys",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Get accepted") raise Exception("Invalid Get accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: No such property" not in str(e): if "InvalidArgs: No such property" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -301,14 +301,14 @@ def test_dbus_properties(dev, apdev):
test_obj.Get(123, "DebugShowKeys", test_obj.Get(123, "DebugShowKeys",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Get accepted") raise Exception("Invalid Get accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: Invalid arguments" not in str(e): if "InvalidArgs: Invalid arguments" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
try: try:
test_obj.Get(WPAS_DBUS_SERVICE, 123, test_obj.Get(WPAS_DBUS_SERVICE, 123,
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Get accepted") raise Exception("Invalid Get accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: Invalid arguments" not in str(e): if "InvalidArgs: Invalid arguments" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -317,7 +317,7 @@ def test_dbus_properties(dev, apdev):
dbus.ByteArray('', variant_level=2), dbus.ByteArray('', variant_level=2),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set accepted") raise Exception("Invalid Set accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: invalid message format" not in str(e): if "InvalidArgs: invalid message format" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -351,7 +351,7 @@ def test_dbus_invalid_method(dev, apdev):
try: try:
wps.Foo() wps.Foo()
raise Exception("Unknown method accepted") raise Exception("Unknown method accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownMethod" not in str(e): if "UnknownMethod" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -360,7 +360,7 @@ def test_dbus_invalid_method(dev, apdev):
try: try:
test_wps.Start(123) test_wps.Start(123)
raise Exception("WPS.Start with incorrect signature accepted") raise Exception("WPS.Start with incorrect signature accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs: Invalid arg" not in str(e): if "InvalidArgs: Invalid arg" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -537,7 +537,7 @@ def test_dbus_wps_invalid(dev, apdev):
try: try:
wps.Start(args) wps.Start(args)
raise Exception("Invalid WPS.Start() arguments accepted: " + str(args)) raise Exception("Invalid WPS.Start() arguments accepted: " + str(args))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.w1.wpa_supplicant1.InvalidArgs"): if not str(e).startswith("fi.w1.wpa_supplicant1.InvalidArgs"):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -571,7 +571,7 @@ def test_dbus_wps_oom(dev, apdev):
try: try:
bss_obj.Get(WPAS_DBUS_BSS, "Rates", bss_obj.Get(WPAS_DBUS_BSS, "Rates",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
id = dev[0].add_network() id = dev[0].add_network()
@ -1031,7 +1031,7 @@ def test_dbus_scan_invalid(dev, apdev):
try: try:
iface.Scan(t) iface.Scan(t)
raise Exception("Invalid Scan() arguments accepted: " + str(t)) raise Exception("Invalid Scan() arguments accepted: " + str(t))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid Scan(%s): %s" % (str(t), str(e))) raise Exception("Unexpected error message for invalid Scan(%s): %s" % (str(t), str(e)))
@ -1162,7 +1162,7 @@ def test_dbus_scan_busy(dev, apdev):
try: try:
iface.Scan({'Type': 'active', 'AllowRoam': False}) iface.Scan({'Type': 'active', 'AllowRoam': False})
raise Exception("Scan() accepted when busy") raise Exception("Scan() accepted when busy")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "ScanError: Scan request reject" not in str(e): if "ScanError: Scan request reject" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -1436,13 +1436,13 @@ def test_dbus_connect_oom(dev, apdev):
signature='sv') signature='sv')
try: try:
self.netw = iface.AddNetwork(args) self.netw = iface.AddNetwork(args)
except Exception, e: except Exception as e:
logger.info("Exception on AddNetwork: " + str(e)) logger.info("Exception on AddNetwork: " + str(e))
self.loop.quit() self.loop.quit()
return False return False
try: try:
iface.SelectNetwork(self.netw) iface.SelectNetwork(self.netw)
except Exception, e: except Exception as e:
logger.info("Exception on SelectNetwork: " + str(e)) logger.info("Exception on SelectNetwork: " + str(e))
self.loop.quit() self.loop.quit()
@ -1499,14 +1499,14 @@ def test_dbus_while_not_connected(dev, apdev):
try: try:
iface.Disconnect() iface.Disconnect()
raise Exception("Disconnect() accepted when not connected") raise Exception("Disconnect() accepted when not connected")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NotConnected" not in str(e): if "NotConnected" not in str(e):
raise Exception("Unexpected error message for invalid Disconnect: " + str(e)) raise Exception("Unexpected error message for invalid Disconnect: " + str(e))
try: try:
iface.Reattach() iface.Reattach()
raise Exception("Reattach() accepted when not connected") raise Exception("Reattach() accepted when not connected")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NotConnected" not in str(e): if "NotConnected" not in str(e):
raise Exception("Unexpected error message for invalid Reattach: " + str(e)) raise Exception("Unexpected error message for invalid Reattach: " + str(e))
@ -1661,13 +1661,13 @@ def test_dbus_network(dev, apdev):
try: try:
iface.RemoveNetwork(netw) iface.RemoveNetwork(netw)
raise Exception("Invalid RemoveNetwork() accepted") raise Exception("Invalid RemoveNetwork() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NetworkUnknown" not in str(e): if "NetworkUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveNetwork: " + str(e)) raise Exception("Unexpected error message for invalid RemoveNetwork: " + str(e))
try: try:
iface.SelectNetwork(netw) iface.SelectNetwork(netw)
raise Exception("Invalid SelectNetwork() accepted") raise Exception("Invalid SelectNetwork() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NetworkUnknown" not in str(e): if "NetworkUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveNetwork: " + str(e)) raise Exception("Unexpected error message for invalid RemoveNetwork: " + str(e))
@ -1704,7 +1704,7 @@ def test_dbus_network(dev, apdev):
net_obj.Set(WPAS_DBUS_NETWORK, "Enabled", dbus.UInt32(1), net_obj.Set(WPAS_DBUS_NETWORK, "Enabled", dbus.UInt32(1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(Enabled,1) accepted") raise Exception("Invalid Set(Enabled,1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(Enabled,1): " + str(e)) raise Exception("Unexpected error message for invalid Set(Enabled,1): " + str(e))
@ -1734,7 +1734,7 @@ def test_dbus_network(dev, apdev):
try: try:
iface.AddNetwork(args) iface.AddNetwork(args)
raise Exception("Invalid AddNetwork args accepted: " + str(args)) raise Exception("Invalid AddNetwork args accepted: " + str(args))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid AddNetwork: " + str(e)) raise Exception("Unexpected error message for invalid AddNetwork: " + str(e))
@ -1770,7 +1770,7 @@ def test_dbus_network_oom(dev, apdev):
# Currently, AddNetwork() succeeds even if os_strdup() for path # Currently, AddNetwork() succeeds even if os_strdup() for path
# fails, so remove the network if that occurs. # fails, so remove the network if that occurs.
iface.RemoveNetwork(netw) iface.RemoveNetwork(netw)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
for i in range(1, 3): for i in range(1, 3):
@ -1780,7 +1780,7 @@ def test_dbus_network_oom(dev, apdev):
# Currently, AddNetwork() succeeds even if network registration # Currently, AddNetwork() succeeds even if network registration
# fails, so remove the network if that occurs. # fails, so remove the network if that occurs.
iface.RemoveNetwork(netw) iface.RemoveNetwork(netw)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
with alloc_fail_dbus(dev[0], 1, with alloc_fail_dbus(dev[0], 1,
@ -1857,7 +1857,7 @@ def _test_dbus_interface(dev, apdev):
try: try:
wpas.CreateInterface(params) wpas.CreateInterface(params)
raise Exception("Invalid CreateInterface() accepted") raise Exception("Invalid CreateInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InterfaceExists" not in str(e): if "InterfaceExists" not in str(e):
raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) raise Exception("Unexpected error message for invalid CreateInterface: " + str(e))
@ -1865,7 +1865,7 @@ def _test_dbus_interface(dev, apdev):
try: try:
wpas.RemoveInterface(path) wpas.RemoveInterface(path)
raise Exception("Invalid RemoveInterface() accepted") raise Exception("Invalid RemoveInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InterfaceUnknown" not in str(e): if "InterfaceUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e))
@ -1875,7 +1875,7 @@ def _test_dbus_interface(dev, apdev):
try: try:
wpas.CreateInterface(params) wpas.CreateInterface(params)
raise Exception("Invalid CreateInterface() accepted") raise Exception("Invalid CreateInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) raise Exception("Unexpected error message for invalid CreateInterface: " + str(e))
@ -1883,14 +1883,14 @@ def _test_dbus_interface(dev, apdev):
try: try:
wpas.CreateInterface(params) wpas.CreateInterface(params)
raise Exception("Invalid CreateInterface() accepted") raise Exception("Invalid CreateInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) raise Exception("Unexpected error message for invalid CreateInterface: " + str(e))
try: try:
wpas.GetInterface("lo") wpas.GetInterface("lo")
raise Exception("Invalid GetInterface() accepted") raise Exception("Invalid GetInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InterfaceUnknown" not in str(e): if "InterfaceUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e))
@ -1920,7 +1920,7 @@ def test_dbus_interface_oom(dev, apdev):
raise Exception("CreateInterface succeeded during out-of-memory") raise Exception("CreateInterface succeeded during out-of-memory")
if not state.startswith('0:'): if not state.startswith('0:'):
break break
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
for arg in [ 'Driver', 'Ifname', 'ConfigFile', 'BridgeIfname' ]: for arg in [ 'Driver', 'Ifname', 'ConfigFile', 'BridgeIfname' ]:
@ -1939,7 +1939,7 @@ def test_dbus_blob(dev, apdev):
try: try:
iface.AddBlob('blob1', dbus.ByteArray("\x01\x02\x04")) iface.AddBlob('blob1', dbus.ByteArray("\x01\x02\x04"))
raise Exception("Invalid AddBlob() accepted") raise Exception("Invalid AddBlob() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "BlobExists" not in str(e): if "BlobExists" not in str(e):
raise Exception("Unexpected error message for invalid AddBlob: " + str(e)) raise Exception("Unexpected error message for invalid AddBlob: " + str(e))
res = iface.GetBlob('blob1') res = iface.GetBlob('blob1')
@ -1956,13 +1956,13 @@ def test_dbus_blob(dev, apdev):
try: try:
iface.RemoveBlob('blob1') iface.RemoveBlob('blob1')
raise Exception("Invalid RemoveBlob() accepted") raise Exception("Invalid RemoveBlob() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "BlobUnknown" not in str(e): if "BlobUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveBlob: " + str(e)) raise Exception("Unexpected error message for invalid RemoveBlob: " + str(e))
try: try:
iface.GetBlob('blob1') iface.GetBlob('blob1')
raise Exception("Invalid GetBlob() accepted") raise Exception("Invalid GetBlob() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "BlobUnknown" not in str(e): if "BlobUnknown" not in str(e):
raise Exception("Unexpected error message for invalid GetBlob: " + str(e)) raise Exception("Unexpected error message for invalid GetBlob: " + str(e))
@ -2045,14 +2045,14 @@ def test_dbus_tdls_invalid(dev, apdev):
try: try:
iface.TDLSDiscover("foo") iface.TDLSDiscover("foo")
raise Exception("Invalid TDLSDiscover() accepted") raise Exception("Invalid TDLSDiscover() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSDiscover: " + str(e)) raise Exception("Unexpected error message for invalid TDLSDiscover: " + str(e))
try: try:
iface.TDLSStatus("foo") iface.TDLSStatus("foo")
raise Exception("Invalid TDLSStatus() accepted") raise Exception("Invalid TDLSStatus() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSStatus: " + str(e)) raise Exception("Unexpected error message for invalid TDLSStatus: " + str(e))
@ -2063,35 +2063,35 @@ def test_dbus_tdls_invalid(dev, apdev):
try: try:
iface.TDLSSetup("foo") iface.TDLSSetup("foo")
raise Exception("Invalid TDLSSetup() accepted") raise Exception("Invalid TDLSSetup() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSSetup: " + str(e)) raise Exception("Unexpected error message for invalid TDLSSetup: " + str(e))
try: try:
iface.TDLSTeardown("foo") iface.TDLSTeardown("foo")
raise Exception("Invalid TDLSTeardown() accepted") raise Exception("Invalid TDLSTeardown() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSTeardown: " + str(e)) raise Exception("Unexpected error message for invalid TDLSTeardown: " + str(e))
try: try:
iface.TDLSTeardown("00:11:22:33:44:55") iface.TDLSTeardown("00:11:22:33:44:55")
raise Exception("TDLSTeardown accepted for unknown peer") raise Exception("TDLSTeardown accepted for unknown peer")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: error performing TDLS teardown" not in str(e): if "UnknownError: error performing TDLS teardown" not in str(e):
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
try: try:
iface.TDLSChannelSwitch({}) iface.TDLSChannelSwitch({})
raise Exception("Invalid TDLSChannelSwitch() accepted") raise Exception("Invalid TDLSChannelSwitch() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSChannelSwitch: " + str(e)) raise Exception("Unexpected error message for invalid TDLSChannelSwitch: " + str(e))
try: try:
iface.TDLSCancelChannelSwitch("foo") iface.TDLSCancelChannelSwitch("foo")
raise Exception("Invalid TDLSCancelChannelSwitch() accepted") raise Exception("Invalid TDLSCancelChannelSwitch() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid TDLSCancelChannelSwitch: " + str(e)) raise Exception("Unexpected error message for invalid TDLSCancelChannelSwitch: " + str(e))
@ -2227,7 +2227,7 @@ def test_dbus_tdls_channel_switch(dev, apdev):
signature='sv') signature='sv')
try: try:
iface.TDLSChannelSwitch(args) iface.TDLSChannelSwitch(args)
except Exception, e: except Exception as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected exception") raise Exception("Unexpected exception")
@ -2235,7 +2235,7 @@ def test_dbus_tdls_channel_switch(dev, apdev):
args = dbus.Dictionary({}, signature='sv') args = dbus.Dictionary({}, signature='sv')
try: try:
iface.TDLSChannelSwitch(args) iface.TDLSChannelSwitch(args)
except Exception, e: except Exception as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected exception") raise Exception("Unexpected exception")
@ -2244,7 +2244,7 @@ def test_dbus_tdls_channel_switch(dev, apdev):
signature='sv') signature='sv')
try: try:
iface.TDLSChannelSwitch(args) iface.TDLSChannelSwitch(args)
except Exception, e: except Exception as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected exception") raise Exception("Unexpected exception")
@ -2254,7 +2254,7 @@ def test_dbus_tdls_channel_switch(dev, apdev):
signature='sv') signature='sv')
try: try:
iface.TDLSChannelSwitch(args) iface.TDLSChannelSwitch(args)
except Exception, e: except Exception as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected exception") raise Exception("Unexpected exception")
@ -2295,13 +2295,13 @@ def test_dbus_pkcs11(dev, apdev):
try: try:
iface.SetPKCS11EngineAndModulePath("foo", "bar") iface.SetPKCS11EngineAndModulePath("foo", "bar")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: Reinit of the EAPOL" not in str(e): if "Error.Failed: Reinit of the EAPOL" not in str(e):
raise Exception("Unexpected error message for invalid SetPKCS11EngineAndModulePath: " + str(e)) raise Exception("Unexpected error message for invalid SetPKCS11EngineAndModulePath: " + str(e))
try: try:
iface.SetPKCS11EngineAndModulePath("foo", "") iface.SetPKCS11EngineAndModulePath("foo", "")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: Reinit of the EAPOL" not in str(e): if "Error.Failed: Reinit of the EAPOL" not in str(e):
raise Exception("Unexpected error message for invalid SetPKCS11EngineAndModulePath: " + str(e)) raise Exception("Unexpected error message for invalid SetPKCS11EngineAndModulePath: " + str(e))
@ -2352,7 +2352,7 @@ def _test_dbus_apscan(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "ApScan", dbus.Int16(-1), if_obj.Set(WPAS_DBUS_IFACE, "ApScan", dbus.Int16(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(ApScan,-1) accepted") raise Exception("Invalid Set(ApScan,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(ApScan,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(ApScan,-1): " + str(e))
@ -2360,7 +2360,7 @@ def _test_dbus_apscan(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "ApScan", dbus.UInt32(123), if_obj.Set(WPAS_DBUS_IFACE, "ApScan", dbus.UInt32(123),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(ApScan,123) accepted") raise Exception("Invalid Set(ApScan,123) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: ap_scan must be 0, 1, or 2" not in str(e): if "Error.Failed: ap_scan must be 0, 1, or 2" not in str(e):
raise Exception("Unexpected error message for invalid Set(ApScan,123): " + str(e)) raise Exception("Unexpected error message for invalid Set(ApScan,123): " + str(e))
@ -2415,7 +2415,7 @@ def test_dbus_fastreauth(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "FastReauth", dbus.Int16(-1), if_obj.Set(WPAS_DBUS_IFACE, "FastReauth", dbus.Int16(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(FastReauth,-1) accepted") raise Exception("Invalid Set(FastReauth,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(ApScan,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(ApScan,-1): " + str(e))
@ -2444,7 +2444,7 @@ def test_dbus_bss_expire(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireAge", dbus.Int16(-1), if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireAge", dbus.Int16(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(BSSExpireAge,-1) accepted") raise Exception("Invalid Set(BSSExpireAge,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(BSSExpireAge,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(BSSExpireAge,-1): " + str(e))
@ -2452,7 +2452,7 @@ def test_dbus_bss_expire(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireAge", dbus.UInt32(9), if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireAge", dbus.UInt32(9),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(BSSExpireAge,9) accepted") raise Exception("Invalid Set(BSSExpireAge,9) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: BSSExpireAge must be >= 10" not in str(e): if "Error.Failed: BSSExpireAge must be >= 10" not in str(e):
raise Exception("Unexpected error message for invalid Set(BSSExpireAge,9): " + str(e)) raise Exception("Unexpected error message for invalid Set(BSSExpireAge,9): " + str(e))
@ -2460,7 +2460,7 @@ def test_dbus_bss_expire(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireCount", dbus.Int16(-1), if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireCount", dbus.Int16(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(BSSExpireCount,-1) accepted") raise Exception("Invalid Set(BSSExpireCount,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(BSSExpireCount,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(BSSExpireCount,-1): " + str(e))
@ -2468,7 +2468,7 @@ def test_dbus_bss_expire(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireCount", dbus.UInt32(0), if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireCount", dbus.UInt32(0),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(BSSExpireCount,0) accepted") raise Exception("Invalid Set(BSSExpireCount,0) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: BSSExpireCount must be > 0" not in str(e): if "Error.Failed: BSSExpireCount must be > 0" not in str(e):
raise Exception("Unexpected error message for invalid Set(BSSExpireCount,0): " + str(e)) raise Exception("Unexpected error message for invalid Set(BSSExpireCount,0): " + str(e))
@ -2513,7 +2513,7 @@ def _test_dbus_country(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "Country", dbus.Int16(-1), if_obj.Set(WPAS_DBUS_IFACE, "Country", dbus.Int16(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(Country,-1) accepted") raise Exception("Invalid Set(Country,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(Country,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(Country,-1): " + str(e))
@ -2521,7 +2521,7 @@ def _test_dbus_country(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "Country", "F", if_obj.Set(WPAS_DBUS_IFACE, "Country", "F",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(Country,F) accepted") raise Exception("Invalid Set(Country,F) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: invalid country code" not in str(e): if "Error.Failed: invalid country code" not in str(e):
raise Exception("Unexpected error message for invalid Set(Country,F): " + str(e)) raise Exception("Unexpected error message for invalid Set(Country,F): " + str(e))
@ -2560,7 +2560,7 @@ def _test_dbus_scan_interval(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "ScanInterval", dbus.UInt16(100), if_obj.Set(WPAS_DBUS_IFACE, "ScanInterval", dbus.UInt16(100),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(ScanInterval,100) accepted") raise Exception("Invalid Set(ScanInterval,100) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: wrong property type" not in str(e): if "Error.Failed: wrong property type" not in str(e):
raise Exception("Unexpected error message for invalid Set(ScanInterval,100): " + str(e)) raise Exception("Unexpected error message for invalid Set(ScanInterval,100): " + str(e))
@ -2568,7 +2568,7 @@ def _test_dbus_scan_interval(dev, apdev):
if_obj.Set(WPAS_DBUS_IFACE, "ScanInterval", dbus.Int32(-1), if_obj.Set(WPAS_DBUS_IFACE, "ScanInterval", dbus.Int32(-1),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(ScanInterval,-1) accepted") raise Exception("Invalid Set(ScanInterval,-1) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: scan_interval must be >= 0" not in str(e): if "Error.Failed: scan_interval must be >= 0" not in str(e):
raise Exception("Unexpected error message for invalid Set(ScanInterval,-1): " + str(e)) raise Exception("Unexpected error message for invalid Set(ScanInterval,-1): " + str(e))
@ -2626,7 +2626,7 @@ def test_dbus_probe_req_reporting(dev, apdev):
try: try:
t.iface.UnsubscribeProbeReq() t.iface.UnsubscribeProbeReq()
raise Exception("Invalid UnsubscribeProbeReq() accepted") raise Exception("Invalid UnsubscribeProbeReq() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NoSubscription" not in str(e): if "NoSubscription" not in str(e):
raise Exception("Unexpected error message for invalid UnsubscribeProbeReq(): " + str(e)) raise Exception("Unexpected error message for invalid UnsubscribeProbeReq(): " + str(e))
t.group_p2p.Disconnect() t.group_p2p.Disconnect()
@ -2650,7 +2650,7 @@ def test_dbus_probe_req_reporting_oom(dev, apdev):
try: try:
iface.UnsubscribeProbeReq() iface.UnsubscribeProbeReq()
was_subscribed = True was_subscribed = True
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
was_subscribed = False was_subscribed = False
pass pass
@ -2671,14 +2671,14 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
p2p.RejectPeer(path + "/Peers/00112233445566") p2p.RejectPeer(path + "/Peers/00112233445566")
raise Exception("Invalid RejectPeer accepted") raise Exception("Invalid RejectPeer accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: Failed to call wpas_p2p_reject" not in str(e): if "UnknownError: Failed to call wpas_p2p_reject" not in str(e):
raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e)) raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e))
try: try:
p2p.RejectPeer("/foo") p2p.RejectPeer("/foo")
raise Exception("Invalid RejectPeer accepted") raise Exception("Invalid RejectPeer accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e)) raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e))
@ -2691,7 +2691,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
p2p.RemoveClient(t) p2p.RemoveClient(t)
raise Exception("Invalid RemoveClient accepted") raise Exception("Invalid RemoveClient accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid RemoveClient(): " + str(e)) raise Exception("Unexpected error message for invalid RemoveClient(): " + str(e))
@ -2717,7 +2717,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
p2p.Find(dbus.Dictionary(t)) p2p.Find(dbus.Dictionary(t))
raise Exception("Invalid Find accepted") raise Exception("Invalid Find accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Find(): " + str(e)) raise Exception("Unexpected error message for invalid Find(): " + str(e))
@ -2727,7 +2727,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
p2p.RemovePersistentGroup(dbus.ObjectPath(p)) p2p.RemovePersistentGroup(dbus.ObjectPath(p))
raise Exception("Invalid RemovePersistentGroup accepted") raise Exception("Invalid RemovePersistentGroup accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid RemovePersistentGroup: " + str(e)) raise Exception("Unexpected error message for invalid RemovePersistentGroup: " + str(e))
@ -2735,7 +2735,7 @@ def test_dbus_p2p_invalid(dev, apdev):
dev[0].request("P2P_SET disabled 1") dev[0].request("P2P_SET disabled 1")
p2p.Listen(5) p2p.Listen(5)
raise Exception("Invalid Listen accepted") raise Exception("Invalid Listen accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: Could not start P2P listen" not in str(e): if "UnknownError: Could not start P2P listen" not in str(e):
raise Exception("Unexpected error message for invalid Listen: " + str(e)) raise Exception("Unexpected error message for invalid Listen: " + str(e))
finally: finally:
@ -2746,7 +2746,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
test_p2p.Listen("foo") test_p2p.Listen("foo")
raise Exception("Invalid Listen accepted") raise Exception("Invalid Listen accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Listen: " + str(e)) raise Exception("Unexpected error message for invalid Listen: " + str(e))
@ -2754,7 +2754,7 @@ def test_dbus_p2p_invalid(dev, apdev):
dev[0].request("P2P_SET disabled 1") dev[0].request("P2P_SET disabled 1")
p2p.ExtendedListen(dbus.Dictionary({})) p2p.ExtendedListen(dbus.Dictionary({}))
raise Exception("Invalid ExtendedListen accepted") raise Exception("Invalid ExtendedListen accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: failed to initiate a p2p_ext_listen" not in str(e): if "UnknownError: failed to initiate a p2p_ext_listen" not in str(e):
raise Exception("Unexpected error message for invalid ExtendedListen: " + str(e)) raise Exception("Unexpected error message for invalid ExtendedListen: " + str(e))
finally: finally:
@ -2766,7 +2766,7 @@ def test_dbus_p2p_invalid(dev, apdev):
'duration2': 20000, 'interval2': 102400 } 'duration2': 20000, 'interval2': 102400 }
p2p.PresenceRequest(args) p2p.PresenceRequest(args)
raise Exception("Invalid PresenceRequest accepted") raise Exception("Invalid PresenceRequest accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: Failed to invoke presence request" not in str(e): if "UnknownError: Failed to invoke presence request" not in str(e):
raise Exception("Unexpected error message for invalid PresenceRequest: " + str(e)) raise Exception("Unexpected error message for invalid PresenceRequest: " + str(e))
finally: finally:
@ -2776,7 +2776,7 @@ def test_dbus_p2p_invalid(dev, apdev):
params = dbus.Dictionary({'frequency': dbus.Int32(-1)}) params = dbus.Dictionary({'frequency': dbus.Int32(-1)})
p2p.GroupAdd(params) p2p.GroupAdd(params)
raise Exception("Invalid GroupAdd accepted") raise Exception("Invalid GroupAdd accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid GroupAdd: " + str(e)) raise Exception("Unexpected error message for invalid GroupAdd: " + str(e))
@ -2786,14 +2786,14 @@ def test_dbus_p2p_invalid(dev, apdev):
'frequency': 2412}) 'frequency': 2412})
p2p.GroupAdd(params) p2p.GroupAdd(params)
raise Exception("Invalid GroupAdd accepted") raise Exception("Invalid GroupAdd accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid GroupAdd: " + str(e)) raise Exception("Unexpected error message for invalid GroupAdd: " + str(e))
try: try:
p2p.Disconnect() p2p.Disconnect()
raise Exception("Invalid Disconnect accepted") raise Exception("Invalid Disconnect accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: failed to disconnect" not in str(e): if "UnknownError: failed to disconnect" not in str(e):
raise Exception("Unexpected error message for invalid Disconnect: " + str(e)) raise Exception("Unexpected error message for invalid Disconnect: " + str(e))
@ -2801,7 +2801,7 @@ def test_dbus_p2p_invalid(dev, apdev):
dev[0].request("P2P_SET disabled 1") dev[0].request("P2P_SET disabled 1")
p2p.Flush() p2p.Flush()
raise Exception("Invalid Flush accepted") raise Exception("Invalid Flush accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Flush: " + str(e)) raise Exception("Unexpected error message for invalid Flush: " + str(e))
finally: finally:
@ -2815,7 +2815,7 @@ def test_dbus_p2p_invalid(dev, apdev):
'frequency': 2412 } 'frequency': 2412 }
pin = p2p.Connect(args) pin = p2p.Connect(args)
raise Exception("Invalid Connect accepted") raise Exception("Invalid Connect accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Connect: " + str(e)) raise Exception("Unexpected error message for invalid Connect: " + str(e))
finally: finally:
@ -2828,7 +2828,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
pin = p2p.Connect(args) pin = p2p.Connect(args)
raise Exception("Invalid Connect accepted") raise Exception("Invalid Connect accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Connect: " + str(e)) raise Exception("Unexpected error message for invalid Connect: " + str(e))
@ -2837,7 +2837,7 @@ def test_dbus_p2p_invalid(dev, apdev):
args = { 'peer': path } args = { 'peer': path }
pin = p2p.Invite(args) pin = p2p.Invite(args)
raise Exception("Invalid Invite accepted") raise Exception("Invalid Invite accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Invite: " + str(e)) raise Exception("Unexpected error message for invalid Invite: " + str(e))
finally: finally:
@ -2847,7 +2847,7 @@ def test_dbus_p2p_invalid(dev, apdev):
args = { 'foo': 'bar' } args = { 'foo': 'bar' }
pin = p2p.Invite(args) pin = p2p.Invite(args)
raise Exception("Invalid Invite accepted") raise Exception("Invalid Invite accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Connect: " + str(e)) raise Exception("Unexpected error message for invalid Connect: " + str(e))
@ -2870,7 +2870,7 @@ def test_dbus_p2p_invalid(dev, apdev):
try: try:
p2p.ProvisionDiscoveryRequest(p, method) p2p.ProvisionDiscoveryRequest(p, method)
raise Exception("Invalid ProvisionDiscoveryRequest accepted") raise Exception("Invalid ProvisionDiscoveryRequest accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid ProvisionDiscoveryRequest: " + str(e)) raise Exception("Unexpected error message for invalid ProvisionDiscoveryRequest: " + str(e))
@ -2879,7 +2879,7 @@ def test_dbus_p2p_invalid(dev, apdev):
if_obj.Get(WPAS_DBUS_IFACE_P2PDEVICE, "Peers", if_obj.Get(WPAS_DBUS_IFACE_P2PDEVICE, "Peers",
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Get(Peers) accepted") raise Exception("Invalid Get(Peers) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Get(Peers): " + str(e)) raise Exception("Unexpected error message for invalid Get(Peers): " + str(e))
finally: finally:
@ -3075,7 +3075,7 @@ def run_dbus_p2p_discovery(dev, apdev):
try: try:
p2p.RejectPeer(path) p2p.RejectPeer(path)
raise Exception("Invalid RejectPeer accepted") raise Exception("Invalid RejectPeer accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "UnknownError: Failed to call wpas_p2p_reject" not in str(e): if "UnknownError: Failed to call wpas_p2p_reject" not in str(e):
raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e)) raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e))
self.loop.quit() self.loop.quit()
@ -3121,7 +3121,7 @@ def run_dbus_p2p_discovery(dev, apdev):
try: try:
p2p.ExtendedListen(dbus.Dictionary({'foo': 100})) p2p.ExtendedListen(dbus.Dictionary({'foo': 100}))
raise Exception("Invalid ExtendedListen accepted") raise Exception("Invalid ExtendedListen accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid ExtendedListen(): " + str(e)) raise Exception("Unexpected error message for invalid ExtendedListen(): " + str(e))
@ -3191,7 +3191,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.DeleteService(args) p2p.DeleteService(args)
raise Exception("Invalid DeleteService() accepted") raise Exception("Invalid DeleteService() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) raise Exception("Unexpected error message for invalid DeleteService(): " + str(e))
@ -3201,7 +3201,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.DeleteService(args) p2p.DeleteService(args)
raise Exception("Invalid DeleteService() accepted") raise Exception("Invalid DeleteService() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) raise Exception("Unexpected error message for invalid DeleteService(): " + str(e))
@ -3213,7 +3213,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.DeleteService(args) p2p.DeleteService(args)
raise Exception("Invalid DeleteService() accepted") raise Exception("Invalid DeleteService() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) raise Exception("Unexpected error message for invalid DeleteService(): " + str(e))
@ -3233,7 +3233,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.DeleteService(args) p2p.DeleteService(args)
raise Exception("Invalid DeleteService() accepted") raise Exception("Invalid DeleteService() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) raise Exception("Unexpected error message for invalid DeleteService(): " + str(e))
@ -3256,7 +3256,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.AddService(args) p2p.AddService(args)
raise Exception("Invalid AddService() accepted") raise Exception("Invalid AddService() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid AddService(): " + str(e)) raise Exception("Unexpected error message for invalid AddService(): " + str(e))
@ -3266,13 +3266,13 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.ServiceDiscoveryCancelRequest(ref) p2p.ServiceDiscoveryCancelRequest(ref)
raise Exception("Invalid ServiceDiscoveryCancelRequest() accepted") raise Exception("Invalid ServiceDiscoveryCancelRequest() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid AddService(): " + str(e)) raise Exception("Unexpected error message for invalid AddService(): " + str(e))
try: try:
p2p.ServiceDiscoveryCancelRequest(dbus.UInt64(0)) p2p.ServiceDiscoveryCancelRequest(dbus.UInt64(0))
raise Exception("Invalid ServiceDiscoveryCancelRequest() accepted") raise Exception("Invalid ServiceDiscoveryCancelRequest() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid AddService(): " + str(e)) raise Exception("Unexpected error message for invalid AddService(): " + str(e))
@ -3307,7 +3307,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.ServiceDiscoveryRequest(args) p2p.ServiceDiscoveryRequest(args)
raise Exception("Invalid ServiceDiscoveryRequest accepted") raise Exception("Invalid ServiceDiscoveryRequest accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid ServiceDiscoveryRequest(): " + str(e)) raise Exception("Unexpected error message for invalid ServiceDiscoveryRequest(): " + str(e))
@ -3315,7 +3315,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
try: try:
p2p.ServiceDiscoveryResponse(dbus.Dictionary(args, signature='sv')) p2p.ServiceDiscoveryResponse(dbus.Dictionary(args, signature='sv'))
raise Exception("Invalid ServiceDiscoveryResponse accepted") raise Exception("Invalid ServiceDiscoveryResponse accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid ServiceDiscoveryResponse(): " + str(e)) raise Exception("Unexpected error message for invalid ServiceDiscoveryResponse(): " + str(e))
@ -3564,7 +3564,7 @@ def test_dbus_p2p_autogo(dev, apdev):
wps.Start(params) wps.Start(params)
self.exceptions = True self.exceptions = True
raise Exception("Invalid WPS.Start() accepted") raise Exception("Invalid WPS.Start() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
self.exceptions = True self.exceptions = True
raise Exception("Unexpected error message: " + str(e)) raise Exception("Unexpected error message: " + str(e))
@ -3641,7 +3641,7 @@ def test_dbus_p2p_autogo(dev, apdev):
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
self.exceptions = True self.exceptions = True
raise Exception("Invalid Set(WPSVendorExtensions) accepted") raise Exception("Invalid Set(WPSVendorExtensions) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed" not in str(e): if "Error.Failed" not in str(e):
self.exceptions = True self.exceptions = True
raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e))
@ -3652,7 +3652,7 @@ def test_dbus_p2p_autogo(dev, apdev):
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
self.exceptions = True self.exceptions = True
raise Exception("Invalid Set(WPSVendorExtensions) accepted") raise Exception("Invalid Set(WPSVendorExtensions) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
self.exceptions = True self.exceptions = True
raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e))
@ -3663,7 +3663,7 @@ def test_dbus_p2p_autogo(dev, apdev):
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
self.exceptions = True self.exceptions = True
raise Exception("Invalid Set(WPSVendorExtensions) accepted") raise Exception("Invalid Set(WPSVendorExtensions) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed" not in str(e): if "Error.Failed" not in str(e):
self.exceptions = True self.exceptions = True
raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e))
@ -3674,7 +3674,7 @@ def test_dbus_p2p_autogo(dev, apdev):
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
self.exceptions = True self.exceptions = True
raise Exception("Invalid Set(WPSVendorExtensions) accepted") raise Exception("Invalid Set(WPSVendorExtensions) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed" not in str(e): if "Error.Failed" not in str(e):
self.exceptions = True self.exceptions = True
raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e))
@ -3953,7 +3953,7 @@ def test_dbus_p2p_join(dev, apdev):
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res, g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(WPSVendorExtensions) accepted") raise Exception("Invalid Set(WPSVendorExtensions) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: Failed to set property" not in str(e): if "Error.Failed: Failed to set property" not in str(e):
raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e))
@ -4105,7 +4105,7 @@ def _test_dbus_p2p_config(dev, apdev):
dbus_interface=dbus.PROPERTIES_IFACE, dbus_interface=dbus.PROPERTIES_IFACE,
byte_arrays=True) byte_arrays=True)
raise Exception("Invalid Get(P2PDeviceConfig) accepted") raise Exception("Invalid Get(P2PDeviceConfig) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Invite: " + str(e)) raise Exception("Unexpected error message for invalid Invite: " + str(e))
finally: finally:
@ -4118,7 +4118,7 @@ def _test_dbus_p2p_config(dev, apdev):
dbus.Dictionary(changes, signature='sv'), dbus.Dictionary(changes, signature='sv'),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(P2PDeviceConfig) accepted") raise Exception("Invalid Set(P2PDeviceConfig) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "Error.Failed: P2P is not available for this interface" not in str(e): if "Error.Failed: P2P is not available for this interface" not in str(e):
raise Exception("Unexpected error message for invalid Invite: " + str(e)) raise Exception("Unexpected error message for invalid Invite: " + str(e))
finally: finally:
@ -4133,7 +4133,7 @@ def _test_dbus_p2p_config(dev, apdev):
dbus.Dictionary(changes, signature='sv'), dbus.Dictionary(changes, signature='sv'),
dbus_interface=dbus.PROPERTIES_IFACE) dbus_interface=dbus.PROPERTIES_IFACE)
raise Exception("Invalid Set(P2PDeviceConfig) accepted") raise Exception("Invalid Set(P2PDeviceConfig) accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Invite: " + str(e)) raise Exception("Unexpected error message for invalid Invite: " + str(e))
@ -4226,7 +4226,7 @@ def test_dbus_p2p_persistent(dev, apdev):
try: try:
p2p.RemovePersistentGroup(persistent) p2p.RemovePersistentGroup(persistent)
raise Exception("Invalid RemovePersistentGroup accepted") raise Exception("Invalid RemovePersistentGroup accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "NetworkUnknown: There is no such persistent group" not in str(e): if "NetworkUnknown: There is no such persistent group" not in str(e):
raise Exception("Unexpected error message for invalid RemovePersistentGroup: " + str(e)) raise Exception("Unexpected error message for invalid RemovePersistentGroup: " + str(e))
@ -4295,7 +4295,7 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev):
try: try:
pin = p2p.Invite(args) pin = p2p.Invite(args)
raise Exception("Invalid Invite accepted") raise Exception("Invalid Invite accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Invite: " + str(e)) raise Exception("Unexpected error message for invalid Invite: " + str(e))
@ -4412,7 +4412,7 @@ def test_dbus_p2p_go_neg_rx(dev, apdev):
try: try:
p2p.Connect(args) p2p.Connect(args)
raise Exception("Invalid Connect accepted") raise Exception("Invalid Connect accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "ConnectChannelUnsupported" not in str(e): if "ConnectChannelUnsupported" not in str(e):
raise Exception("Unexpected error message for invalid Connect: " + str(e)) raise Exception("Unexpected error message for invalid Connect: " + str(e))
@ -4494,7 +4494,7 @@ def test_dbus_p2p_go_neg_auth(dev, apdev):
try: try:
p2p.Connect(args) p2p.Connect(args)
raise Exception("Invalid Connect accepted") raise Exception("Invalid Connect accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e): if "InvalidArgs" not in str(e):
raise Exception("Unexpected error message for invalid Connect: " + str(e)) raise Exception("Unexpected error message for invalid Connect: " + str(e))
@ -5113,7 +5113,7 @@ def test_dbus_p2p_cancel(dev, apdev):
try: try:
p2p.Cancel() p2p.Cancel()
raise Exception("Unexpected p2p.Cancel() success") raise Exception("Unexpected p2p.Cancel() success")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
pass pass
addr0 = dev[0].p2p_dev_addr() addr0 = dev[0].p2p_dev_addr()
@ -5536,7 +5536,7 @@ def test_dbus_save_config(dev, apdev):
try: try:
iface.SaveConfig() iface.SaveConfig()
raise Exception("SaveConfig() accepted unexpectedly") raise Exception("SaveConfig() accepted unexpectedly")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.w1.wpa_supplicant1.UnknownError: Not allowed to update configuration"): if not str(e).startswith("fi.w1.wpa_supplicant1.UnknownError: Not allowed to update configuration"):
raise Exception("Unexpected error message for SaveConfig(): " + str(e)) raise Exception("Unexpected error message for SaveConfig(): " + str(e))
@ -5557,7 +5557,7 @@ def _test_dbus_vendor_elem(dev, apdev):
ie = dbus.ByteArray("\x00\x00") ie = dbus.ByteArray("\x00\x00")
iface.VendorElemAdd(-1, ie) iface.VendorElemAdd(-1, ie)
raise Exception("Invalid VendorElemAdd() accepted") raise Exception("Invalid VendorElemAdd() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e): if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemAdd[1]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemAdd[1]: " + str(e))
@ -5565,7 +5565,7 @@ def _test_dbus_vendor_elem(dev, apdev):
ie = dbus.ByteArray("") ie = dbus.ByteArray("")
iface.VendorElemAdd(1, ie) iface.VendorElemAdd(1, ie)
raise Exception("Invalid VendorElemAdd() accepted") raise Exception("Invalid VendorElemAdd() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Invalid value" not in str(e): if "InvalidArgs" not in str(e) or "Invalid value" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemAdd[2]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemAdd[2]: " + str(e))
@ -5573,21 +5573,21 @@ def _test_dbus_vendor_elem(dev, apdev):
ie = dbus.ByteArray("\x00\x01") ie = dbus.ByteArray("\x00\x01")
iface.VendorElemAdd(1, ie) iface.VendorElemAdd(1, ie)
raise Exception("Invalid VendorElemAdd() accepted") raise Exception("Invalid VendorElemAdd() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Parse error" not in str(e): if "InvalidArgs" not in str(e) or "Parse error" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemAdd[3]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemAdd[3]: " + str(e))
try: try:
iface.VendorElemGet(-1) iface.VendorElemGet(-1)
raise Exception("Invalid VendorElemGet() accepted") raise Exception("Invalid VendorElemGet() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e): if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemGet[1]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemGet[1]: " + str(e))
try: try:
iface.VendorElemGet(1) iface.VendorElemGet(1)
raise Exception("Invalid VendorElemGet() accepted") raise Exception("Invalid VendorElemGet() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "ID value does not exist" not in str(e): if "InvalidArgs" not in str(e) or "ID value does not exist" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemGet[2]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemGet[2]: " + str(e))
@ -5595,7 +5595,7 @@ def _test_dbus_vendor_elem(dev, apdev):
ie = dbus.ByteArray("\x00\x00") ie = dbus.ByteArray("\x00\x00")
iface.VendorElemRem(-1, ie) iface.VendorElemRem(-1, ie)
raise Exception("Invalid VendorElemRemove() accepted") raise Exception("Invalid VendorElemRemove() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e): if "InvalidArgs" not in str(e) or "Invalid ID" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
@ -5603,7 +5603,7 @@ def _test_dbus_vendor_elem(dev, apdev):
ie = dbus.ByteArray("") ie = dbus.ByteArray("")
iface.VendorElemRem(1, ie) iface.VendorElemRem(1, ie)
raise Exception("Invalid VendorElemRemove() accepted") raise Exception("Invalid VendorElemRemove() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Invalid value" not in str(e): if "InvalidArgs" not in str(e) or "Invalid value" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
@ -5634,7 +5634,7 @@ def _test_dbus_vendor_elem(dev, apdev):
test_ie = dbus.ByteArray("\x01\x01") test_ie = dbus.ByteArray("\x01\x01")
iface.VendorElemRem(1, test_ie) iface.VendorElemRem(1, test_ie)
raise Exception("Invalid VendorElemRemove() accepted") raise Exception("Invalid VendorElemRemove() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "Parse error" not in str(e): if "InvalidArgs" not in str(e) or "Parse error" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
@ -5647,7 +5647,7 @@ def _test_dbus_vendor_elem(dev, apdev):
try: try:
iface.VendorElemGet(1) iface.VendorElemGet(1)
raise Exception("Invalid VendorElemGet() accepted after removal") raise Exception("Invalid VendorElemGet() accepted after removal")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidArgs" not in str(e) or "ID value does not exist" not in str(e): if "InvalidArgs" not in str(e) or "ID value does not exist" not in str(e):
raise Exception("Unexpected error message for invalid VendorElemGet after removal: " + str(e)) raise Exception("Unexpected error message for invalid VendorElemGet after removal: " + str(e))

View File

@ -36,7 +36,7 @@ def prepare_dbus(dev):
path = wpas.getInterface(dev.ifname) path = wpas.getInterface(dev.ifname)
if_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, path) if_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, path)
return (bus,wpas_obj,path,if_obj) return (bus,wpas_obj,path,if_obj)
except Exception, e: except Exception as e:
raise HwsimSkip("Could not connect to D-Bus: %s" % e) raise HwsimSkip("Could not connect to D-Bus: %s" % e)
class TestDbusOldWps(TestDbus): class TestDbusOldWps(TestDbus):
@ -83,7 +83,7 @@ def test_dbus_old(dev, apdev):
try: try:
if_obj.setAPScan(t, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.setAPScan(t, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid setAPScan() accepted") raise Exception("Invalid setAPScan() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidOptions" not in str(e): if "InvalidOptions" not in str(e):
raise Exception("Unexpected error message for invalid setAPScan: " + str(e)) raise Exception("Unexpected error message for invalid setAPScan: " + str(e))
@ -93,7 +93,7 @@ def test_dbus_old(dev, apdev):
try: try:
obj.disable(dbus_interface=WPAS_DBUS_OLD_NETWORK) obj.disable(dbus_interface=WPAS_DBUS_OLD_NETWORK)
raise Exception("Invalid disable() accepted") raise Exception("Invalid disable() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidNetwork" not in str(e): if "InvalidNetwork" not in str(e):
raise Exception("Unexpected error message for invalid disable: " + str(e)) raise Exception("Unexpected error message for invalid disable: " + str(e))
@ -103,7 +103,7 @@ def test_dbus_old(dev, apdev):
try: try:
obj.properties(dbus_interface=WPAS_DBUS_OLD_BSSID) obj.properties(dbus_interface=WPAS_DBUS_OLD_BSSID)
raise Exception("Invalid properties() accepted") raise Exception("Invalid properties() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidBSSID" not in str(e): if "InvalidBSSID" not in str(e):
raise Exception("Unexpected error message for invalid properties: " + str(e)) raise Exception("Unexpected error message for invalid properties: " + str(e))
@ -162,7 +162,7 @@ def test_dbus_old_scan(dev, apdev):
try: try:
bss_obj.properties2(dbus_interface=WPAS_DBUS_OLD_BSSID) bss_obj.properties2(dbus_interface=WPAS_DBUS_OLD_BSSID)
raise Exception("Unknown BSSID method accepted") raise Exception("Unknown BSSID method accepted")
except Exception, e: except Exception as e:
logger.debug("Unknown BSSID method exception: " + str(e)) logger.debug("Unknown BSSID method exception: " + str(e))
if not if_obj.flush(0, dbus_interface=WPAS_DBUS_OLD_IFACE): if not if_obj.flush(0, dbus_interface=WPAS_DBUS_OLD_IFACE):
@ -175,13 +175,13 @@ def test_dbus_old_scan(dev, apdev):
try: try:
if_obj.flush("foo", dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.flush("foo", dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid flush arguments accepted") raise Exception("Invalid flush arguments accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid flush: " + str(e)) raise Exception("Unexpected error message for invalid flush: " + str(e))
try: try:
bss_obj.properties(dbus_interface=WPAS_DBUS_OLD_BSSID, bss_obj.properties(dbus_interface=WPAS_DBUS_OLD_BSSID,
byte_arrays=True) byte_arrays=True)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidBSSID"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidBSSID"):
raise Exception("Unexpected error message for invalid BSS: " + str(e)) raise Exception("Unexpected error message for invalid BSS: " + str(e))
@ -193,14 +193,14 @@ def test_dbus_old_debug(dev, apdev):
try: try:
wpas.setDebugParams(123) wpas.setDebugParams(123)
raise Exception("Invalid setDebugParams accepted") raise Exception("Invalid setDebugParams accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidOptions" not in str(e): if "InvalidOptions" not in str(e):
raise Exception("Unexpected error message for invalid setDebugParam: " + str(e)) raise Exception("Unexpected error message for invalid setDebugParam: " + str(e))
try: try:
wpas.setDebugParams(123, True, True) wpas.setDebugParams(123, True, True)
raise Exception("Invalid setDebugParams accepted") raise Exception("Invalid setDebugParams accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidOptions" not in str(e): if "InvalidOptions" not in str(e):
raise Exception("Unexpected error message for invalid setDebugParam: " + str(e)) raise Exception("Unexpected error message for invalid setDebugParam: " + str(e))
@ -233,7 +233,7 @@ def test_dbus_old_smartcard(dev, apdev):
try: try:
if_obj.setSmartcardModules(t, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.setSmartcardModules(t, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid setSmartcardModules accepted: " + str(t)) raise Exception("Invalid setSmartcardModules accepted: " + str(t))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid setSmartcardModules(%s): %s" % (str(t), str(e))) raise Exception("Unexpected error message for invalid setSmartcardModules(%s): %s" % (str(t), str(e)))
@ -266,7 +266,7 @@ def test_dbus_old_interface(dev, apdev):
try: try:
wpas.getInterface(ifname) wpas.getInterface(ifname)
raise Exception("Invalid getInterface accepted") raise Exception("Invalid getInterface accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid getInterface: " + str(e)) raise Exception("Unexpected error message for invalid getInterface: " + str(e))
@ -278,7 +278,7 @@ def test_dbus_old_interface(dev, apdev):
try: try:
wpas.removeInterface(path) wpas.removeInterface(path)
raise Exception("Invalid removeInterface() accepted") raise Exception("Invalid removeInterface() accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidInterface" not in str(e): if "InvalidInterface" not in str(e):
raise Exception("Unexpected error message for invalid removeInterface: " + str(e)) raise Exception("Unexpected error message for invalid removeInterface: " + str(e))
@ -302,14 +302,14 @@ def test_dbus_old_interface(dev, apdev):
else: else:
wpas.addInterface(ifname, params) wpas.addInterface(ifname, params)
raise Exception("Invalid addInterface accepted: " + str(params)) raise Exception("Invalid addInterface accepted: " + str(params))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid addInterface(%s): %s" % (str(params), str(e))) raise Exception("Unexpected error message for invalid addInterface(%s): %s" % (str(params), str(e)))
try: try:
wpas.removeInterface(123) wpas.removeInterface(123)
raise Exception("Invalid removeInterface accepted") raise Exception("Invalid removeInterface accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid removeInterface: " + str(e)) raise Exception("Unexpected error message for invalid removeInterface: " + str(e))
@ -345,7 +345,7 @@ def test_dbus_old_blob(dev, apdev):
try: try:
if_obj.setBlobs(arg, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.setBlobs(arg, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid setBlobs() accepted: " + str(arg)) raise Exception("Invalid setBlobs() accepted: " + str(arg))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
logger.debug("setBlobs(%s): %s" % (str(arg), str(e))) logger.debug("setBlobs(%s): %s" % (str(arg), str(e)))
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid setBlobs: " + str(e)) raise Exception("Unexpected error message for invalid setBlobs: " + str(e))
@ -358,7 +358,7 @@ def test_dbus_old_blob(dev, apdev):
try: try:
if_obj.removeBlobs(arg, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.removeBlobs(arg, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid removeBlobs() accepted: " + str(arg)) raise Exception("Invalid removeBlobs() accepted: " + str(arg))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
logger.debug("removeBlobs(%s): %s" % (str(arg), str(e))) logger.debug("removeBlobs(%s): %s" % (str(arg), str(e)))
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid removeBlobs: " + str(e)) raise Exception("Unexpected error message for invalid removeBlobs: " + str(e))
@ -412,21 +412,21 @@ def test_dbus_old_connect(dev, apdev):
try: try:
if_obj.removeNetwork(obj, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.removeNetwork(obj, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid removeNetwork accepted: " + p) raise Exception("Invalid removeNetwork accepted: " + p)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"):
raise Exception("Unexpected error message for invalid removeNetwork: " + str(e)) raise Exception("Unexpected error message for invalid removeNetwork: " + str(e))
try: try:
if_obj.removeNetwork("foo", dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.removeNetwork("foo", dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid removeNetwork accepted") raise Exception("Invalid removeNetwork accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid removeNetwork: " + str(e)) raise Exception("Unexpected error message for invalid removeNetwork: " + str(e))
try: try:
if_obj.removeNetwork(path, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.removeNetwork(path, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid removeNetwork accepted") raise Exception("Invalid removeNetwork accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"):
raise Exception("Unexpected error message for invalid removeNetwork: " + str(e)) raise Exception("Unexpected error message for invalid removeNetwork: " + str(e))
@ -442,7 +442,7 @@ def test_dbus_old_connect(dev, apdev):
try: try:
if_obj.selectNetwork(t, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.selectNetwork(t, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid selectNetwork accepted: " + str(t)) raise Exception("Invalid selectNetwork accepted: " + str(t))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if err not in str(e): if err not in str(e):
raise Exception("Unexpected error message for invalid selectNetwork(%s): %s" % (str(t), str(e))) raise Exception("Unexpected error message for invalid selectNetwork(%s): %s" % (str(t), str(e)))
@ -456,7 +456,7 @@ def test_dbus_old_connect(dev, apdev):
try: try:
netw_obj.set(t, dbus_interface=WPAS_DBUS_OLD_NETWORK) netw_obj.set(t, dbus_interface=WPAS_DBUS_OLD_NETWORK)
raise Exception("Invalid set() accepted: " + str(t)) raise Exception("Invalid set() accepted: " + str(t))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidOptions" not in str(e): if "InvalidOptions" not in str(e):
raise Exception("Unexpected error message for invalid set: " + str(e)) raise Exception("Unexpected error message for invalid set: " + str(e))
params = dbus.Dictionary({ 'ssid': ssid, params = dbus.Dictionary({ 'ssid': ssid,
@ -521,7 +521,7 @@ def test_dbus_old_connect(dev, apdev):
if_obj.removeNetwork(self.path, if_obj.removeNetwork(self.path,
dbus_interface=WPAS_DBUS_OLD_IFACE) dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid removeNetwork accepted") raise Exception("Invalid removeNetwork accepted")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.Interface.InvalidNetwork"):
raise Exception("Unexpected error message for invalid wpsPbc: " + str(e)) raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
@ -637,7 +637,7 @@ def test_dbus_old_network_set(dev, apdev):
try: try:
netw_obj.set(params, dbus_interface=WPAS_DBUS_OLD_NETWORK) netw_obj.set(params, dbus_interface=WPAS_DBUS_OLD_NETWORK)
raise Exception("set succeeded with unexpected type") raise Exception("set succeeded with unexpected type")
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if "InvalidOptions" not in str(e): if "InvalidOptions" not in str(e):
raise Exception("Unexpected error message for unexpected type: " + str(e)) raise Exception("Unexpected error message for unexpected type: " + str(e))
@ -662,7 +662,7 @@ def _test_dbus_old_wps_pbc(dev, apdev):
try: try:
if_obj.wpsPbc(arg, dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.wpsPbc(arg, dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid wpsPbc arguments accepted: " + str(arg)) raise Exception("Invalid wpsPbc arguments accepted: " + str(arg))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid wpsPbc: " + str(e)) raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
@ -730,7 +730,7 @@ def _test_dbus_old_wps_pin(dev, apdev):
try: try:
if_obj.wpsPin(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.wpsPin(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid wpsPin arguments accepted: " + str(arg)) raise Exception("Invalid wpsPin arguments accepted: " + str(arg))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid wpsPbc: " + str(e)) raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
@ -784,7 +784,7 @@ def _test_dbus_old_wps_reg(dev, apdev):
try: try:
if_obj.wpsReg(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE) if_obj.wpsReg(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
raise Exception("Invalid wpsReg arguments accepted: " + str(arg)) raise Exception("Invalid wpsReg arguments accepted: " + str(arg))
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException as e:
if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"): if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
raise Exception("Unexpected error message for invalid wpsPbc: " + str(e)) raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))

View File

@ -198,7 +198,7 @@ def test_fils_sk_pmksa_caching_ocv(dev, apdev, params):
params['ocv'] = '1' params['ocv'] = '1'
try: try:
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise

View File

@ -243,7 +243,7 @@ class FstLauncher:
try: try:
pid = int(pidtxt) pid = int(pidtxt)
break break
except Exception, e: except Exception as e:
self.logger.debug("kill_pid: No valid PID found: %s" % str(e)) self.logger.debug("kill_pid: No valid PID found: %s" % str(e))
time.sleep(1) time.sleep(1)
self.logger.debug("kill_pid %s --> pid %d" % (pidfile, pid)) self.logger.debug("kill_pid %s --> pid %d" % (pidfile, pid))
@ -257,7 +257,7 @@ class FstLauncher:
break break
# Wait and check again # Wait and check again
time.sleep(1) time.sleep(1)
except Exception, e: except Exception as e:
self.logger.debug("Didn't stop the pid=%d. Was it stopped already? (%s)" % (pid, str(e))) self.logger.debug("Didn't stop the pid=%d. Was it stopped already? (%s)" % (pid, str(e)))

View File

@ -142,7 +142,7 @@ def fst_start_session(apdev, test_params, bad_param_type, start_on_ap,
sid = '-1' sid = '-1'
initiator.set_fst_parameters(llt=llt) initiator.set_fst_parameters(llt=llt)
initiator.configure_session(sid, new_iface, old_iface) initiator.configure_session(sid, new_iface, old_iface)
except Exception, e: except Exception as e:
if e.args[0].startswith("Cannot add FST session with groupid"): if e.args[0].startswith("Cannot add FST session with groupid"):
if bad_param_type == bad_param_group_id or bad_param_type == bad_param_session_add_no_params: if bad_param_type == bad_param_group_id or bad_param_type == bad_param_session_add_no_params:
bad_parameter_detected = True bad_parameter_detected = True
@ -302,7 +302,7 @@ def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap):
bad_parameter_detected = True bad_parameter_detected = True
else: else:
initiator.initiate_session(sid, "accept") initiator.initiate_session(sid, "accept")
except Exception, e: except Exception as e:
if e.args[0].startswith("Cannot initiate fst session"): if e.args[0].startswith("Cannot initiate fst session"):
if bad_param_type != bad_param_none: if bad_param_type != bad_param_none:
bad_parameter_detected = True bad_parameter_detected = True
@ -364,7 +364,7 @@ def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap,
elif bad_param_type == bad_param_session_transfer_bad_session_id: elif bad_param_type == bad_param_session_transfer_bad_session_id:
sid = '-1' sid = '-1'
initiator.transfer_session(sid) initiator.transfer_session(sid)
except Exception, e: except Exception as e:
if e.args[0].startswith("Cannot transfer fst session"): if e.args[0].startswith("Cannot transfer fst session"):
if bad_param_type != bad_param_none: if bad_param_type != bad_param_none:
bad_parameter_detected = True bad_parameter_detected = True
@ -427,7 +427,7 @@ def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap):
elif bad_param_type == bad_param_session_teardown_bad_session_id: elif bad_param_type == bad_param_session_teardown_bad_session_id:
sid = '-1' sid = '-1'
initiator.teardown_session(sid) initiator.teardown_session(sid)
except Exception, e: except Exception as e:
if e.args[0].startswith("Cannot tear down fst session"): if e.args[0].startswith("Cannot tear down fst session"):
if (bad_param_type == bad_param_session_teardown_no_params or if (bad_param_type == bad_param_session_teardown_no_params or
bad_param_type == bad_param_session_teardown_bad_session_id or bad_param_type == bad_param_session_teardown_bad_session_id or
@ -503,7 +503,7 @@ def fst_remove_session(apdev, test_params, remove_session_scenario, init_on_ap):
elif remove_session_scenario == remove_scenario_bad_session_id: elif remove_session_scenario == remove_scenario_bad_session_id:
sid = '-1' sid = '-1'
initiator.remove_session(sid) initiator.remove_session(sid)
except Exception, e: except Exception as e:
if e.args[0].startswith("Cannot remove fst session"): if e.args[0].startswith("Cannot remove fst session"):
if (remove_session_scenario == remove_scenario_no_params or if (remove_session_scenario == remove_scenario_no_params or
remove_session_scenario == remove_scenario_bad_session_id): remove_session_scenario == remove_scenario_bad_session_id):
@ -592,7 +592,7 @@ def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, addi
#fsts_id doesn't matter, no actual session exists #fsts_id doesn't matter, no actual session exists
sender.send_test_tear_down('0') sender.send_test_tear_down('0')
receiver.wait_for_session_event(5) receiver.wait_for_session_event(5)
except Exception, e: except Exception as e:
if e.args[0].startswith("No FST-EVENT-SESSION received"): if e.args[0].startswith("No FST-EVENT-SESSION received"):
if frame_type != frame_type_session_request: if frame_type != frame_type_session_request:
frame_receive_timeout = True frame_receive_timeout = True
@ -716,7 +716,7 @@ def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap):
responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"]) responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
else: else:
raise Exception("Unknown bad scenario identifier") raise Exception("Unknown bad scenario identifier")
except Exception, e: except Exception as e:
if e.args[0].startswith("No FST-EVENT-SESSION received"): if e.args[0].startswith("No FST-EVENT-SESSION received"):
bad_parameter_detected = True bad_parameter_detected = True
if not bad_parameter_detected: if not bad_parameter_detected:
@ -753,7 +753,7 @@ def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -773,7 +773,7 @@ def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params):
res_sta2_mbies = sta2.get_local_mbies() res_sta2_mbies = sta2.get_local_mbies()
if res_sta2_mbies == orig_sta2_mbies: if res_sta2_mbies == orig_sta2_mbies:
raise Exception("Failure. MB IEs have not been updated") raise Exception("Failure. MB IEs have not been updated")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -792,7 +792,7 @@ def test_fst_ap_connect_to_fst_sta(dev, apdev, test_params):
res_ap_mbies = ap1.get_local_mbies() res_ap_mbies = ap1.get_local_mbies()
if res_ap_mbies != orig_ap_mbies: if res_ap_mbies != orig_ap_mbies:
raise Exception("Failure. MB IEs have been unexpectedly updated on the AP") raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -811,7 +811,7 @@ def test_fst_ap_connect_to_non_fst_sta(dev, apdev, test_params):
res_ap_mbies = ap2.get_local_mbies() res_ap_mbies = ap2.get_local_mbies()
if res_ap_mbies != orig_ap_mbies: if res_ap_mbies != orig_ap_mbies:
raise Exception("Failure. MB IEs have been unexpectedly updated on the AP") raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -839,7 +839,7 @@ def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -869,7 +869,7 @@ def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -900,7 +900,7 @@ def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -931,7 +931,7 @@ def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -964,7 +964,7 @@ def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
res_sta1_mbies.startswith("FAIL") or res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")): res_sta2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs must be present on the stations") raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -1014,7 +1014,7 @@ def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params):
addr_sta2_mbie1 != addr_sta2_mbie2 or addr_sta2_mbie1 != addr_sta2_mbie2 or
addr_sta2_mbie1 != addr_sta1_str): addr_sta2_mbie1 != addr_sta1_str):
raise Exception("Failure. STA Address in MB IEs should have been same as the other STA's") raise Exception("Failure. STA Address in MB IEs should have been same as the other STA's")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -1045,7 +1045,7 @@ def test_fst_disconnect_non_fst_sta(dev, apdev, test_params):
res_ap_mbies = ap2.get_local_mbies() res_ap_mbies = ap2.get_local_mbies()
if res_ap_mbies != orig_ap_mbies: if res_ap_mbies != orig_ap_mbies:
raise Exception("Failure. MB IEs have been unexpectedly updated on the AP") raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -1076,7 +1076,7 @@ def test_fst_disconnect_fst_sta(dev, apdev, test_params):
res_ap_mbies = ap2.get_local_mbies() res_ap_mbies = ap2.get_local_mbies()
if res_ap_mbies != orig_ap_mbies: if res_ap_mbies != orig_ap_mbies:
raise Exception("Failure. MB IEs have been unexpectedly updated on the AP") raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -1137,7 +1137,7 @@ def test_fst_dynamic_iface_attach(dev, apdev, test_params):
res_sta2_mbies.startswith("FAIL") or res_sta2_mbies.startswith("FAIL") or
res_ap2_mbies.startswith("FAIL")): res_ap2_mbies.startswith("FAIL")):
raise Exception("Failure. MB IEs should have appeared on the station and on the AP") raise Exception("Failure. MB IEs should have appeared on the station and on the AP")
except Exception, e: except Exception as e:
logger.info(e) logger.info(e)
raise raise
finally: finally:
@ -1498,13 +1498,13 @@ def test_fst_ap_ctrl_iface(dev, apdev, test_params):
ap1.send_iface_attach_request(ap1.iface, ap1.fst_group, ap1.send_iface_attach_request(ap1.iface, ap1.fst_group,
ap1.fst_llt, ap1.fst_pri) ap1.fst_llt, ap1.fst_pri)
raise Exception("Duplicate FST-ATTACH succeeded") raise Exception("Duplicate FST-ATTACH succeeded")
except Exception, e: except Exception as e:
if not str(e).startswith("Cannot attach"): if not str(e).startswith("Cannot attach"):
raise raise
try: try:
ap1.get_fsts_id_by_sid("123") ap1.get_fsts_id_by_sid("123")
except Exception, e: except Exception as e:
if not str(e).startswith("Cannot get fsts_id for sid"): if not str(e).startswith("Cannot get fsts_id for sid"):
raise raise
finally: finally:
@ -2537,7 +2537,7 @@ def _test_fst_setup_mbie_diff(dev, apdev, test_params):
with alloc_fail(hapd, 1, "mb_ies_by_info"): with alloc_fail(hapd, 1, "mb_ies_by_info"):
fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie, fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie,
mbie, no_wait=True) mbie, no_wait=True)
except HwsimSkip, e: except HwsimSkip as e:
# Skip exception to allow proper cleanup # Skip exception to allow proper cleanup
pass pass

View File

@ -35,7 +35,7 @@ def hostapd_oom_loop(apdev, params, start_func="main"):
count += 1 count += 1
if count == 5: if count == 5:
break break
except Exception, e: except Exception as e:
logger.info("Iteration %d - %s" % (i, str(e))) logger.info("Iteration %d - %s" % (i, str(e)))
@remote_compatible @remote_compatible
@ -57,7 +57,7 @@ def test_hostapd_oom_wpa2_psk(dev, apdev):
try: try:
hostapd.add_ap(apdev[1], params, timeout=2.5) hostapd.add_ap(apdev[1], params, timeout=2.5)
raise Exception("Unexpected add_ap() success during OOM") raise Exception("Unexpected add_ap() success during OOM")
except Exception, e: except Exception as e:
if "Failed to enable hostapd" in str(e): if "Failed to enable hostapd" in str(e):
pass pass
else: else:

View File

@ -240,15 +240,15 @@ def test_ibss_wpa_none(dev):
# mac80211 currently.. # mac80211 currently..
try: try:
hwsim_utils.test_connectivity(dev[0], dev[1]) hwsim_utils.test_connectivity(dev[0], dev[1])
except Exception, e: except Exception as e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
try: try:
hwsim_utils.test_connectivity(dev[0], dev[2]) hwsim_utils.test_connectivity(dev[0], dev[2])
except Exception, e: except Exception as e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
try: try:
hwsim_utils.test_connectivity(dev[1], dev[2]) hwsim_utils.test_connectivity(dev[1], dev[2])
except Exception, e: except Exception as e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
key_mgmt = dev[0].get_status_field("key_mgmt") key_mgmt = dev[0].get_status_field("key_mgmt")
@ -291,7 +291,7 @@ def test_ibss_wpa_none_ccmp(dev):
# mac80211 currently.. # mac80211 currently..
try: try:
hwsim_utils.test_connectivity(dev[0], dev[1]) hwsim_utils.test_connectivity(dev[0], dev[1])
except Exception, e: except Exception as e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
def test_ibss_open(dev): def test_ibss_open(dev):

View File

@ -164,7 +164,7 @@ def add_wpas_interfaces(count=2):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("veth%d" % i, driver="macsec_linux") wpas.interface_add("veth%d" % i, driver="macsec_linux")
wpa.append(wpas) wpa.append(wpas)
except Exception, e: except Exception as e:
if "Failed to add a dynamic wpa_supplicant interface" in str(e): if "Failed to add a dynamic wpa_supplicant interface" in str(e):
raise HwsimSkip("macsec supported (wpa_supplicant CONFIG_MACSEC, CONFIG_MACSEC_LINUX; kernel CONFIG_MACSEC)") raise HwsimSkip("macsec supported (wpa_supplicant CONFIG_MACSEC, CONFIG_MACSEC_LINUX; kernel CONFIG_MACSEC)")
raise raise

View File

@ -528,7 +528,7 @@ def test_mbo_without_pmf(dev, apdev):
# "MBO: PMF needs to be enabled whenever using WPA2 with MBO" # "MBO: PMF needs to be enabled whenever using WPA2 with MBO"
hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[0], params)
raise Exception("AP setup succeeded unexpectedly") raise Exception("AP setup succeeded unexpectedly")
except Exception, e: except Exception as e:
if "Failed to enable hostapd" in str(e): if "Failed to enable hostapd" in str(e):
pass pass
else: else:

View File

@ -35,7 +35,7 @@ def ocv_setup_ap(apdev, params):
params.update(hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)) params.update(hostapd.wpa2_params(ssid=ssid, passphrase=passphrase))
try: try:
hapd = hostapd.add_ap(apdev, params) hapd = hostapd.add_ap(apdev, params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -371,7 +371,7 @@ class APConnection:
params["ocv"] = ap_ocv params["ocv"] = ap_ocv
try: try:
self.hapd = hostapd.add_ap(apdev, params) self.hapd = hostapd.add_ap(apdev, params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -598,7 +598,7 @@ def test_wpa2_ocv_ap_retransmit_msg3(dev, apdev):
params['wpa_disable_eapol_key_retries'] = "1" params['wpa_disable_eapol_key_retries'] = "1"
try: try:
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -731,7 +731,7 @@ class STAConnection:
try: try:
self.hapd = hostapd.add_ap(apdev, params) self.hapd = hostapd.add_ap(apdev, params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise

View File

@ -551,7 +551,7 @@ def test_go_neg_peers_force_diff_freq(dev, apdev):
try: try:
[i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14, i_freq=5180, [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14, i_freq=5180,
r_dev=dev[1], r_intent=0, r_freq=5200) r_dev=dev[1], r_intent=0, r_freq=5200)
except Exception, e: except Exception as e:
return return
raise Exception("Unexpected group formation success") raise Exception("Unexpected group formation success")

View File

@ -22,7 +22,7 @@ def get_rfkill(dev):
for r, s, h in RFKill.list(): for r, s, h in RFKill.list():
if r.name == phy: if r.name == phy:
return r return r
except Exception, e: except Exception as e:
raise HwsimSkip("No rfkill available: " + str(e)) raise HwsimSkip("No rfkill available: " + str(e))
raise HwsimSkip("No rfkill match found for the interface") raise HwsimSkip("No rfkill match found for the interface")

View File

@ -1247,7 +1247,7 @@ def test_rrm_beacon_req_table_vht(dev, apdev):
elif report.bssid_str == apdev[1]['bssid']: elif report.bssid_str == apdev[1]['bssid']:
if report.opclass != 117 or report.channel != 48: if report.opclass != 117 or report.channel != 48:
raise Exception("Incorrect opclass/channel for AP1") raise Exception("Incorrect opclass/channel for AP1")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -1662,7 +1662,7 @@ def test_rrm_beacon_req_passive_scan_vht(dev, apdev):
logger.info("Received beacon report: " + str(report)) logger.info("Received beacon report: " + str(report))
if report.opclass != 128 or report.channel != 36: if report.opclass != 128 or report.channel != 36:
raise Exception("Incorrect opclass/channel for AP") raise Exception("Incorrect opclass/channel for AP")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
@ -1712,7 +1712,7 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev):
logger.info("Received beacon report: " + str(report)) logger.info("Received beacon report: " + str(report))
if report.opclass != 129 or report.channel != 104: if report.opclass != 129 or report.channel != 104:
raise Exception("Incorrect opclass/channel for AP") raise Exception("Incorrect opclass/channel for AP")
except Exception, e: except Exception as e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
raise HwsimSkip("ZA regulatory rule likely did not have DFS requirement removed") raise HwsimSkip("ZA regulatory rule likely did not have DFS requirement removed")
raise raise

View File

@ -21,7 +21,7 @@ def get_wext_interface():
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
try: try:
wpas.interface_add("wlan5", driver="wext") wpas.interface_add("wlan5", driver="wext")
except Exception, e: except Exception as e:
wpas.close_ctrl() wpas.close_ctrl()
raise HwsimSkip("WEXT driver support not included in wpa_supplicant") raise HwsimSkip("WEXT driver support not included in wpa_supplicant")
return wpas return wpas

View File

@ -70,7 +70,7 @@ def get_wmediumd_version():
try: try:
verstr = subprocess.check_output(['wmediumd', '-V']) verstr = subprocess.check_output(['wmediumd', '-V'])
except OSError, e: except OSError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
raise HwsimSkip('wmediumd not available') raise HwsimSkip('wmediumd not available')
raise raise
@ -101,7 +101,7 @@ def start_wmediumd(fn, params):
p = subprocess.Popen(['wmediumd', '-c', fn], p = subprocess.Popen(['wmediumd', '-c', fn],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
except OSError, e: except OSError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
raise HwsimSkip('wmediumd not available') raise HwsimSkip('wmediumd not available')
raise raise

View File

@ -310,7 +310,7 @@ def test_wnm_sleep_mode_rsn_ocv(dev, apdev):
params["bss_transition"] = "1" params["bss_transition"] = "1"
try: try:
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -343,7 +343,7 @@ def test_wnm_sleep_mode_rsn_badocv(dev, apdev):
params['wnm_sleep_mode'] = '1' params['wnm_sleep_mode'] = '1'
try: try:
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
except Exception, e: except Exception as e:
if "Failed to set hostapd parameter ocv" in str(e): if "Failed to set hostapd parameter ocv" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise

View File

@ -94,7 +94,7 @@ def test_wpas_ctrl_network(dev):
res = dev[0].get_network(id, "key_mgmt") res = dev[0].get_network(id, "key_mgmt")
if res != value: if res != value:
raise Exception("Unexpected response for key_mgmt") raise Exception("Unexpected response for key_mgmt")
except Exception, e: except Exception as e:
if str(e).startswith("Unexpected"): if str(e).startswith("Unexpected"):
raise raise
else: else:
@ -1827,7 +1827,7 @@ def test_wpas_ctrl_socket_full(dev, apdev, test_params):
logger.debug("Command %d" % i) logger.debug("Command %d" % i)
try: try:
s.send("MIB") s.send("MIB")
except Exception, e: except Exception as e:
logger.info("Could not send command %d: %s" % (i, str(e))) logger.info("Could not send command %d: %s" % (i, str(e)))
break break
# Close without receiving response # Close without receiving response
@ -1846,7 +1846,7 @@ def test_wpas_ctrl_socket_full(dev, apdev, test_params):
logger.debug("Command %d [2]" % i) logger.debug("Command %d [2]" % i)
try: try:
s2.send("MIB") s2.send("MIB")
except Exception, e: except Exception as e:
logger.info("Could not send command %d [2]: %s" % (i, str(e))) logger.info("Could not send command %d [2]: %s" % (i, str(e)))
break break
# Close without receiving response # Close without receiving response
@ -1859,7 +1859,7 @@ def test_wpas_ctrl_socket_full(dev, apdev, test_params):
logger.debug("Command %d [3]" % i) logger.debug("Command %d [3]" % i)
try: try:
s2.send("MIB") s2.send("MIB")
except Exception, e: except Exception as e:
logger.info("Could not send command %d [3]: %s" % (i, str(e))) logger.info("Could not send command %d [3]: %s" % (i, str(e)))
break break
# Close without receiving response # Close without receiving response

View File

@ -303,7 +303,7 @@ def add_mesh_secure_net(dev, psk=True, pmf=False, pairwise=None, group=None,
if ocv: if ocv:
try: try:
dev.set_network(id, "ocv", "1") dev.set_network(id, "ocv", "1")
except Exception, e: except Exception as e:
if "SET_NETWORK failed" in str(e): if "SET_NETWORK failed" in str(e):
raise HwsimSkip("OCV not supported") raise HwsimSkip("OCV not supported")
raise raise
@ -1264,7 +1264,7 @@ def test_wpas_mesh_password_mismatch(dev, apdev):
try: try:
hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1) hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1)
raise Exception("Data connectivity test passed unexpectedly") raise Exception("Data connectivity test passed unexpectedly")
except Exception, e: except Exception as e:
if "data delivery failed" not in str(e): if "data delivery failed" not in str(e):
raise raise
@ -1713,7 +1713,7 @@ def test_mesh_oom(dev, apdev):
"MESH-GROUP-STARTED"]) "MESH-GROUP-STARTED"])
if ev is None: if ev is None:
raise Exception("Init failure not reported") raise Exception("Init failure not reported")
except Exception, e: except Exception as e:
if i < 15: if i < 15:
raise raise
logger.info("Ignore no-oom for i=%d" % i) logger.info("Ignore no-oom for i=%d" % i)

View File

@ -60,7 +60,7 @@ def test_tspec(dev, apdev):
try: try:
dev[0].add_ts(tsid, 3) dev[0].add_ts(tsid, 3)
raise Exception("ADDTS succeeded although it should have failed") raise Exception("ADDTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("ADDTS failed"): if not str(e).startswith("ADDTS failed"):
raise raise
status = dev[0].request("WMM_AC_STATUS") status = dev[0].request("WMM_AC_STATUS")
@ -77,7 +77,7 @@ def test_tspec(dev, apdev):
try: try:
dev[0].add_ts(tsid, 5) dev[0].add_ts(tsid, 5)
raise Exception("ADDTS succeeded although it should have failed") raise Exception("ADDTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("ADDTS failed"): if not str(e).startswith("ADDTS failed"):
raise raise
@ -93,13 +93,13 @@ def test_tspec(dev, apdev):
try: try:
dev[0].add_ts(tsid, 7, direction="uplink") dev[0].add_ts(tsid, 7, direction="uplink")
raise Exception("ADDTS succeeded although it should have failed") raise Exception("ADDTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("ADDTS failed"): if not str(e).startswith("ADDTS failed"):
raise raise
try: try:
dev[0].add_ts(tsid, 7, direction="bidi") dev[0].add_ts(tsid, 7, direction="bidi")
raise Exception("ADDTS succeeded although it should have failed") raise Exception("ADDTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("ADDTS failed"): if not str(e).startswith("ADDTS failed"):
raise raise
@ -107,7 +107,7 @@ def test_tspec(dev, apdev):
try: try:
dev[0].del_ts(tsid) dev[0].del_ts(tsid)
raise Exception("DELTS succeeded although it should have failed") raise Exception("DELTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("DELTS failed"): if not str(e).startswith("DELTS failed"):
raise raise
@ -231,7 +231,7 @@ def test_tspec_not_enabled(dev, apdev):
try: try:
dev[0].add_ts(5, 6) dev[0].add_ts(5, 6)
raise Exception("ADDTS succeeded although it should have failed") raise Exception("ADDTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("ADDTS failed"): if not str(e).startswith("ADDTS failed"):
raise raise
@ -239,7 +239,7 @@ def test_tspec_not_enabled(dev, apdev):
try: try:
dev[0].del_ts(5) dev[0].del_ts(5)
raise Exception("DELTS succeeded although it should have failed") raise Exception("DELTS succeeded although it should have failed")
except Exception, e: except Exception as e:
if not str(e).startswith("DELTS failed"): if not str(e).startswith("DELTS failed"):
raise raise

View File

@ -39,7 +39,7 @@ def _run_tshark(filename, filter, display=None, wait=True):
arg.append('-V') arg.append('-V')
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
except Exception, e: except Exception as e:
logger.info("Could run run tshark check: " + str(e)) logger.info("Could run run tshark check: " + str(e))
cmd = None cmd = None
return None return None
@ -88,7 +88,7 @@ def run_tshark(filename, filter, display=None, wait=True):
if display is None: display = [] if display is None: display = []
try: try:
return _run_tshark(filename, filter, display, wait) return _run_tshark(filename, filter, display, wait)
except UnknownFieldsException, e: except UnknownFieldsException as e:
all_wlan_mgt = True all_wlan_mgt = True
for f in e.fields: for f in e.fields:
if not f.startswith('wlan_mgt.'): if not f.startswith('wlan_mgt.'):
@ -108,7 +108,7 @@ def run_tshark_json(filename, filter):
try: try:
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
except Exception, e: except Exception as e:
logger.info("Could run run tshark: " + str(e)) logger.info("Could run run tshark: " + str(e))
return None return None
output = cmd.communicate() output = cmd.communicate()

View File

@ -142,7 +142,7 @@ class Wlantest:
def get_bss_counter(self, field, bssid): def get_bss_counter(self, field, bssid):
try: try:
res = self.cli_cmd(["get_bss_counter", field, bssid]) res = self.cli_cmd(["get_bss_counter", field, bssid])
except Exception, e: except Exception as e:
return 0 return 0
if "FAIL" in res: if "FAIL" in res:
return 0 return 0

View File

@ -438,7 +438,7 @@ class WpaSupplicant:
try: try:
[name,value] = l.split('=', 1) [name,value] = l.split('=', 1)
vals[name] = value vals[name] = value
except ValueError, e: except ValueError as e:
logger.info(self.ifname + ": Ignore unexpected STATUS line: " + l) logger.info(self.ifname + ": Ignore unexpected STATUS line: " + l)
return vals return vals
@ -507,7 +507,7 @@ class WpaSupplicant:
try: try:
[name,value] = l.split('=', 1) [name,value] = l.split('=', 1)
vals[name] = value vals[name] = value
except ValueError, e: except ValueError as e:
logger.info(self.ifname + ": Ignore unexpected MIB line: " + l) logger.info(self.ifname + ": Ignore unexpected MIB line: " + l)
return vals return vals

View File

@ -265,7 +265,7 @@ def main():
# lock devices # lock devices
try: try:
get_devices(devices, duts, refs, monitors) get_devices(devices, duts, refs, monitors)
except Exception, e: except Exception as e:
logger.warning("get devices failed: " + str(e)) logger.warning("get devices failed: " + str(e))
logger.info(traceback.format_exc()) logger.info(traceback.format_exc())
put_devices(devices, duts, refs, monitors) put_devices(devices, duts, refs, monitors)
@ -288,7 +288,7 @@ def main():
logger.warning("RUN check_devices") logger.warning("RUN check_devices")
try: try:
check_devices(devices, setup_params, refs, duts, monitors) check_devices(devices, setup_params, refs, duts, monitors)
except Exception, e: except Exception as e:
logger.warning("FAILED: " + str(e)) logger.warning("FAILED: " + str(e))
logger.info(traceback.format_exc()) logger.info(traceback.format_exc())
put_devices(devices, duts, refs, monitors) put_devices(devices, duts, refs, monitors)
@ -317,10 +317,10 @@ def main():
except KeyboardInterrupt: except KeyboardInterrupt:
put_devices(devices, duts, refs, monitors) put_devices(devices, duts, refs, monitors)
raise raise
except TestSkip, e: except TestSkip as e:
end = datetime.now() end = datetime.now()
logger.warning("SKIP (" + str(e) + ") - " + str((end - start).total_seconds()) + "s") logger.warning("SKIP (" + str(e) + ") - " + str((end - start).total_seconds()) + "s")
except Exception, e: except Exception as e:
end = datetime.now() end = datetime.now()
logger.warning("FAILED (" + str(e) + ") - " + str((end - start).total_seconds()) + "s") logger.warning("FAILED (" + str(e) + ") - " + str((end - start).total_seconds()) + "s")
logger.info(traceback.format_exc()) logger.info(traceback.format_exc())
@ -344,11 +344,11 @@ def main():
except KeyboardInterrupt: except KeyboardInterrupt:
put_devices(devices, duts, refs, monitors) put_devices(devices, duts, refs, monitors)
raise raise
except HwsimSkip,e: except HwsimSkip as e:
end = datetime.now() end = datetime.now()
logger.warning("SKIP (" + str(e) + ") - " + str((end - start).total_seconds()) + "s") logger.warning("SKIP (" + str(e) + ") - " + str((end - start).total_seconds()) + "s")
failed.append(hwsim_test.__name__.replace('test_', '', 1)) failed.append(hwsim_test.__name__.replace('test_', '', 1))
except Exception, e: except Exception as e:
end = datetime.now() end = datetime.now()
logger.warning("FAILED (" + str(e) + ") - " + str((end - start).total_seconds()) + "s") logger.warning("FAILED (" + str(e) + ") - " + str((end - start).total_seconds()) + "s")
logger.info(traceback.format_exc()) logger.info(traceback.format_exc())

View File

@ -24,7 +24,7 @@ def wpas_connect():
if os.path.isdir(wpas_ctrl): if os.path.isdir(wpas_ctrl):
try: try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error: except OSError as error:
print "Could not find wpa_supplicant: ", error print "Could not find wpa_supplicant: ", error
return None return None
@ -36,7 +36,7 @@ def wpas_connect():
try: try:
wpas = wpaspy.Ctrl(ctrl) wpas = wpaspy.Ctrl(ctrl)
return wpas return wpas
except Exception, e: except Exception as e:
pass pass
return None return None

View File

@ -53,7 +53,7 @@ def wpas_connect():
if os.path.isdir(wpas_ctrl): if os.path.isdir(wpas_ctrl):
try: try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error: except OSError as error:
print "Could not find wpa_supplicant: ", error print "Could not find wpa_supplicant: ", error
return None return None
@ -69,7 +69,7 @@ def wpas_connect():
print "Trying to use control interface " + ctrl print "Trying to use control interface " + ctrl
wpas = wpaspy.Ctrl(ctrl) wpas = wpaspy.Ctrl(ctrl)
return wpas return wpas
except Exception, e: except Exception as e:
pass pass
return None return None
@ -169,7 +169,7 @@ def p2p_handover_client(llc):
print "Handover request (pre-WPS):" print "Handover request (pre-WPS):"
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
data = wpas_get_handover_req_wps() data = wpas_get_handover_req_wps()
@ -181,7 +181,7 @@ def p2p_handover_client(llc):
print "Handover request:" print "Handover request:"
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
print str(message).encode("hex") print str(message).encode("hex")
@ -194,7 +194,7 @@ def p2p_handover_client(llc):
summary("Handover connection refused") summary("Handover connection refused")
client.close() client.close()
return return
except Exception, e: except Exception as e:
summary("Other exception: " + str(e)) summary("Other exception: " + str(e))
client.close() client.close()
return return
@ -220,14 +220,14 @@ def p2p_handover_client(llc):
print "Received message" print "Received message"
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
print str(message).encode("hex") print str(message).encode("hex")
message = nfc.ndef.HandoverSelectMessage(message) message = nfc.ndef.HandoverSelectMessage(message)
summary("Handover select received") summary("Handover select received")
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
for carrier in message.carriers: for carrier in message.carriers:
@ -286,7 +286,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "HandoverServer - request received" print "HandoverServer - request received"
try: try:
print "Parsed handover request: " + request.pretty() print "Parsed handover request: " + request.pretty()
except Exception, e: except Exception as e:
print e print e
sel = nfc.ndef.HandoverSelectMessage(version="1.2") sel = nfc.ndef.HandoverSelectMessage(version="1.2")
@ -302,7 +302,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "Carrier record:" print "Carrier record:"
try: try:
print carrier.record.pretty() print carrier.record.pretty()
except Exception, e: except Exception as e:
print e print e
data = wpas_get_handover_sel() data = wpas_get_handover_sel()
if data is None: if data is None:
@ -332,7 +332,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "Carrier record:" print "Carrier record:"
try: try:
print carrier.record.pretty() print carrier.record.pretty()
except Exception, e: except Exception as e:
print e print e
data = wpas_get_handover_sel_wps() data = wpas_get_handover_sel_wps()
if data is None: if data is None:
@ -355,7 +355,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "Handover select:" print "Handover select:"
try: try:
print sel.pretty() print sel.pretty()
except Exception, e: except Exception as e:
print e print e
print str(sel).encode("hex") print str(sel).encode("hex")
@ -443,7 +443,7 @@ def wps_write_p2p_handover_sel(clf, wait_remove=True):
print "Handover select:" print "Handover select:"
try: try:
print p2p_sel_data.pretty() print p2p_sel_data.pretty()
except Exception, e: except Exception as e:
print e print e
print str(p2p_sel_data).encode("hex") print str(p2p_sel_data).encode("hex")
@ -459,7 +459,7 @@ def rdwr_connected(tag):
print "NDEF tag: " + tag.type print "NDEF tag: " + tag.type
try: try:
print tag.ndef.message.pretty() print tag.ndef.message.pretty()
except Exception, e: except Exception as e:
print e print e
success = p2p_tag_read(tag) success = p2p_tag_read(tag)
if only_one and success: if only_one and success:
@ -636,7 +636,7 @@ def main():
'on-connect': llcp_connected}, 'on-connect': llcp_connected},
terminate=terminate_loop): terminate=terminate_loop):
break break
except Exception, e: except Exception as e:
print "clf.connect failed" print "clf.connect failed"
global srv global srv

View File

@ -118,7 +118,7 @@ class P2P_Connect():
{'Ifname': ifname, 'Driver': 'test'}) {'Ifname': ifname, 'Driver': 'test'})
time.sleep(1) time.sleep(1)
except dbus.DBusException, exc: except dbus.DBusException as exc:
if not str(exc).startswith( if not str(exc).startswith(
self.wpas_dbus_interface + \ self.wpas_dbus_interface + \
".InterfaceExists:"): ".InterfaceExists:"):
@ -209,7 +209,7 @@ class P2P_Connect():
result_pin = self.p2p_interface.Connect( result_pin = self.p2p_interface.Connect(
self.p2p_connect_arguements) self.p2p_connect_arguements)
except dbus.DBusException, exc: except dbus.DBusException as exc:
raise exc raise exc
if (self.wps_method == 'pin' and \ if (self.wps_method == 'pin' and \

View File

@ -81,7 +81,7 @@ class P2P_Disconnect (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -85,7 +85,7 @@ class P2P_Find (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -81,7 +81,7 @@ class P2P_Flush (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -99,7 +99,7 @@ class P2P_Group_Add (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -96,7 +96,7 @@ class P2P_Invite (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -82,7 +82,7 @@ class P2P_Listen(threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -83,7 +83,7 @@ class P2P_Stop_Find (threading.Thread):
try: try:
self.path = self.wpas.GetInterface( self.path = self.wpas.GetInterface(
self.interface_name) self.interface_name)
except dbus.DBusException, exc: except dbus.DBusException as exc:
error = 'Error:\n Interface ' + self.interface_name \ error = 'Error:\n Interface ' + self.interface_name \
+ ' was not found' + ' was not found'
print error print error

View File

@ -123,14 +123,14 @@ def main():
path = None path = None
try: try:
path = wpas.GetInterface(ifname) path = wpas.GetInterface(ifname)
except dbus.DBusException, exc: except dbus.DBusException as exc:
if not str(exc).startswith("fi.w1.wpa_supplicant1.InterfaceUnknown:"): if not str(exc).startswith("fi.w1.wpa_supplicant1.InterfaceUnknown:"):
raise exc raise exc
try: try:
path = wpas.CreateInterface({'Ifname': ifname, 'Driver': 'test'}) path = wpas.CreateInterface({'Ifname': ifname, 'Driver': 'test'})
time.sleep(1) time.sleep(1)
except dbus.DBusException, exc: except dbus.DBusException as exc:
if not str(exc).startswith("fi.w1.wpa_supplicant1.InterfaceExists:"): if not str(exc).startswith("fi.w1.wpa_supplicant1.InterfaceExists:"):
raise exc raise exc

View File

@ -37,12 +37,12 @@ def main():
path = None path = None
try: try:
path = wpas.getInterface(ifname) path = wpas.getInterface(ifname)
except dbus.dbus_bindings.DBusException, exc: except dbus.dbus_bindings.DBusException as exc:
if str(exc) != "wpa_supplicant knows nothing about this interface.": if str(exc) != "wpa_supplicant knows nothing about this interface.":
raise exc raise exc
try: try:
path = wpas.addInterface(ifname, {'driver': dbus.Variant('wext')}) path = wpas.addInterface(ifname, {'driver': dbus.Variant('wext')})
except dbus.dbus_bindings.DBusException, exc: except dbus.dbus_bindings.DBusException as exc:
if str(exc) != "wpa_supplicant already controls this interface.": if str(exc) != "wpa_supplicant already controls this interface.":
raise exc raise exc

View File

@ -46,7 +46,7 @@ def wpas_connect():
if os.path.isdir(wpas_ctrl): if os.path.isdir(wpas_ctrl):
try: try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error: except OSError as error:
print "Could not find wpa_supplicant: ", error print "Could not find wpa_supplicant: ", error
return None return None
@ -58,7 +58,7 @@ def wpas_connect():
try: try:
wpas = wpaspy.Ctrl(ctrl) wpas = wpaspy.Ctrl(ctrl)
return wpas return wpas
except Exception, e: except Exception as e:
pass pass
return None return None
@ -164,7 +164,7 @@ class HandoverServer(nfc.handover.HandoverServer):
summary("HandoverServer - request received") summary("HandoverServer - request received")
try: try:
print "Parsed handover request: " + request.pretty() print "Parsed handover request: " + request.pretty()
except Exception, e: except Exception as e:
print e print e
sel = nfc.ndef.HandoverSelectMessage(version="1.2") sel = nfc.ndef.HandoverSelectMessage(version="1.2")
@ -191,7 +191,7 @@ class HandoverServer(nfc.handover.HandoverServer):
print "Handover select:" print "Handover select:"
try: try:
print sel.pretty() print sel.pretty()
except Exception, e: except Exception as e:
print e print e
print str(sel).encode("hex") print str(sel).encode("hex")
@ -217,7 +217,7 @@ def wps_handover_init(llc):
print "Handover request:" print "Handover request:"
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
print str(message).encode("hex") print str(message).encode("hex")
@ -230,7 +230,7 @@ def wps_handover_init(llc):
summary("Handover connection refused") summary("Handover connection refused")
client.close() client.close()
return return
except Exception, e: except Exception as e:
summary("Other exception: " + str(e)) summary("Other exception: " + str(e))
client.close() client.close()
return return
@ -256,14 +256,14 @@ def wps_handover_init(llc):
print "Received message" print "Received message"
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
print str(message).encode("hex") print str(message).encode("hex")
message = nfc.ndef.HandoverSelectMessage(message) message = nfc.ndef.HandoverSelectMessage(message)
summary("Handover select received") summary("Handover select received")
try: try:
print message.pretty() print message.pretty()
except Exception, e: except Exception as e:
print e print e
for carrier in message.carriers: for carrier in message.carriers:
@ -376,7 +376,7 @@ def rdwr_connected(tag):
print "NDEF tag: " + tag.type print "NDEF tag: " + tag.type
try: try:
print tag.ndef.message.pretty() print tag.ndef.message.pretty()
except Exception, e: except Exception as e:
print e print e
success = wps_tag_read(tag, not only_one) success = wps_tag_read(tag, not only_one)
if only_one and success: if only_one and success:
@ -507,7 +507,7 @@ def main():
'on-connect': llcp_connected}, 'on-connect': llcp_connected},
terminate=terminate_loop): terminate=terminate_loop):
break break
except Exception, e: except Exception as e:
print "clf.connect failed" print "clf.connect failed"
global srv global srv

View File

@ -27,7 +27,7 @@ def wpas_connect(host=None, port=9877):
if os.path.isdir(wpas_ctrl): if os.path.isdir(wpas_ctrl):
try: try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error: except OSError as error:
print "Could not find wpa_supplicant: ", error print "Could not find wpa_supplicant: ", error
return None return None
@ -39,7 +39,7 @@ def wpas_connect(host=None, port=9877):
try: try:
wpas = wpaspy.Ctrl(ctrl) wpas = wpaspy.Ctrl(ctrl)
return wpas return wpas
except Exception, e: except Exception as e:
pass pass
return None return None