diff options
author | David Sommerseth <davids@redhat.com> | 2009-06-10 18:57:42 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2009-06-10 18:57:42 +0200 |
commit | 65c9384ec9b6e265aba11227ffa37ae7a6a787d1 (patch) | |
tree | 63c51e604a9e4d30dbda43cced9b28a01a149e68 /unit-tests | |
parent | e9ae400e4dc70966bfd940c27f9a8b91d5caffa4 (diff) | |
download | python-dmidecode-65c9384ec9b6e265aba11227ffa37ae7a6a787d1.tar.gz python-dmidecode-65c9384ec9b6e265aba11227ffa37ae7a6a787d1.tar.xz python-dmidecode-65c9384ec9b6e265aba11227ffa37ae7a6a787d1.zip |
Fixed import issues with dmidecode
As we now include libxml2 and the required libxml2mod (which is used to wrap
xmlDoc and xmlNode data into Python objects), importing only dmidecode caused
a failure. If adding import libxml2 first, everything would work out fine.
To avoid this issue, due to backwards compatibility, a tiny dmidecode wrapper
is implemted as well. The dmidecode.so module is now renamed to dmidecodemodule.so,
and the wrapper is now called dmidecode.py.
To simplify things, the dmidecodeXML module introduced in commit b25b2ca548508cd2beb26f465b7bc5a296592461
is not merged into the new dmidecode.py
The constants mentioned are now called dmidecode.DMIXML_NODE and dmidecode.DMIXML_DOC
and to instantiate the dmidecodeXML class, dmidecode.dmidecodeXML() is used.
Diffstat (limited to 'unit-tests')
l--------- | unit-tests/dmidecode.py | 1 | ||||
-rwxr-xr-x | unit-tests/unit | 23 |
2 files changed, 12 insertions, 12 deletions
diff --git a/unit-tests/dmidecode.py b/unit-tests/dmidecode.py new file mode 120000 index 0000000..4876cd6 --- /dev/null +++ b/unit-tests/dmidecode.py @@ -0,0 +1 @@ +../dmidecode.py
\ No newline at end of file diff --git a/unit-tests/unit b/unit-tests/unit index b6018f9..8156945 100755 --- a/unit-tests/unit +++ b/unit-tests/unit @@ -64,8 +64,8 @@ def test(r, msg=None, indent=1): sys.stdout.write(LINE) sys.stdout.write(" * Testing for dmidecode (upstream)...") -d = True in [os.path.exists(os.path.join(_, "dmidecode")) for _ in os.getenv("PATH").split(':')] -test(d) +dmidecode_bin = True in [os.path.exists(os.path.join(_, "dmidecode")) for _ in os.getenv("PATH").split(':')] +test(dmidecode_bin) sys.stdout.write(" * Creation of temporary files...") try: @@ -77,13 +77,12 @@ except: failed() sys.stdout.write(LINE) -sys.stdout.write(" * Importing module...") try: + sys.stdout.write(" * Importing module...") import libxml2 import dmidecode - import dmidecodeXML - passed() + sys.stdout.write(" * Version: %s\n"%blue(dmidecode.version)) sys.stdout.write(" * DMI Version String: %s\n"%blue(dmidecode.dmi)) @@ -153,7 +152,7 @@ try: sys.stdout.write(" * Testing type %s..."%red(i)); sys.stdout.flush() try: output = dmidecode.type(i) - if dmidecode: + if dmidecode_bin: _output = commands.getoutput("dmidecode -t %d"%i).strip().split('\n') test(len(_output) == 1 and len(output) == 0 or True) else: @@ -165,7 +164,7 @@ try: except LookupError, e: failed(e, 2) - dmixml = dmidecodeXML.dmidecodeXML() + dmixml = dmidecode.dmidecodeXML() try: sys.stdout.write(" * XML: Swapping result type dmidecodeXML::SetResultType('-')..."); sys.stdout.flush() @@ -178,12 +177,12 @@ try: failed() try: - sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecodeXML.DMIXML_DOC)..."); + sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecode.DMIXML_DOC)..."); sys.stdout.flush() - test(dmixml.SetResultType(dmidecodeXML.DMIXML_DOC)) - sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecodeXML.DMIXML_NODE)..."); + test(dmixml.SetResultType(dmidecode.DMIXML_DOC)) + sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecode.DMIXML_NODE)..."); sys.stdout.flush() - test(dmixml.SetResultType(dmidecodeXML.DMIXML_NODE)) + test(dmixml.SetResultType(dmidecode.DMIXML_NODE)) except: failed() @@ -216,7 +215,7 @@ try: except: failed() - dmixml.SetResultType(dmidecodeXML.DMIXML_DOC) + dmixml.SetResultType(dmidecode.DMIXML_DOC) i = 0 for section in sections: i += 1 |