Nope, it's not namespacing. In python it's safe to just "import serial"

You know the problem is due the "call" function.

Instead using:
*    except* ser.SerialTimeoutException:

use:
 except serial.SerialTimeoutException:
  print('Data could not be read')
 except:
  print 'Error', sys.exc_info()

And see a better log message.
Don't forget to "import sys"

I belive the problem is the "video_player.py" or the ".mp4" files are not in /bin. Or you don't have permission in those files...


Em 27-06-2014 16:42, William Hermans escreveu:
Keep in mind I am not all that familiar with Python, but have been programming in multiple other languages since the 90's. Meaning, I dont write code in Python, but can usually read through it ok.

Anyhow, according to that post this error is due to namespace resolution. Meaning . ..

*/import serial /*should instead be /*from serial import serial

*/
The second answer although seemingly rewarded with more votes is FUD, and would be what I'd consider very bad programming technique. Never name your project the same as an already existing module.


On Fri, Jun 27, 2014 at 10:51 AM, John McClaire <[email protected] <mailto:[email protected]>> wrote:

    Yeah I saw that, but rushed through it. I'll take a closer look.
    Thanks for helping the n00b.


    On Fri, Jun 27, 2014 at 1:17 PM, William Hermans
    <[email protected] <mailto:[email protected]>> wrote:

        
http://stackoverflow.com/questions/11403932/python-attributeerror-module-object-has-no-attribute-serial

        First hit From :
        
https://www.google.com/#q=AttributeError%3A+%27Serial%27+object+has+no+attribute+%27SerialTimeoutException%27


        On Fri, Jun 27, 2014 at 8:58 AM, John McClaire
        <[email protected] <mailto:[email protected]>> wrote:

            Hey guys,

            I'm looking for some help with an error I'm getting. I
            think it's just a syntax sorta thing.

            Here's my python code:

            *import* serial

            *import*time

            *from* subprocess *import* call


            ser = serial.Serial( *"/dev/ttyACM0"* , 9600 )


            *while*1:

            *try*:

              ard = ser.readline()

            *if*(*'smile'* *in* ard):

            *print**'Smiling'*

               call([*"bin/video_player.py -s 80x32 -l bin/smile.mp4"*])


            *elif*(*'laugh'* *in* ard):

            *print**'Laughing'*

               call([*"bin/video_player.py -s 80x32 -l bin/laugh.mp4"*])


            *elif*(*'wink'* *in* ard):

            *print**'Winking'*

               call([*"bin/video_player.py -s 80x32 -l bin/wink.mp4"*])


              time.sleep(1)

            *except* ser.SerialTimeoutException:

            *print*(*'Data could not be read'*)

              time.sleep(1)

            
---------------------------------------------------------------------------------------------------

            And here's the error I'm receiving (happens because when I
            try to call a subprocess):

              File "commands.py", line 23, in <module>

                except ser.SerialTimeoutException:

            AttributeError: 'Serial' object has no attribute
            'SerialTimeoutException'

            
---------------------------------------------------------------------------------------------------

            Thanks for the help!

            - John

-- For more options, visit http://beagleboard.org/discuss
            ---
            You received this message because you are subscribed to
            the Google Groups "BeagleBoard" group.
            To unsubscribe from this group and stop receiving emails
            from it, send an email to
            [email protected]
            <mailto:[email protected]>.
            For more options, visit https://groups.google.com/d/optout.


-- For more options, visit http://beagleboard.org/discuss
        ---
        You received this message because you are subscribed to a
        topic in the Google Groups "BeagleBoard" group.
        To unsubscribe from this topic, visit
        https://groups.google.com/d/topic/beagleboard/B1qWMFAdcsQ/unsubscribe.
        To unsubscribe from this group and all its topics, send an
        email to [email protected]
        <mailto:[email protected]>.
        For more options, visit https://groups.google.com/d/optout.




-- *John McClaire | Creative Technologist * -- For more options, visit http://beagleboard.org/discuss
    ---
    You received this message because you are subscribed to the Google
    Groups "BeagleBoard" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:[email protected]>.
    For more options, visit https://groups.google.com/d/optout.


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
For more options, visit http://beagleboard.org/discuss
--- You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to