Skip to content

Commit

Permalink
update method for getting ssid
Browse files Browse the repository at this point in the history
Differential Revision: D56316127

fbshipit-source-id: 39168f4a01420577ebea0b7fd8b131c79f5b144e
  • Loading branch information
Joseph Chilcote authored and facebook-github-bot committed Apr 18, 2024
1 parent 3bfc259 commit 4194889
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions itchef/cookbooks/cpe_munki/files/default/munki_preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""Munki preflight to configure Munki run settings."""

import os
import plistlib
import subprocess
import sys
import time
Expand Down Expand Up @@ -54,14 +55,12 @@ def check_munki_pause() -> None:

def get_airport_info() -> str:
"""Get the SSID of the connected WiFi network."""
cmd = [
"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport", # NOQA
"-I",
]
cmd = ["/usr/sbin/ioreg", "-r", "-k", "IO80211CountryCode", "-d", "1", "-a"]
proc = subprocess.run(cmd, stdout=subprocess.PIPE)
output = proc.stdout.decode("utf-8").split("\n")
ssid_line: str = list(filter(lambda x: x.strip().startswith("SSID:"), output))
return ssid_line[0].replace(" SSID:", "").strip()
output = proc.stdout
plist_output = plistlib.loads(output)[0]
ssid = plist_output.get("IO80211SSID", "")
return ssid


def exit_if_on_wifi_shuttle() -> None:
Expand Down

0 comments on commit 4194889

Please sign in to comment.