selftest/buildoptions: pexpect not a builtin module
PATCH 1/1 selftest/buildoptions: pexpect not a builtin module
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
the message that outputs is:
"No module named pexpect, import failed"
--- meta/lib/oeqa/selftest/buildoptions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/buildoptions.py +7 -1
@@ -3,7 +3,13 @@ import os import logging import re import glob as g -import pexpect as p + +try: + import pexpect as p +except ImportError as e: + import sys + sys.stderr.write("{}, import failed\n".format(e)) + raise e from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase
Signature · 1 line
2.5.1
Quoted 3 lines · Benjamin Esquivel
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
As the failing import is throwing an exception, can't the calling code display the exception correctly?
Ross
Quoted 8 lines · Ross
On 17 September 2015 at 21:38, Benjamin Esquivel <
Quoted 2 lines · [email protected]> wrote:
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
As the failing import is throwing an exception, can't the calling code display the exception correctly?
If we're going to trap this I think we should be displaying something like "Please install pexpect (python-pexpect)".
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
PATCH v2 1/1 selftest/buildoptions: pexpect not a builtin module
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
the message that outputs is:
"No module named pexpect, import failed"
"Please install pexpect (python-pexpect)"
--- meta/lib/oeqa/selftest/buildoptions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/buildoptions.py +8 -1
@@ -3,7 +3,14 @@ import os import logging import re import glob as g -import pexpect as p + +try: + import pexpect as p +except ImportError as e: + import sys + sys.stderr.write("{}, import failed\n".format(e)) + sys.stderr.write("Please install pexpect (python-pexpect)\n") + raise e from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase
Signature · 1 line
2.5.1
Hi Benjamin, Paul,
Just want to point out that 'pexpect' is an unused import in buildoptions.py. Unused imports are also unittest and logging. Instead of try-catch an import that is not used I think it's best to get rid of them.
--Daniel
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Benjamin Esquivel
Sent: Friday, September 18, 2015 11:34
To: [email protected]
Cc: [email protected]
Subject: [OE-core] [PATCH V2] selftest/buildoptions: pexpect not a builtin module
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
the message that outputs is:
"No module named pexpect, import failed"
"Please install pexpect (python-pexpect)"
--- meta/lib/oeqa/selftest/buildoptions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/buildoptions.py +8 -2
@@ -3,7 +3,14 @@ import os import logging import re import glob as g -import pexpect as p + +try: + import pexpect as p +except ImportError as e: + import sys + sys.stderr.write("{}, import failed\n".format(e)) + sys.stderr.write("Please install pexpect (python-pexpect)\n") + raise e from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase --
2.5.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 5 lines · Daniel AlexandruX
Just want to point out that 'pexpect' is an unused import in
buildoptions.py. Unused imports are also unittest and logging. Instead of try-catch an import that is not used I think it's best to get rid of them.
Totally agreed. Can you send a quick patch?
Ross
Hi Ross,
I sent the patch: http://lists.openembedded.org/pipermail/openembedded-core/2015-September/110738.html
--Daniel
From: Burton, Ross [mailto:[email protected]]
Sent: Monday, September 21, 2015 13:20
To: Istrate, Daniel AlexandruX
Cc: Benjamin Esquivel; [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH V2] selftest/buildoptions: pexpect not a builtin module
On 21 September 2015 at 09:37, Istrate, Daniel AlexandruX <[email protected]<mailto:[email protected]>> wrote:
Just want to point out that 'pexpect' is an unused import in buildoptions.py. Unused imports are also unittest and logging. Instead of try-catch an import that is not used I think it's best to get rid of them.
Totally agreed. Can you send a quick patch?
Ross
Great! thanks Daniel.
Quoted 26 lines · Daniel AlexandruX
Hi Ross,
I sent the patch: http://lists.openembedded.org/pipermail/openembedde
d-core/2015-September/110738.html--Daniel
From: Burton, Ross [mailto:[email protected]]
Sent: Monday, September 21, 2015 13:20
To: Istrate, Daniel AlexandruX
Cc: Benjamin Esquivel; [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH V2] selftest/buildoptions: pexpect not a builtin moduleOn 21 September 2015 at 09:37, Istrate, Daniel AlexandruX < [email protected]> wrote:
Just want to point out that 'pexpect' is an unused import inbuildoptions.py. Unused imports are also unittest and logging. Instead of try-catch an import that is not used I think it's best to get rid of them.Totally agreed. Can you send a quick patch?
Ross
Quoted 9 lines · Ross
Quoted 4 lines · Benjamin Esquivel
put the import of pexpect around a try statement so it can tell you why it failed to import when in a system that has the module unreachable
As the failing import is throwing an exception, can't the calling code display the exception correctly?
This is the logging without the change:
2015-09-18 08:27:44,233 - selftest - INFO - Loading tests from: oeqa.selftest.buildhistory 2015-09-18 08:27:44,234 - selftest - INFO - Loading tests from: oeqa.selftest.buildoptions 2015-09-18 08:27:44,236 - selftest - ERROR - Failed to import oeqa.selftest.buildoptions 2015-09-18 08:27:44,236 - selftest - ERROR - 'module' object has no attribute 'buildoptions' This is the logging with the proposed change and including Paul's comment: 2015-09-18 08:27:44,233 - selftest - INFO - Loading tests from: oeqa.selftest.buildhistory 2015-09-18 08:27:44,234 - selftest - INFO - Loading tests from: oeqa.selftest.buildoptions No module named pexpect, import failed Please install pexpect (python-pexpect) 2015-09-18 08:27:44,236 - selftest - ERROR - Failed to import oeqa.selftest.buildoptions 2015-09-18 08:27:44,236 - selftest - ERROR - 'module' object has no
attribute 'buildoptions'
I'm sending the patch V2
Quoted 2 lines
Quoted 1 line
Ross