×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Python application aborts

    Hi!

    I've been trying to develop an app for quite a bit, and have finally reached a stage where it seems to be getting done. My script is called pycode.py.

    So far, I have always been using siscontents to create my app. When I am creating the application, I install the script in the location "c:\\Python\\pycode.py", and run the application by going through the following path :
    Menu --> Application --> Python --> Options --> Run App --> pycode.py
    The application works completely fine!

    I tried to create the same file using ensymble (to create a sort of stand-alone application). I used the following command to create the sis :
    python c:\sisinfo\ensymble.py py2sis --uid=0xE4211998 --appname=Demo --version=1.0.0 --lang=EN --icon=icon.svg --shortcaption="Demo App" --caption="Demo Application" --drive=C --textfile=info.txt --caps=ReadUserData+LocalServices+Location+NetworkServices+UserEnvironment+WriteUserData+ReadDeviceData+WriteDeviceData --vendor="kedarm" --verbose pycode.py app_30th_jan.sis
    However, when I run the app, the application aborts half-way into the application.

    Is there any way to debug the problem and find out what exactly is causing the program to abort suddenly?
    Have I got the capabilities wrong, or have I missed out something there?

    The app has the following flow :
    1) Call camera application (stand alone application is called using e32.start_exe(uid))
    a) Take image
    b) Store image at specific location
    2) Process image
    a) Run some pre-defined algorithms
    3) Display output
    The app seems to fail at step 2.
    During the step 2, I tend to create lots of temporary files. Could this be causing a problem?

    Thanks
    Kedar

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Python application aborts

    Quote Originally Posted by kedarm View Post
    Hi!

    I've been trying to develop an app for quite a bit, and have finally reached a stage where it seems to be getting done. My script is called pycode.py.

    So far, I have always been using siscontents to create my app. When I am creating the application, I install the script in the location "c:\\Python\\pycode.py", and run the application by going through the following path :
    Menu --> Application --> Python --> Options --> Run App --> pycode.py
    The application works completely fine!

    I tried to create the same file using ensymble (to create a sort of stand-alone application). I used the following command to create the sis :

    However, when I run the app, the application aborts half-way into the application.

    Is there any way to debug the problem and find out what exactly is causing the program to abort suddenly?
    Have I got the capabilities wrong, or have I missed out something there?

    The app has the following flow :
    1) Call camera application (stand alone application is called using e32.start_exe(uid))
    a) Take image
    b) Store image at specific location
    2) Process image
    a) Run some pre-defined algorithms
    3) Display output
    The app seems to fail at step 2.
    During the step 2, I tend to create lots of temporary files. Could this be causing a problem?

    Thanks
    Kedar
    hello kedar

    make sure your app and the Python runtime are in same drive.

    apart from that you can go through this article which will help you in debugging your application.

    Hope this helps,

  3. #3
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    I have installed Python runtime in C. When I created my app, I gave the --drive=C option in ensymble.
    While developing the app, I am not using a memory card. Hence, there is no drive E (etc) available to install.


    I tried the method (first one) and I figured out the line where things seem to be falling apart!
    As described in my initial post, during the image processing stage, I run an operator on an image and create a new image. The program seems to be aborting when I try and save this image. The precise line is :
    Code:
    img.save("D:\\temp_img.jpg",quality=100,bpp=1,compression="no")
    Is the problem with the capabilities I have set, that do not allow me to write to D drive? Or is it an issue with the signing (I use the Symbian Signed facility to sign my applications)

    The capabilities I have set are : ReadUserData+LocalServices+Location+NetworkServices+UserEnvironment+WriteUserData+ReadDeviceData+WriteDeviceData
    (first post has the entire command to create the sis file)

    Thanks
    Kedar

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Python application aborts

    hello kedar again

    why are you using D:\\ to save your temp image, i am not sure but D:\\ is only a read only directory. Or you might not have sufficient permissions to get access to that directory try saving the temp images somewhere else and see if that works for you or not.

    Regards,

  5. #5
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Quote Originally Posted by gaba88 View Post
    hello kedar again


    Quote Originally Posted by gaba88 View Post
    why are you using D:\\ to save your temp image, i am not sure but D:\\ is only a read only directory. Or you might not have sufficient permissions to get access to that directory try saving the temp images somewhere else and see if that works for you or not.
    I understand that D is a temporary directory, but I need the code to write the image to that specific location itself. I am using some other libraries (modules) that require the image to be at that specific location.

    I don't think it's an issue with capabilities (as said by me in earlier post), because the capabilities are identical to various other applications that freely read/write from D drive.

    When I install the python script at the location : 'c:\Python', and run it as a script, it works fine. There seem to be no problems with permissions. Is it because the Python Script Shell or Python for S60 has the required permissions?
    If it's an issue with permissions (as suggested by you), is there any way to get the required permissions? Do we need to buy them from Nokia or something?

    Thanks
    Kedar

  6. #6
    Registered User
    Join Date
    Sep 2003
    Posts
    77

    Re: Python application aborts

    Perhaps the memory allocated to your application is to small (1 MB default with 1.4.5 ensymble version). Assuming that the (uncompressed) image files are large. Have a look at the ensymble '--heapsize' option.

    Just a guess...

    Martin

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Python application aborts

    Quote Originally Posted by kedarm View Post

    When I install the python script at the location : 'c:\Python', and run it as a script, it works fine. There seem to be no problems with permissions. Is it because the Python Script Shell or Python for S60 has the required permissions?
    Ya might be your Python Shell has all the required capabilities and when you make your sis it doesnt have all that require capabilities.

    What i suggest is go through the capabilities section at the wiki and see if using D:\\ requires something other than symbiansign or your dev cert has.

    May that would take to some solution.

    Regards,

  8. #8
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Quote Originally Posted by gaba88 View Post
    Ya might be your Python Shell has all the required capabilities and when you make your sis it doesnt have all that require capabilities.
    I checked the capabilities of the ScriptShell. It is a subset of the capabilities that I have given to my code. Are there some additional features somewhere that I am unaware of?

    Quote Originally Posted by gaba88 View Post
    What i suggest is go through the capabilities section at the wiki and see if using D:\\ requires something other than symbiansign or your dev cert has.
    Well, it gets a little strange. I took the camera example (from the wiki/tuts section) and changed the save path to D:\\photo.jpg (instead of C:\\photo.jpg) and it works totally fine.
    I have used the same capabilities as the app I have made!



    Kedar

    Here is the code (from here):
    import appuifw, e32, camera

    app_lock = e32.Ao_lock()
    #Define the exit function
    def quit():
    #Close the viewfinder
    camera.stop_finder()
    #Release the camera so that other programs can use it
    camera.release()
    app_lock.signal()
    appuifw.app.exit_key_handler = quit

    #Function for displaying the viewfinder
    def vf(im):
    appuifw.app.body.blit(im)

    #Function for taking the picture
    def take_picture():
    #Take the photo
    photo = camera.take_photo('RGB', (1024, 768))
    #Save it at maximum quality
    photo.save(photo_savepath, quality = 100)
    #Restart the viewfinder
    camera.stop_finder()
    camera.start_finder(vf)

    photo_savepath = u"d:\\photo.jpg"
    #This is the path and name for storing the photo

    #Set the application's body to Canvas
    appuifw.app.body = appuifw.Canvas()

    #Start the viewfinder
    camera.start_finder(vf)

    #Set the application's menu with the option to take the photo
    appuifw.app.menu=[(u"Take photo", take_picture)]

    #Wait for the user to request the exit
    app_lock.wait()

  9. #9
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Hi!

    I have been trying to debug the code to the best of my abilities, but I have not been able to figure things out. The problem seems to be occurring at the step where I save the image to D drive. The precise line is :
    Code:
    img.save(u"D:\\temp_img.jpg",quality=100,bpp=1,compression="no")
    The action itself (saving) is performed, but the program aborts as soon as it is done. If I comment out the line, the whole program runs fine.

    I have tried to save images to D drive with other codes, and it has always worked fine. So, I am safely assuming that it works. But why it fails here is still quite a mystery

    Anyone has any clues?

    Could I use some sort of try-except handling here, to figure out the error? I tried the options given in the link sent by gaba88, but it didn't help.
    What is the exact error (something like OSError?) that the exception would catch?

    Thanks
    Kedar

  10. #10
    Registered User
    Join Date
    Sep 2003
    Posts
    77

    Re: Python application aborts

    Did you monitor memory consumption? You can do this 'live' with Nokia Energy Profiler.
    Have you increased the memory that can be allocated with the ensymble option --heapsize?

  11. #11
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Hi Dehlerm,

    Quote Originally Posted by dehlerm View Post
    Did you monitor memory consumption? You can do this 'live' with Nokia Energy Profiler.
    Thanks a lot. To be honest, I had not monitored the memory. Maybe, it is the memory consumption of the D drive that is causing the problem. Could you elaborate a little more on how I could use the Energy Profiler option?
    A doubt : Is the D drive the RAM of the phone?

    Quote Originally Posted by dehlerm View Post
    Have you increased the memory that can be allocated with the ensymble option --heapsize?
    I will try using the --heapsize option. Any idea what the default amount of memory assigned to an application?

    Thanks
    Kedar

  12. #12
    Registered User
    Join Date
    Sep 2003
    Posts
    77

    Re: Python application aborts

    Quote Originally Posted by kedarm View Post
    Could you elaborate a little more on how I could use the Energy Profiler option?
    A doubt: Is the D drive the RAM of the phone?
    Nokia Energy Profiler is a application provided by Nokia that e.g. can monitor processor load, memory consumption,...
    Download e.g. from Ovi store: http://store.ovi.com/content/17374
    When installed you can run Energy Profiler, start monitoring, run your application, stop monitoring and then review the resources your application did consume as graph or statistics (nice box plots and histograms) or export the data for further analyses.

    Quote Originally Posted by kedarm View Post
    I will try using the --heapsize option. Any idea what the default amount of memory assigned to an application?
    In Python 1.4.5 it's 1MB by default. Not sure about ensymble distributed with 1.9.x. Just give it a try. I sometimes had the problem that an app crashed without a KErrNoMemory error (when run as SIS, not via script shell) and increasing the heapsize was the solution. Although I'm not sure if it's the same problem that you encounter, just sounded similar.

  13. #13
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Hi!

    Quote Originally Posted by dehlerm View Post
    Nokia Energy Profiler is a application provided by Nokia that e.g. can monitor processor load, memory consumption,...
    Download e.g. from Ovi store: http://store.ovi.com/content/17374
    When installed you can run Energy Profiler, start monitoring, run your application, stop monitoring and then review the resources your application did consume as graph or statistics (nice box plots and histograms) or export the data for further analyses.
    I am using the N73 (Maintenance Release) and hence I cannot use the Energy Profiler. If there is any other way to keep track of memory consumption, please let me know.

    Your description of the symptoms match mine exactly! When I run the script in the shell, it works fine. But, when I run it as a stand-alone app, it crashes, without giving any error (try/except etc do not work).

    I found a similar discussion here.

    I tried the following with ensymble v 0.28 (am using Python 1.4.5):

    Ensymble command and options -
    Code:
    D:\data_matrix\final_symbian_app\app_30th_jan>python c:\sisinfo\ensymble.py py2sis --uid=0xE4211998 --appname=Demo --version=2.0.3 --lang=EN --icon=cameraapp_icon.svg --shortcaption="Demo App" --caption="Demo Application" --drive=C --textfile=info.txt --caps=ReadUserData+LocalServices+Location+NetworkServices+UserEnvironment+WriteUserData+ReadDeviceData+WriteDeviceData --vendor="kedarm" --heapsize=16M --verbose pycode.py app_30th_jan_2_0_3.sis
    I chose "--heapsize=16M", hoping to choose the maximum permissible amount, but now the application doesn't even start!
    According to the documentation -
    The heap minimum value determines if a program is allowed to start. If
    less than the set amount of memory is available, program start-up fails.
    I am using a N73. What is the maximum heapsize I can allocate to my application?

    Thanks!
    Kedar

    Update 1 : I tried the same with --heapsize=1M, --heapsize=12M and --heapsize=8M. This time, the program aborts even faster! Will using Python 1.9.x help things?
    Doubt: Why doesn't --heapsize=max work?
    For the testing phase, I would like to assign the maximum possible heapsize for the application.

    Update 2: As per this page, the N73 has "unlimited heapsize". Does that mean I can assign as much heapsize as I want?
    Last edited by kedarm; 2010-02-03 at 08:57.

  14. #14
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Python application aborts

    kedarm,

    You could try to log instead try/catch. See this article.

    Doubt: Why doesn't --heapsize=max work?
    As a note, I can say that it works for me.

    Marcelo

  15. #15
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    285

    Re: Python application aborts

    Quote Originally Posted by marcelobarrosalmeida View Post
    You could try to log instead try/catch. See this article.
    Thanks. Will definitely try that option and get back..

    Quote Originally Posted by marcelobarrosalmeida View Post
    As a note, I can say that it works for me.
    I get the error (when trying --heapsize=max):
    ensymble.py: max: invalid heap size, one or two values expected
    It looks like max has not been defined (at least in the ensmymble I am using). Could you tell me the version of ensymble and python you are using, so that I can download the same and try?

    Thanks
    Kedar

Similar Threads

  1. Python for S60 1.9.1 released
    By tvijayan in forum Symbian
    Replies: 30
    Last Post: 2009-02-26, 06:16
  2. Python for S60.Read it once
    By jalpesh_patel17 in forum Symbian
    Replies: 0
    Last Post: 2008-09-08, 05:45
  3. Replies: 6
    Last Post: 2008-05-15, 19:23
  4. Replies: 2
    Last Post: 2008-05-03, 22:03
  5. Replies: 3
    Last Post: 2007-03-13, 21:13

Posting Permissions

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