1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 15:57:34 +00:00

Catch broken macOS wifi plist. Fixes #270 (#301)

This commit is contained in:
Manuel Riel 2019-06-17 16:06:43 +08:00 committed by GitHub
parent 642ce58225
commit 4cdc76680c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -26,6 +26,7 @@
help='Specify output file name')
opts = parser.parse_args()
def get_pypi_url(name: str, filename: str) -> str:
url = 'https://pypi.python.org/pypi/{}/json'.format(name)
print('Extracting download url for', name)

View file

@ -13,6 +13,7 @@
from functools import reduce
import operator
import psutil
import xml
from paramiko.rsakey import RSAKey
from paramiko.ecdsakey import ECDSAKey
@ -120,8 +121,14 @@ def get_sorted_wifis(profile):
if sys.platform == 'darwin':
plist_path = '/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist'
plist_file = open(plist_path, 'rb')
wifis = plistlib.load(plist_file).get('KnownNetworks')
try:
plist_file = open(plist_path, 'rb')
wifis = plistlib.load(plist_file).get('KnownNetworks')
except xml.parsers.expat.ExpatError:
logger.error('Unable to parse list of Wifi networks.')
return
if wifis is not None:
for wifi in wifis.values():
timestamp = wifi.get('LastConnected', None)