From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 76A3A1393DD for ; Fri, 15 Aug 2014 22:32:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 70FF2E0AAE; Fri, 15 Aug 2014 22:32:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A44A2E0AB0 for ; Fri, 15 Aug 2014 22:32:38 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 70E393405E1 for ; Fri, 15 Aug 2014 22:32:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 73F3B18816 for ; Fri, 15 Aug 2014 22:32:35 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1408136258.89bf796adb52fac6c9472f5dc40bc137e4ab0d44.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/api.py X-VCS-Directories: layman/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 89bf796adb52fac6c9472f5dc40bc137e4ab0d44 X-VCS-Branch: gsoc2014 Date: Fri, 15 Aug 2014 22:32:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cb5f8e89-1850-4b2a-9f8b-cdbb8215c782 X-Archives-Hash: da00fbfccb1711969f4a07907f3a0691 commit: 89bf796adb52fac6c9472f5dc40bc137e4ab0d44 Author: Devan Franchini gentoo org> AuthorDate: Thu Jul 10 20:26:45 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Fri Aug 15 20:57:38 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=89bf796a api.py: Adds disable and enable repo functions X-Gentoo-Bug: 512316 X-Gentoo-Bug-URL: https://bugs.gentoo.org/512316 --- layman/api.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/layman/api.py b/layman/api.py index 17c7998..bae6972 100755 --- a/layman/api.py +++ b/layman/api.py @@ -122,7 +122,7 @@ class LaymanAPI(object): self._get_installed_db().select(ovl)) except Exception as e: self._error( - "Exception caught disabling repository '"+ovl+ + "Exception caught removing repository '"+ovl+ "':\n"+str(e)) results.append(success) self.get_installed(dbreload=True) @@ -155,7 +155,7 @@ class LaymanAPI(object): success = self._get_installed_db().add( self._get_remote_db().select(ovl)) except Exception as e: - self._error("Exception caught enabling repository '"+ovl+ + self._error("Exception caught installing repository '"+ovl+ "' : "+str(e)) results.append(success) self.get_installed(dbreload=True) @@ -183,6 +183,56 @@ class LaymanAPI(object): return success + def disable_repos(self, repos, update_news=False): + repos = self._check_repo_type(repos, "disable_repo") + results = [] + for ovl in repos: + if not self.is_repo(ovl): + self.output.error(UnknownOverlayMessage(ovl)) + result.append(False) + continue + success = False + try: + success = self._get_installed_db().disable( + self._get_installed_db().select(ovl)) + except Exception as e: + self._error('Exception caught disabling repository "%(repo)s"'\ + ': %(err)s' % ({'repo': ovl, 'err': e})) + results.append(success) + self.get_installed(dbreload=True) + if (True in results) and update_news: + self.update_news(repos) + + if False in results: + return False + return True + + + def enable_repos(self, repos, update_news=False): + repos = self._check_repo_type(repos, "enable_repo") + results = [] + for ovl in repos: + if not self.is_repo(ovl): + self.output.error(UnknownOverlayMessage(ovl)) + result.append(False) + continue + success = False + try: + success = self._get_installed_db().enable( + self._get_installed_db().select(ovl)) + except Exception as e: + self._error('Exception caught enabling repository "%(repo)s"'\ + ': %(err)s' % ({'repo': ovl, 'err': e})) + results.append(success) + self.get_installed(dbreload=True) + if (True in results) and update_news: + self.update_news(repos) + + if False in results: + return False + return True + + def get_all_info(self, repos, local=False): """retrieves the recorded information about the repo(s) specified by repo-id