Skip to content

Commit

Permalink
Move set_secured and up_conn as part of __enter__ function
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwu666666 committed Dec 10, 2024
1 parent 301ef35 commit 5d90c5e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_ip_addr(self):
self.interface,
)
)
ip_addr = ip_addr.split("/")[0] if id_addr.find("/") != -1 else ""
ip_addr = ip_addr.split("/")[0] if ip_addr.find("/") != -1 else ""
return ip_addr

def up_conn(self):
Expand Down Expand Up @@ -136,6 +136,10 @@ def __enter__(self):
self.init_conn()
if self.type == "wifi":
self.set_band_channel()
if self.keymgmt is not None:
self.set_secured()
if not self.up_conn():
raise RuntimeError("Connection initialization failed!")

def __exit__(self, exc_type, exc_value, traceback):
logging.info("Exiting context and cleaning up connection")
Expand Down Expand Up @@ -289,10 +293,6 @@ def main():
args.ssid_pwd,
)
with manager:
if args.keymgmt is not None:
manager.set_secured()
if not manager.up_conn():
raise RuntimeError("Connection initialization failed!")
if not args.set_ap_only:
connect_host_device(
manager, args.host_ip, args.host_user, args.host_pwd
Expand Down

0 comments on commit 5d90c5e

Please sign in to comment.