Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: /, PMSTestSuite/pm/
Date: Thu, 26 May 2011 09:46:06
Message-Id: 9f63f0336ec73e876820478d6ad86c5b7cd9a960.mgorny@gentoo
1 commit: 9f63f0336ec73e876820478d6ad86c5b7cd9a960
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 26 09:45:52 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu May 26 09:45:52 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9f63f033
7
8 Refuse to instantiate non-installed PM.
9
10 ---
11 PMSTestSuite/pm/__init__.py | 3 +++
12 ebuild-generator | 5 ++++-
13 2 files changed, 7 insertions(+), 1 deletions(-)
14
15 diff --git a/PMSTestSuite/pm/__init__.py b/PMSTestSuite/pm/__init__.py
16 index 26efaf7..80e698b 100644
17 --- a/PMSTestSuite/pm/__init__.py
18 +++ b/PMSTestSuite/pm/__init__.py
19 @@ -66,6 +66,9 @@ def get_package_managers():
20
21 def inst(self):
22 """ Instantiate the associated PM. """
23 + if not self._pmclass.is_available():
24 + raise Exception('PM is not available! Please consider installing %s.'
25 + % self._pmclass.pkg)
26 return self._pmclass()
27
28 return [PMWrapper(x) for x in (PortagePM,)]
29
30 diff --git a/ebuild-generator b/ebuild-generator
31 index 4394a0e..1db83ea 100755
32 --- a/ebuild-generator
33 +++ b/ebuild-generator
34 @@ -37,7 +37,10 @@ def main(prog, *args):
35
36 for x in get_package_managers():
37 if x.name == opts.pm:
38 - pm = x.inst()
39 + try:
40 + pm = x.inst()
41 + except Exception as e:
42 + opt.error(e)
43 break
44 else:
45 opt.error('Package manager not supported: %s' % opts.pm)