From 6d89177836b5d0dc531dca0e3b7309da815a2eee Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 3 Jan 2010 23:18:41 +0100 Subject: [PATCH] [entropy.client] move UGC information storage outside the main entropy lib --- client/text_repositories.py | 6 ++++++ .../entropy/client/interfaces/repository.py | 8 ++------ sulfur/src/sulfur/__init__.py | 20 ++++++------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/client/text_repositories.py b/client/text_repositories.py index 643a93f50..ead03f546 100644 --- a/client/text_repositories.py +++ b/client/text_repositories.py @@ -179,8 +179,14 @@ def _do_sync(entropy_client, repo_identifiers = None, force = False): rc = repo_intf.sync() if not rc: + for reponame in repo_identifiers: + # inform UGC that we are syncing this repo + if entropy_client.UGC is not None: + entropy_client.UGC.add_download_stats(reponame, [reponame]) + for reponame in repo_identifiers: _show_notice_board_summary(entropy_client, reponame) + return rc def _check_notice_board_availability(entropy_client, reponame): diff --git a/libraries/entropy/client/interfaces/repository.py b/libraries/entropy/client/interfaces/repository.py index 5e3381f48..d4e8c915b 100644 --- a/libraries/entropy/client/interfaces/repository.py +++ b/libraries/entropy/client/interfaces/repository.py @@ -1223,7 +1223,7 @@ class Repository: return gpg_rc - def run_sync(self): + def _run_sync(self): self.updated = False repocount = 0 @@ -1448,10 +1448,6 @@ class Repository: # database has been updated self.updated = True - # inform UGC that we are syncing this repo - if self.Entropy.UGC is not None: - self.Entropy.UGC.add_download_stats(repo, [repo]) - # remove garbage left around for path in files_to_remove: try: @@ -2072,7 +2068,7 @@ class Repository: if not acquired: return 4 # app locked during lock acquire try: - rc = self.run_sync() + rc = self._run_sync() finally: self.Entropy.resources_remove_lock() if rc: diff --git a/sulfur/src/sulfur/__init__.py b/sulfur/src/sulfur/__init__.py index b30d0e694..b15b13483 100644 --- a/sulfur/src/sulfur/__init__.py +++ b/sulfur/src/sulfur/__init__.py @@ -1205,26 +1205,13 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin): try: repoConn = self.Equo.Repositories(repos, force = force) - except PermissionDenied: - self.progress_log(_('You must run this application as root'), - extra = "repositories") - self.disable_ugc = False - self.show_notebook_tabs_after_install() - return 1 - except MissingParameter: + except AttributeError: msg = "%s: %s" % (_('No repositories specified in'), etpConst['repositoriesconf'],) self.progress_log( msg, extra = "repositories") self.disable_ugc = False self.show_notebook_tabs_after_install() return 127 - except OnlineMirrorError: - self.progress_log( - _('You are not connected to the Internet. You should.'), - extra = "repositories") - self.disable_ugc = False - self.show_notebook_tabs_after_install() - return 126 except Exception as e: msg = "%s: %s" % (_('Unhandled exception'), e,) self.progress_log(msg, extra = "repositories") @@ -1245,6 +1232,11 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin): self.gtk_loop() rc = self.__repo_update_rc + for repo in repos: + # inform UGC that we are syncing this repo + if self.Equo.UGC is not None: + self.Equo.UGC.add_download_stats(repo, [repo]) + if repoConn.sync_errors or (rc != 0): self.progress.set_mainLabel(_('Errors updating repositories.')) self.progress.set_subLabel(