mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[core/utils] Clean up crossover bottle code a bit
This commit is contained in:
parent
d15f05fc60
commit
ecb230511f
|
@ -33,7 +33,7 @@ from legendary.models.game import *
|
|||
from legendary.models.json_manifest import JSONManifest
|
||||
from legendary.models.manifest import Manifest, ManifestMeta
|
||||
from legendary.models.chunk import Chunk
|
||||
from legendary.utils.crossover import mac_find_crossover_apps, mac_get_crossover_version
|
||||
from legendary.utils.crossover import mac_find_crossover_apps, mac_get_crossover_version, mac_get_bottle_path
|
||||
from legendary.utils.egl_crypt import decrypt_epic_data
|
||||
from legendary.utils.env import is_windows_mac_or_pyi
|
||||
from legendary.utils.eos import EOSOverlayApp, query_registry_entries
|
||||
|
@ -1839,9 +1839,7 @@ class LegendaryCore:
|
|||
manifest = self.load_manifest(r.content)
|
||||
base_url = manifest_url.rpartition('/')[0]
|
||||
|
||||
bottles_dir = os.path.expanduser('~/Library/Application Support/CrossOver/Bottles')
|
||||
path = os.path.join(bottles_dir, bottle_name)
|
||||
|
||||
path = mac_get_bottle_path(bottle_name)
|
||||
if os.path.exists(path):
|
||||
raise FileExistsError(f'Bottle {bottle_name} already exists')
|
||||
|
||||
|
@ -1862,8 +1860,7 @@ class LegendaryCore:
|
|||
return dlm, analysis_result, path
|
||||
|
||||
def finish_bottle_setup(self, bottle_name):
|
||||
bottles_dir = os.path.expanduser('~/Library/Application Support/CrossOver/Bottles')
|
||||
path = os.path.join(bottles_dir, bottle_name)
|
||||
path = mac_get_bottle_path(bottle_name)
|
||||
|
||||
self.log.info('Creating bottle symlinks...')
|
||||
symlinks = [
|
||||
|
@ -1888,8 +1885,7 @@ class LegendaryCore:
|
|||
|
||||
@staticmethod
|
||||
def remove_bottle(bottle_name):
|
||||
bottles_dir = os.path.expanduser('~/Library/Application Support/CrossOver/Bottles')
|
||||
path = os.path.join(bottles_dir, bottle_name)
|
||||
path = mac_get_bottle_path(bottle_name)
|
||||
if os.path.exists(path):
|
||||
delete_folder(path, recursive=True)
|
||||
|
||||
|
|
|
@ -40,9 +40,7 @@ def mac_get_crossover_bottles():
|
|||
bottles_path = os.path.expanduser('~/Library/Application Support/CrossOver/Bottles')
|
||||
if not os.path.exists(bottles_path):
|
||||
return []
|
||||
return sorted(p for p in os.listdir(bottles_path) if
|
||||
os.path.isdir(os.path.join(bottles_path, p)) and
|
||||
os.path.exists(os.path.join(bottles_path, p, 'cxbottle.conf')))
|
||||
return sorted(p for p in os.listdir(bottles_path) if mac_is_valid_bottle(p))
|
||||
|
||||
|
||||
def mac_is_valid_bottle(bottle_name):
|
||||
|
@ -50,6 +48,11 @@ def mac_is_valid_bottle(bottle_name):
|
|||
return os.path.exists(os.path.join(bottles_path, bottle_name, 'cxbottle.conf'))
|
||||
|
||||
|
||||
def mac_get_bottle_path(bottle_name):
|
||||
bottles_path = os.path.expanduser('~/Library/Application Support/CrossOver/Bottles')
|
||||
return os.path.join(bottles_path, bottle_name)
|
||||
|
||||
|
||||
def mac_is_crossover_running():
|
||||
try:
|
||||
out = subprocess.check_output(['launchctl', 'list'])
|
||||
|
|
Loading…
Reference in a new issue