×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    ImportError: No module named _appuifw

    Hello,
    I was playing with both mod_python and PSP and I found that every script I make (.py or .psp) which tries to use the appuifw module fails returning the following error:

    "ImportError: No module named _appuifw"

    I even tried to write a very small script which first import all the modules described in the Python for S60 documentation and then just takes a picture via the camera.take_photo function: it works as long as I add to the import list the appuifw module, then it gives me:

    Code:
    Mod_python error: "PythonHandler mod_python.psp"
    
    Traceback (most recent call last):
    
      File "E:\system\libs\mod_python\apache.py", line 303, in HandlerDispatch
        result = object(req)
    
      File "E:\system\libs\mod_python\psp.py", line 331, in handler
        p.run()
    
      File "E:\system\libs\mod_python\psp.py", line 237, in run
        exec code in global_scope
    
      File "E:/data/apache/mod_python/psp/ciccia.psp", line 2, in ?
        import appuifw
    
      File "E:\system\libs\appuifw.py", line 14, in ?
        import _appuifw
    
    ImportError: No module named _appuifw
    BTW the test script goes like:

    Code:
    <%
    import appuifw
    import camera
    import audio
    import graphics
    import messaging
    import calendar
    import contacts
    import e32
    import e32db
    import e32dbm
    import inbox
    import keycapture
    import socket
    import sysinfo
    import telephone
    import thread
    import topwindow
    import location
    image = camera.take_photo(size = (160,120))
    filename=u'e:\\camera.jpg'
    image.save(filename)
    %>
    Are there some issues with appuifw module and mod_python/PSP?

    Thanks,
    Ernesto Ferrari

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Re: ImportError: No module named _appuifw

    BTW, I'm running raccoon_2ndEdFP2_0.8.0 on a Nokia 6630.

  3. #3
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: ImportError: No module named _appuifw

    Hi,

    At the moment using appuifw in an embedded PyS60 interpreter is not supported. I don't know if and when that will change.

    However, it's not that big a limitation as one initially might think. Namely, invoking UI stuff, especially of the kind that require user interaction, from a request handler is conceptually not that simple. An HTTP request handler is supposed to execute quickly and anything involving a user can potentially take an unbounded amount of time to finish.

    For instance, the instant message concept demo (implemented as a native Apache module) uses a secondary thread for displaying the messages so that the request handler can return immediately. The take picture demo does use the request handler thread for taking the picture, but there's a pretty short timeout so that the request handler thread will not hang, in case the phone owner does not notice the request. So, in general, interacting with the phone owner directly from within a request handler is not that useful.

    A better approach - if direct user interaction is wanted - is to have a separate application that a request handler communicates with. In the PyS60 context that would mean having a Python application (which then can use appuifw) that the request handler contacts. That way request handlers can execute quickly and there are no limitations on what UI stuff you can do.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Re: ImportError: No module named _appuifw

    Quote Originally Posted by jhnwkmn
    Hi,
    The take picture demo does use the request handler thread for taking the picture, but there's a pretty short timeout so that the request handler thread will not hang, in case the phone owner does not notice the request.
    Is this also the reason why the user doesn't actually see the camera "viewfinder" when taking the picture via the take picture demo as he would normally do when using the OS camera application?

    Quote Originally Posted by jhnwkmn
    A better approach - if direct user interaction is wanted - is to have a separate application that a request handler communicates with. In the PyS60 context that would mean having a Python application (which then can use appuifw) that the request handler contacts.
    What do you exactly mean by "contacts"?

    Thanks,
    Ernesto Ferrari

  5. #5
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: ImportError: No module named _appuifw

    Quote Originally Posted by ernesto.ferrari
    Is this also the reason why the user doesn't actually see the camera "viewfinder" when taking the picture via the take picture demo as he would normally do when using the OS camera application?
    Not really. The primary reason is that the camera demo simply uses the camera API directly without adding anything that one would take for granted in a "real" product. But it would be somewhat challenging technically as well. The environment when running as a server (as Apache httpd does) is not the same as when one is running as a normal GUI application and that would then have to be dealt with.

    What do you exactly mean by "contacts"?
    Communicates with in one way or another. For instance, to pass a "command" or something from the request handler to the GUI application for execution.

  6. #6
    Registered User
    Join Date
    Mar 2008
    Posts
    47

    Re: ImportError: No module named _appuifw

    Hi,

    A better approach - if direct user interaction is wanted - is to have a separate application that a request handler communicates with. In the PyS60 context that would mean having a Python application (which then can use appuifw) that the request handler contacts. That way request handlers can execute quickly and there are no limitations on what UI stuff you can do.
    Any change anyone has a sample code showing how to let the request handler contact / execute a second python script that can do appuifw calls?

    I have been testing something like
    Code:
    execfile('E:\\Python\\appuidemo.py')
    Which dose not work, returns the same import error (the script being executed in the same context)

    and also

    Code:
    e32.start_exe('python.exe','E:\\Python\\appuidemo.py');
    Which also doesn't work, just fires up the python shell program on my phone, guess python.exe is the shell executable but not the python interpreter.

    regards,
    Magnus

  7. #7
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: ImportError: No module named _appuifw

    Quote Originally Posted by maggias View Post
    ...
    Code:
    e32.start_exe('python.exe','E:\\Python\\appuidemo.py');
    Which also doesn't work, just fires up the python shell program on my phone, guess python.exe is the shell executable but not the python interpreter.
    It appears that currently you need to make the script you intend to run into a standalone Python application, that is, make it into an exe that can have capabilities if its own.

    I suppose you should be able to make that exe-fied script general purpose so that it in turn then can execute any other Python script.

    Johan

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    47

    Re: ImportError: No module named _appuifw

    Hi,

    Thanks for the reply.

    I created a very simple demo script, appuidemo.py

    Code:
    import appuifw
    
    appuifw.note(u"Dispaly a message ","info")
    and made it into a .sis with Ensymble
    Code:
    ensymble.py py2sis appuidemo.py appuidemo.sis
    And then installed it on the memory card in the N95 that I have, everything works and I see the application in the Applications menu and can open it from there.

    However when I try to execute it from another python script with
    Code:
    import e32
    
    e32.start_exe(u'e:\\resource\\apps\\appuidemo.exe','')
    I get
    SymbianError: [Error -1]
    KErrNotFound

    Am I not right that creating a sis install packet for 3rd edition devices also creates a .exe? How can I find the location of programs installed?

    best regards,
    Magnus

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    47

    Re: ImportError: No module named _appuifw

    I found the solution to my problem.

    When I create the .sis packet with ensymble the UID is put between the application name and the .exe ending.

    For example
    C:\Ensymble>ensymble.py py2sis appuidemo.py appuidemo.sis
    ensymble.py: warning: no application version given, using 1.0.0
    ensymble.py: warning: no UID given, using auto-generated test UID 0xe8f72d57
    ensymble.py: warning: no certificate given, using insecure built-in one

    then the executeable on my phone after installing will be in
    c:\sys\bin\appuidemo_0xe8f72d57.exe

    and e32.start_exe(u'c:\\sys\\bin\\appuidemo_0xe8f72d57.exe','') works.

    I unfortunately wasn't aware of the UID being appended to the application name when packing, newbie mistake probably.

    I have created a generic application to handle this kind of request that can be easily extended. The solution is available here: http://maggi.bablish.com/?p=1

  10. #10
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: ImportError: No module named _appuifw

    Quote Originally Posted by maggias View Post
    I found the solution to my problem.
    Thanks for sorting this one out!

    Johan

Similar Threads

  1. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43
  2. Replies: 2
    Last Post: 2006-10-25, 18:04
  3. No module named inbox
    By nibss in forum Symbian
    Replies: 1
    Last Post: 2006-05-31, 00:14
  4. No module named messeging
    By bintelnoor in forum Symbian
    Replies: 7
    Last Post: 2006-05-20, 00:55
  5. SMS I/O Control Application via Evaluation Module
    By alokghosh in forum Nokia M2M
    Replies: 2
    Last Post: 2003-06-18, 17:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×