Skip to content

Remove loading view and rework connections #3710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions bottles/backend/managers/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@

# noinspection PyTypeChecker
class ComponentManager:
def __init__(self, manager, offline: bool = False):
def __init__(self, manager):
self.__manager = manager
self.__repo = manager.repository_manager.get_repo("components", offline)
self.__utils_conn = manager.utils_conn
self.__repo = manager.repository_manager.get_repo("components")

@lru_cache
def get_component(self, name: str, plain: bool = False) -> dict:
Expand All @@ -58,9 +57,6 @@ def fetch_catalog(self) -> dict:
Fetch all components from the Bottles repository, mark the installed
ones and return a dict with the catalog.
"""
if not self.__utils_conn.check_connection():
return {}

catalog = {
"runtimes": {},
"wine": {},
Expand Down
7 changes: 2 additions & 5 deletions bottles/backend/managers/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@


class DependencyManager:
def __init__(self, manager, offline: bool = False):
def __init__(self, manager):
self.__manager = manager
self.__repo = manager.repository_manager.get_repo("dependencies", offline)
self.__utils_conn = manager.utils_conn
self.__repo = manager.repository_manager.get_repo("dependencies")

@lru_cache
def get_dependency(self, name: str, plain: bool = False) -> str | dict | bool:
Expand All @@ -59,8 +58,6 @@ def fetch_catalog(self) -> dict:
and return these as a dictionary. It also returns an empty dictionary
if there are no dependencies or fails to fetch them.
"""
if not self.__utils_conn.check_connection():
return {}

catalog = {}
index = self.__repo.catalog
Expand Down
7 changes: 2 additions & 5 deletions bottles/backend/managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@


class InstallerManager:
def __init__(self, manager, offline: bool = False):
def __init__(self, manager):
self.__manager = manager
self.__repo = manager.repository_manager.get_repo("installers", offline)
self.__utils_conn = manager.utils_conn
self.__repo = manager.repository_manager.get_repo("installers")
self.__component_manager = manager.component_manager
self.__local_resources = {}

Expand Down Expand Up @@ -68,8 +67,6 @@ def fetch_catalog(self) -> dict:
"""Fetch the installers catalog from the repository"""
catalog = {}
index = self.__repo.catalog
if not self.__utils_conn.check_connection():
return {}

