diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2011-08-18 22:45:17 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2011-08-18 22:45:17 +0000 |
commit | 3bf988e877a2393ea22fa1e5213eaa3085160e92 (patch) | |
tree | 420c248c24d9732d612398a08471ec48847e304d | |
parent | ac3084b841dfb414ab029f827ab7e3e48b941a45 (diff) | |
download | pyserial-3bf988e877a2393ea22fa1e5213eaa3085160e92.tar.gz |
raise ImportError (instead of plain Exception) if platform is not supported
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@410 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r-- | serial/__init__.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/serial/__init__.py b/serial/__init__.py index be1647c..986f7a4 100644 --- a/serial/__init__.py +++ b/serial/__init__.py @@ -22,7 +22,8 @@ else: elif os.name == 'java': from serialjava import * else: - raise Exception("Sorry: no implementation for your platform ('%s') available" % os.name) + raise ImportError("Sorry: no implementation for your platform ('%s') available" % (os.name,)) + protocol_handler_packages = [ 'serial.urlhandler', @@ -30,12 +31,13 @@ protocol_handler_packages = [ def serial_for_url(url, *args, **kwargs): """\ - Get a native, a RFC2217 or socket implementation of the Serial class, - depending on port/url. The port is not opened when the keyword parameter - 'do_not_open' is true, by default it is. + Get an instance of the Serial class, depending on port/url. The port is not + opened when the keyword parameter 'do_not_open' is true, by default it + is. All other parameters are directly passed to the __init__ method when + the port is instantiated. The list of package names that is searched for protocol handlers is kept in - ``protocol_handler_packages`` + ``protocol_handler_packages``. e.g. we want to support a URL ``foobar://``. A module ``my_handlers.protocol_foobar`` is provided by the user. Then |