[chirp_devel] run_tests: No module named serial

chirp.cordless at xoxy.net
Thu Apr 10 10:09:27 PDT 2014


On further review, I have an alternative proposal.
Given the hints from Tom and Jens that python ignores
the shebang line (!!), I just created an alias for the kk7ds
python, and run it as
% kk7python run_tests
Works fine, so I don't need to edit the script.

But in the cause of incremental positive improvement, here's
a suggestion for a patch to the file that might help the next
newbie resolve this without help:

==========
diff -r 1cc897a1d161 tests/run_tests
--- a/tests/run_tests	Wed Apr 09 20:30:12 2014 -0700
+++ b/tests/run_tests	Thu Apr 10 10:04:59 2014 -0700
@@ -17,7 +17,12 @@
 
 import traceback, sys, os, shutil, glob, tempfile, time
 from optparse import OptionParser
-from serial import Serial
+try:
+        from serial import Serial
+except ImportError,e:
+        print "\nNo module named serial found.\n" \
+		"This script must be run with the kk7ds Python distribution"
+        sys.exit(1)
 
 # Assume we're running in the tests/ directory of the archive
 sys.path.insert(0, "../")
===========

That behaves as intended, both cases. I'm a bit green on
the try/except paradigm, so I thought I'd post it for review.

Shall I make this patch?

-dan


> ...
> I don't mind doing the work, it's going to be a pain editing
> run_tests every time, and then restoring it so hg doesn't try
> to add it to a patch. I could probably add a mac_run_tests
> wrapper, essentially duplicating what the script in the app does.
> 
> On Apr 9, 2014, at 4:48 PM, Tom Hayward - esarfl at gmail.com  wrote:
>> Sorry I don't have the time to focus on this right now, but here's another hint:
>> http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script
>> 
>> Notice that this is *not* how Dan calls Python from run_tests. You
>> might fix it and submit it as your first bug fix :-)
>> 
>> Tom KD7LXL
> 





More information about the chirp_devel mailing list