From 4cdc76680ca16502e9743a0218ab254c4158fb20 Mon Sep 17 00:00:00 2001 From: Manuel Riel <3916435+m3nu@users.noreply.github.com> Date: Mon, 17 Jun 2019 16:06:43 +0800 Subject: [PATCH] Catch broken macOS wifi plist. Fixes #270 (#301) --- flatpak/dependencies/flatpak-pip-generator.py | 1 + src/vorta/utils.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/flatpak/dependencies/flatpak-pip-generator.py b/flatpak/dependencies/flatpak-pip-generator.py index f6ca8a42..c669ece7 100644 --- a/flatpak/dependencies/flatpak-pip-generator.py +++ b/flatpak/dependencies/flatpak-pip-generator.py @@ -26,6 +26,7 @@ parser.add_argument('--output', 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) diff --git a/src/vorta/utils.py b/src/vorta/utils.py index cedbaf03..9dcca377 100644 --- a/src/vorta/utils.py +++ b/src/vorta/utils.py @@ -13,6 +13,7 @@ from collections import defaultdict 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)