×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    56

    script isnt closing

    hey

    I made a scritp in python and made default.py which only does:
    Code:
    import appuifw
    import myscript
    myscript.main()
    appuifw.app.set_exit()
    in myscript.main() there is ocurse the code:
    Code:
    ...main stuff...
    applock = e32.Ao_lock()
    applock.wait()
    appuifw.app.exit_key_handler = exit_key_handler
    
    def exit_key_handler():
        applock.signal()
        appuifw.app.exit_key_handler = None


    the script runs fine and when i exit i dont see it anymore in the
    task list (by pressing menu for 3 seconds)
    but like when i recreate the sis package with ensymble and install it , the phone says the program is running and needs to be closed, i choose ok and it installs.

    but what is wrong ? why the phone says it needs to closed ?
    it should be closed.

    thanks,
    roi

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: script isnt closing

    Quote Originally Posted by roidayan View Post
    hey

    I made a scritp in python and made default.py which only does:
    Code:
    import appuifw
    import myscript
    myscript.main()
    appuifw.app.set_exit()
    in myscript.main() there is ocurse the code:
    Code:
    ...main stuff...
    applock = e32.Ao_lock()
    applock.wait()
    appuifw.app.exit_key_handler = exit_key_handler
    
    def exit_key_handler():
        applock.signal()
        appuifw.app.exit_key_handler = None


    the script runs fine and when i exit i dont see it anymore in the
    task list (by pressing menu for 3 seconds)
    but like when i recreate the sis package with ensymble and install it , the phone says the program is running and needs to be closed, i choose ok and it installs.

    but what is wrong ? why the phone says it needs to closed ?
    it should be closed.

    thanks,
    roi
    That is strange indeed. My theory is that the phone still sees the program as "open" because, from the code you posted here, e32.Ao_lock() is never signaled (unless you press the right soft key).

    Try this:
    Code:
    import appuifw, e32
    import myscript
    myscript.main()
    applock=e32.Ao_lock()
    applock.signal()
    appuifw.app.set_exit()
    Again, I'm not sure about the mechanisms of this problem so I apologize if this doesn't help.

  3. #3
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    56

    Re: script isnt closing

    hey thx for the answer but i checked again and everything works
    ,, maybe it was a problem i had while writing the code and testing but it seems now.

    or maybe i think its happening if error occur and i call my harness() function, then signal is being called.

    like i do
    Code:
    try:
       something()
    except:
       harness()
    my harness didnt signal applock, i now did applock as global None
    and harness will check if its setted and signal it.

    Code:
    def harness():
        global applock
        import sys
        import traceback
        import e32
        import appuifw
        if applock!=None:
            applock.signal()
        appuifw.app.screen='normal'
        appuifw.app.focus=None
        appuifw.app.title=u'Error occured'
        body=appuifw.app.body=appuifw.Text()
        def tab(idx):
            if idx==0:
                appuifw.app.body=body;
            elif idx==1:
                appuifw.app.body=txtLog;
        appuifw.app.set_tabs([u"Error",u"Log"],tab)
        harnesslock=e32.Ao_lock()
        def quit():
            harnesslock.signal()
        appuifw.app.exit_key_handler=quit
        appuifw.app.menu=[(u'Exit', quit)]
        body.set(unicode('\n'.join(traceback.format_exception(*sys.exc_info()))))
        harnesslock.wait()
        appuifw.app.set_exit()
    i'll check it now.

    --edit--
    It works now after added applock.signal() in harness()
    Last edited by roidayan; 2008-04-19 at 10:31.

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: script isnt closing

    Quote Originally Posted by roidayan View Post
    Code:
    ...main stuff...
    applock = e32.Ao_lock()
    applock.wait()
    appuifw.app.exit_key_handler = exit_key_handler
    There's possible error in code: you should define exit_key_handler before you stop script execution to wait. Not sure what default exit_key_handler would do, but if you want to define your own then do it BEFORE applock.wait(). Your current problem might be caused by defining it when you're about to exit.

    Code:
    appuifw.app.exit_key_handler = exit_key_handler
    applock = e32.Ao_lock()
    applock.wait()
    Hope it helps,

    --jouni

  5. #5
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: script isnt closing

    Jouni is right!
    The appuifw.app.exit_key_handler should be referrenced to the exit_key_handler before applock = e32.Ao_lock().
    I guess it works fine for you now.
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  6. #6
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    56

    Re: script isnt closing

    yea thx guys, i already fixed it.
    i guess the wait line was just a typo of place.
    the problem was that when i had script error and called harness()
    i had a new lock and after it i closed the app without sending signal to the main app lock.

Similar Threads

  1. Replies: 6
    Last Post: 2007-04-24, 21:36
  2. script working,but standalone doesn't
    By bugb in forum Symbian
    Replies: 2
    Last Post: 2007-03-12, 14:14
  3. Install a script as a standalone app !
    By cyke64 in forum Symbian
    Replies: 5
    Last Post: 2006-07-18, 02:24
  4. write perl/python script in your S60 phone
    By kamijawa in forum Symbian
    Replies: 5
    Last Post: 2006-06-03, 15:59
  5. Error when closing multiview applications?
    By ttheoria in forum Symbian
    Replies: 2
    Last Post: 2005-02-18, 18:26

Posting Permissions

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