for installer in index.items():
catalog[installer[0]] = installer[1]
Expand Down
78 changes: 7 additions & 71 deletions bottles/backend/managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from bottles.backend.models.samples import Samples
from bottles.backend.state import SignalManager, Signals, Events, EventManager
from bottles.backend.utils import yaml
from bottles.backend.utils.connection import ConnectionUtils
from bottles.backend.utils.file import FileUtils
from bottles.backend.utils.generic import sort_by_version
from bottles.backend.utils.gpu import GPUUtils
Expand Down Expand Up @@ -106,7 +105,6 @@ class Manager(metaclass=Singleton):
def __init__(
self,
g_settings: Any = None,
check_connection: bool = True,
is_cli: bool = False,
**kwargs,
):
Expand All @@ -117,14 +115,8 @@ def __init__(
# common variables
self.is_cli = is_cli
self.settings = g_settings or GSettingsStub
self.utils_conn = ConnectionUtils(
force_offline=self.is_cli or self.settings.get_boolean("force-offline")
)
self.data_mgr = DataManager()
_offline = True

if check_connection:
_offline = not self.utils_conn.check_connection()
_offline = False

# validating user-defined Paths.bottles
if user_bottles_path := self.data_mgr.get(UserDataKeys.CustomBottlesPath):
Expand All @@ -137,17 +129,14 @@ def __init__(
)

# sub-managers
self.repository_manager = RepositoryManager(get_index=not _offline)
if self.repository_manager.aborted_connections > 0:
self.utils_conn.status = False
_offline = True
self.repository_manager = RepositoryManager()

times["RepositoryManager"] = time.time()
self.versioning_manager = VersioningManager(self)
times["VersioningManager"] = time.time()
self.component_manager = ComponentManager(self, _offline)
self.installer_manager = InstallerManager(self, _offline)
self.dependency_manager = DependencyManager(self, _offline)
self.component_manager = ComponentManager(self)
self.installer_manager = InstallerManager(self)
self.dependency_manager = DependencyManager(self)
self.import_manager = ImportManager(self)
times["ImportManager"] = time.time()
self.steam_manager = SteamManager()
Expand Down Expand Up @@ -420,25 +409,7 @@ def check_runners(self, install_latest: bool = True) -> bool:

if len(tmp_runners) == 0 and install_latest:
logging.warning("No managed runners found.")

if self.utils_conn.check_connection():
# if connected, install the latest runner from repository
try:
if not self.settings.get_boolean("release-candidate"):
tmp_runners = []
for runner in self.supported_wine_runners.items():
if runner[1]["Channel"] not in ["rc", "unstable"]:
tmp_runners.append(runner)
break
runner_name = next(iter(tmp_runners))[0]
else:
tmp_runners = self.supported_wine_runners
runner_name = next(iter(tmp_runners))
self.component_manager.install("runner", runner_name)
except StopIteration:
return False
else:
return False
return False

return True

Expand All @@ -451,13 +422,6 @@ def check_runtimes(self, install_latest: bool = True) -> bool:
runtimes = os.listdir(Paths.runtimes)

if len(runtimes) == 0:
if install_latest and self.utils_conn.check_connection():
logging.warning("No runtime found.")
try:
version = next(iter(self.supported_runtimes))
return self.component_manager.install("runtime", version)
except StopIteration:
return False
return False

runtime = runtimes[0] # runtimes cannot be more than one
Expand All @@ -480,15 +444,6 @@ def check_winebridge(
winebridge = os.listdir(Paths.winebridge)

if len(winebridge) == 0 or update:
if install_latest and self.utils_conn.check_connection():
logging.warning("No WineBridge found.")
try:
version = next(iter(self.supported_winebridge))
self.component_manager.install("winebridge", version)
self.winebridge_available = [version]
return True
except StopIteration:
return False
return False

version_file = os.path.join(Paths.winebridge, "VERSION")
Expand Down Expand Up @@ -637,26 +592,7 @@ def __check_component(

if len(component["available"]) == 0 and install_latest:
logging.warning(f"No {component_type} found.")

if self.utils_conn.check_connection():
# if connected, install the latest component from repository
try:
if not self.settings.get_boolean("release-candidate"):
tmp_components = []
for cpnt in component["supported"].items():
if cpnt[1]["Channel"] not in ["rc", "unstable"]:
tmp_components.append(cpnt)
break
component_version = next(iter(tmp_components))[0]
else:
tmp_components = component["supported"]
component_version = next(iter(tmp_components))
self.component_manager.install(component_type, component_version)
component["available"] = [component_version]
except StopIteration:
return False
else:
return False
return False

try:
return sort_by_version(component["available"])
Expand Down
9 changes: 4 additions & 5 deletions bottles/backend/managers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,18 @@ class RepositoryManager:
},
}

def __init__(self, get_index=True):
def __init__(self):
self.do_get_index = True
self.aborted_connections = 0
SignalManager.connect(Signals.ForceStopNetworking, self.__stop_index)

self.__check_personals()
if get_index:
self.__get_index()
self.__get_index()

def get_repo(self, name: str, offline: bool = False):
def get_repo(self, name: str):
if name in self.__repositories:
repo = self.__repositories[name]
return repo["cls"](repo["url"], repo["index"], offline=offline)
return repo["cls"](repo["url"], repo["index"])

logging.error(f"Repository {name} not found")

Expand Down
110 changes: 0 additions & 110 deletions bottles/backend/utils/connection.py

This file was deleted.

1 change: 0 additions & 1 deletion bottles/backend/utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ bottles_sources = [
'yaml.py',
'nvidia.py',
'threading.py',
'connection.py',
'gsettings_stub.py',
'json.py',
'singleton.py'
Expand Down
1 change: 0 additions & 1 deletion bottles/frontend/bottles.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">new-bottle-dialog.ui</file>
<file preprocess="xml-stripblanks">bottles-list-view.ui</file>
<file preprocess="xml-stripblanks">loading-view.ui</file>
<file preprocess="xml-stripblanks">bottle-row.ui</file>
<file preprocess="xml-stripblanks">check-row.ui</file>
<file preprocess="xml-stripblanks">task-row.ui</file>
Expand Down
3 changes: 1 addition & 2 deletions bottles/frontend/bottles_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ class BottlesListView(Adw.Bin):

# endregion

def __init__(self, window, arg_bottle=None, **kwargs):
def __init__(self, window, **kwargs):
super().__init__(**kwargs)

# common variables and references
self.window = window
self.arg_bottle = arg_bottle

# connect signals
self.btn_create.connect("clicked", self.window.show_add_view)
Expand Down
6 changes: 0 additions & 6 deletions bottles/frontend/details_dependencies_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ def __init__(self, details, config: BottleConfig, **kwargs):
)
self.btn_help.connect("clicked", open_doc_url, "bottles/dependencies")

if not self.manager.utils_conn.status:
self.stack.set_visible_child_name("page_offline")

self.spinner_loading.start()

def __search_dependencies(self, *_args):
Expand Down Expand Up @@ -100,9 +97,6 @@ def update(self, _widget=False, config: BottleConfig | None = None):
self.config = config

# Not sure if it's the best place to make this check
if not self.manager.utils_conn.status:
return

self.stack.set_visible_child_name("page_loading")

def new_dependency(dependency, plain=False):
Expand Down
Loading
Loading