Skip to content

Commit 493e9c2

Browse files
manager: Remove update methods
1 parent 18b25b6 commit 493e9c2

File tree

2 files changed

+0
-167
lines changed

2 files changed

+0
-167
lines changed

bottles/backend/managers/manager.py

-157
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,8 @@ def checks(self, install_latest=False, first_run=False) -> Result:
143143
self.check_runners(install_latest) or rv.set_status(False)
144144
rv.data["check_runners"] = time.time()
145145

146-
self.check_bottles()
147-
rv.data["check_bottles"] = time.time()
148-
149146
return rv
150147

151-
def update_bottles(self, silent: bool = False):
152-
"""Checks for new bottles and update the list view."""
153-
self.check_bottles(silent)
154-
SignalManager.send(Signals.ManagerLocalBottlesLoaded)
155-
156148
def check_app_dirs(self):
157149
"""
158150
Checks for the existence of the bottles' directories, and creates them
@@ -550,152 +542,6 @@ def get_programs(self, config: BottleConfig) -> list[dict]:
550542

551543
return installed_programs
552544

553-
def check_bottles(self, silent: bool = False):
554-
"""
555-
Check for local bottles and update the local_bottles list.
556-
Will also mark the broken ones if the configuration file is missing
557-
"""
558-
bottles = os.listdir(Paths.bottles)
559-
560-
# Empty local bottles
561-
self.local_bottles = {}
562-
563-
def process_bottle(bottle):
564-
_name = bottle
565-
_bottle = str(os.path.join(Paths.bottles, bottle))
566-
_placeholder = os.path.join(_bottle, "placeholder.yml")
567-
_config = os.path.join(_bottle, "bottle.yml")
568-
569-
if os.path.exists(_placeholder):
570-
with open(_placeholder) as f:
571-
try:
572-
placeholder_yaml = yaml.load(f)
573-
if placeholder_yaml.get("Path"):
574-
_config = os.path.join(
575-
placeholder_yaml.get("Path"), "bottle.yml"
576-
)
577-
else:
578-
raise ValueError("Missing Path in placeholder.yml")
579-
except (yaml.YAMLError, ValueError):
580-
return
581-
582-
config_load = BottleConfig.load(_config)
583-
584-
if not config_load.status:
585-
return
586-
587-
config = config_load.data
588-
589-
# Clear Run Executable parameters on new session start
590-
if config.session_arguments:
591-
config.session_arguments = ""
592-
593-
if config.run_in_terminal:
594-
config.run_in_terminal = False
595-
596-
# Check if the path in the bottle config corresponds to the folder name
597-
# if not, change the config to reflect the folder name
598-
# if the folder name is "illegal" across all platforms, rename the folder
599-
600-
# "universal" platform works for all filesystem/OSes
601-
sane_name = pathvalidate.sanitize_filepath(_name, platform="universal")
602-
if config.Custom_Path is False: # There shouldn't be problems with this
603-
if config.Path != _name or sane_name != _name:
604-
logging.warning(
605-
'Illegal bottle folder or mismatch between config "Path" and folder name'
606-
)
607-
if sane_name != _name:
608-
# This hopefully doesn't happen, but it's managed
609-
logging.warning(f"Broken path in bottle {_name}, fixing...")
610-
shutil.move(
611-
_bottle, str(os.path.join(Paths.bottles, sane_name))
612-
)
613-
# Restart the process bottle function. Normally, can't be recursive!
614-
process_bottle(sane_name)
615-
return
616-
617-
config.Path = sane_name
618-
self.update_config(config=config, key="Path", value=sane_name)
619-
620-
sample = BottleConfig()
621-
miss_keys = sample.keys() - config.keys()
622-
for key in miss_keys:
623-
logging.warning(f"Key {key} is missing for bottle {_name}, updating…")
624-
self.update_config(config=config, key=key, value=sample[key])
625-
626-
miss_params_keys = sample.Parameters.keys() - config.Parameters.keys()
627-
628-
for key in miss_params_keys:
629-
"""
630-
For each missing key in the bottle configuration, set
631-
it to the default value.
632-
"""
633-
logging.warning(
634-
f"Parameters key {key} is missing for bottle {_name}, updating…"
635-
)
636-
self.update_config(
637-
config=config,
638-
key=key,
639-
value=sample.Parameters[key],
640-
scope="Parameters",
641-
)
642-
self.local_bottles[config.Name] = config
643-
644-
real_path = ManagerUtils.get_bottle_path(config)
645-
for p in [
646-
os.path.join(real_path, "cache", "dxvk_state"),
647-
os.path.join(real_path, "cache", "gl_shader"),
648-
os.path.join(real_path, "cache", "mesa_shader"),
649-
os.path.join(real_path, "cache", "vkd3d_shader"),
650-
]:
651-
if not os.path.exists(p):
652-
os.makedirs(p)
653-
654-
for c in os.listdir(real_path):
655-
c = str(c)
656-
if c.endswith(".dxvk-cache"):
657-
# NOTE: the following code tries to create the caching directories
658-
# if one or more already exist, it will fail silently as there
659-
# is no need to create them again.
660-
try:
661-
shutil.move(
662-
os.path.join(real_path, c),
663-
os.path.join(real_path, "cache", "dxvk_state"),
664-
)
665-
except shutil.Error:
666-
pass
667-
elif "vkd3d-proton.cache" in c:
668-
try:
669-
shutil.move(
670-
os.path.join(real_path, c),
671-
os.path.join(real_path, "cache", "vkd3d_shader"),
672-
)
673-
except shutil.Error:
674-
pass
675-
elif c == "GLCache":
676-
try:
677-
shutil.move(
678-
os.path.join(real_path, c),
679-
os.path.join(real_path, "cache", "gl_shader"),
680-
)
681-
except shutil.Error:
682-
pass
683-
684-
if config.Parameters.dxvk_nvapi:
685-
NVAPIComponent.check_bottle_nvngx(real_path, config)
686-
687-
for b in bottles:
688-
"""
689-
For each bottle add the path name to the `local_bottles` variable
690-
and append the config.
691-
"""
692-
process_bottle(b)
693-
694-
if len(self.local_bottles) > 0 and not silent:
695-
logging.info(
696-
"Bottles found:\n - {}".format("\n - ".join(self.local_bottles))
697-
)
698-
699545
# Update parameters in bottle config
700546
def update_config(
701547
self,
@@ -839,7 +685,6 @@ def create_bottle_from_config(self, config: BottleConfig) -> bool:
839685
self.install_dll_component(config, "vkd3d")
840686

841687
logging.info(f"New bottle from config created: {config.Path}")
842-
self.update_bottles(silent=True)
843688
return True
844689

845690
def create_bottle(
@@ -1153,8 +998,6 @@ def delete_bottle(self, config: BottleConfig) -> bool:
1153998
path = ManagerUtils.get_bottle_path(config)
1154999
subprocess.run(["rm", "-rf", path], stdout=subprocess.DEVNULL)
11551000

1156-
self.update_bottles(silent=True)
1157-
11581001
logging.info(f"Deleted the bottle in: {path}")
11591002
return True
11601003

bottles/frontend/main.py

-10
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,6 @@ def __help(action=None, param=None):
248248
)
249249
webbrowser.open_new_tab("https://docs.usebottles.com")
250250

251-
def __refresh(self, action=None, param=None):
252-
"""
253-
This function refresh the user bottle list.
254-
It is used by the [Ctrl+R] shortcut.
255-
"""
256-
logging.info(
257-
_("[Refresh] request received."),
258-
)
259-
self.win.manager.update_bottles()
260-
261251
def __show_preferences(self, *args):
262252
preferences_window = PreferencesWindow(self.win)
263253
preferences_window.present()

0 commit comments

Comments
 (0)