On 03/26/2012 02:42 PM, Michal Novotny wrote: > On 03/26/2012 02:30 PM, Peter Krempa wrote: >> On 03/24/2012 06:42 PM, Martin Kletzander wrote: >>> There is no support for distributions without 'rpm' as a package >>> manager. This patch modifies (at this time) the only >>> distribution-specific import in order to ease the broadening of >>> distribution list supported by libvirt-test-API. >>> --- >>> env_inspect.py => dist/redhat/env_inspect.py | 0 >>> generator.py | 12 ++++++++++-- >>> 2 files changed, 10 insertions(+), 2 deletions(-) >>> create mode 100644 dist/__init__.py >>> create mode 100644 dist/redhat/__init__.py >>> rename env_inspect.py => dist/redhat/env_inspect.py (100%) >>> >>> diff --git a/dist/__init__.py b/dist/__init__.py >>> new file mode 100644 >>> index 0000000..e69de29 >>> diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py >>> new file mode 100644 >>> index 0000000..e69de29 >>> diff --git a/env_inspect.py b/dist/redhat/env_inspect.py >>> similarity index 100% >>> rename from env_inspect.py >>> rename to dist/redhat/env_inspect.py >>> diff --git a/generator.py b/generator.py >>> index 6108963..4f4478b 100644 >>> --- a/generator.py >>> +++ b/generator.py >>> @@ -1,6 +1,6 @@ >>> #!/usr/bin/env python >>> # >>> -# libvirt-test-API is copyright 2010 Red Hat, Inc. >>> +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. >>> # >>> # libvirt-test-API is free software: you can redistribute it and/or modify it >>> # under the terms of the GNU General Public License as published by >>> @@ -23,10 +23,18 @@ import sys >>> import traceback >>> >>> import mapper >>> -import env_inspect >>> from utils.Python import log >>> from utils.Python import format >>> >>> +# Import of distribution-specific code. If this is needed somewhere >>> +# else in the future, please don't copy-paste this, but create some >>> +# sensible distribution-specific package >>> +import os >>> +for dist in os.listdir('dist'): >>> + if os.path.exists('/etc/%s-release' % dist): >>> + exec('from dist.%s import env_inspect' % dist) >>> + break >>> + >> Works great on Gentoo, but I'm afraid a bit that it could break Fedora >> if it uses a different version file name. (but I don't have any at hand >> so I can't test this ) >> >> Peter > > Fedora is using /etc/redhat-release file so you use the same handling > for Fedora and RHEL then it's fine. > > Michal > Exactly. I remembered that all Red Hat-based distributions have the file (and should have it), thus rpm can be use to get all the info (same imported file). Little OT while on that note: In the future it would be great to have one place where we examine the sys.path used for importing other packages (instead of having the same 10 lines in every file in the whole libvirt-test-API) and in this place this code could be done globally. Martin -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list