[cli/utils] Simplify imports

This commit is contained in:
derrod 2021-12-31 14:44:32 +01:00
parent 688910bf91
commit 2e6335bf09
2 changed files with 6 additions and 8 deletions

View file

@ -22,9 +22,7 @@ from legendary.core import LegendaryCore
from legendary.models.exceptions import InvalidCredentialsError from legendary.models.exceptions import InvalidCredentialsError
from legendary.models.game import SaveGameStatus, VerifyResult, Game from legendary.models.game import SaveGameStatus, VerifyResult, Game
from legendary.utils.cli import get_boolean_choice, get_int_choice, sdl_prompt, strtobool from legendary.utils.cli import get_boolean_choice, get_int_choice, sdl_prompt, strtobool
from legendary.utils.crossover import ( from legendary.utils.crossover import *
mac_find_crossover_apps, mac_get_crossover_bottles, mac_is_valid_bottle, mac_is_crossover_running
)
from legendary.utils.custom_parser import AliasedSubParsersAction from legendary.utils.custom_parser import AliasedSubParsersAction
from legendary.utils.env import is_windows_mac_or_pyi from legendary.utils.env import is_windows_mac_or_pyi
from legendary.utils.eos import add_registry_entries, query_registry_entries, remove_registry_entries from legendary.utils.eos import add_registry_entries, query_registry_entries, remove_registry_entries

View file

@ -3,7 +3,7 @@ import plistlib
import os import os
import subprocess import subprocess
logger = logging.getLogger('CXHelpers') _logger = logging.getLogger('CXHelpers')
def mac_get_crossover_version(app_path): def mac_get_crossover_version(app_path):
@ -11,7 +11,7 @@ def mac_get_crossover_version(app_path):
plist = plistlib.load(open(os.path.join(app_path, 'Contents', 'Info.plist'), 'rb')) plist = plistlib.load(open(os.path.join(app_path, 'Contents', 'Info.plist'), 'rb'))
return plist['CFBundleShortVersionString'] return plist['CFBundleShortVersionString']
except Exception as e: except Exception as e:
logger.debug(f'Failed to load plist for "{app_path}" with {e!r}') _logger.debug(f'Failed to load plist for "{app_path}" with {e!r}')
return None return None
@ -21,7 +21,7 @@ def mac_find_crossover_apps():
out = subprocess.check_output(['mdfind', 'kMDItemCFBundleIdentifier="com.codeweavers.CrossOver"']) out = subprocess.check_output(['mdfind', 'kMDItemCFBundleIdentifier="com.codeweavers.CrossOver"'])
paths.extend(out.decode('utf-8', 'replace').strip().split('\n')) paths.extend(out.decode('utf-8', 'replace').strip().split('\n'))
except Exception as e: except Exception as e:
logger.warning(f'Trying to find CrossOver installs via mdfind failed: {e!r}') _logger.warning(f'Trying to find CrossOver installs via mdfind failed: {e!r}')
valid = [p for p in paths if os.path.exists(os.path.join(p, 'Contents', 'Info.plist'))] valid = [p for p in paths if os.path.exists(os.path.join(p, 'Contents', 'Info.plist'))]
found_tuples = set() found_tuples = set()
@ -30,7 +30,7 @@ def mac_find_crossover_apps():
version = mac_get_crossover_version(path) version = mac_get_crossover_version(path)
if not version: if not version:
continue continue
logger.debug(f'Found Crossover {version} at "{path}"') _logger.debug(f'Found Crossover {version} at "{path}"')
found_tuples.add((version, path)) found_tuples.add((version, path))
return sorted(found_tuples, reverse=True) return sorted(found_tuples, reverse=True)
@ -55,5 +55,5 @@ def mac_is_crossover_running():
out = subprocess.check_output(['launchctl', 'list']) out = subprocess.check_output(['launchctl', 'list'])
return b'com.codeweavers.CrossOver' in out return b'com.codeweavers.CrossOver' in out
except Exception as e: except Exception as e:
logger.warning(f'Getting list of running application bundles failed: {e!r}') _logger.warning(f'Getting list of running application bundles failed: {e!r}')
return True # assume the worst return True # assume the worst