×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Running Scripts From The Application Menu

    Guys

    I have been going-on for some time about running scripts from the main application menu. I have now had an idea. So here goes.

    1) Create a directory under C:\System\Apps (probably use the same name as the file containing the script to install)
    2) Copy the contents of C:\System\Apps\Python to the directory created above leaving-out the .py files
    3) Copy the script you wish to run in the directory created above
    4) Create a default.py file in the directory created above which creates a namespace (as in the default.py in C:\System\Apps\Python) ane executes your script.

    Not sure if the above would work but if it does I can see two issues

    1) The same UID will be used for several apps (Python itself and the installed script(s))
    2) Installed scripts would also be called Python and have the Python icon. Both are in the python.aif file but I have no idea how to edit that!

    I would probably implement this as a function so I can add it to the standart menu in Python itself. This would be a simple modification to the default.py in C:\System\Apps\Python. There might be licensing issues relating to modifying ghe default.py in C:\System\Apps\Python.

    If this works and the licensing of Python allows it then you could even make a SIS installer of this to distribute your script as an app.

    Any comments?

    Regards

    Patrick
    Last edited by patlucas; 2011-04-14 at 10:57.

  2. #2
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Re: Running Scripts From The Application Menu

    I have written a script and tested on the PC. It works fine. On my Nokia N70, it does not like the following line.

    shutil.copytree('C:\\System\\Apps\\Python', d)

    The actual error is "AttributeError: 'module' object has no attribute 'copytree'".

    My default.py has a line that says "import shutil" at the top and Python did start correctly so I assume that the "shutil" module exists.
    Is it that the copytree function does not exist on PyS60? What can I use instead?

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

    Re: Running Scripts From The Application Menu

    If you use dir(shutil) you will see what functions there are in it. copytree is not among them (not in PyS60 1.4.5 anyway; it's there in 2.0, but that won't work on the N70).

    Maybe you can write your own function that copies files and directories.

  4. #4
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Re: Running Scripts From The Application Menu

    Thanks. I did write my script differently and now I get a Symbian error when using e32.file_copy (see below). Any ideas why?

    Here is an extract of my script so you can see what it is doing.

    n = os.path.splitext(s)[0].lower()
    a = n.split('\\')
    n = a[len(a) - 1].capitalize()
    d = 'C:\\System\\Apps\\' + n
    if not os.path.exists(d): os.mkdir(d)
    e32.file_copy('C:\\System\\Apps\\Python\\Python.app', d)

    's' is a fully qualified file name such as "C:\System\Apps\Python\ball.py"

    And now for the error as reported on my N70

    e32.file_copy('C:\\System\\Apps\\Python\\Python.app', d)
    SymbianError: (Errno -1) KErrNotFound

    I know that both source and destination exist in the above copy so what could be wrong?

    Many thanks

    Patrick

Similar Threads

  1. Running Scripts
    By patlucas in forum Symbian
    Replies: 1
    Last Post: 2010-07-15, 15:44
  2. Running Scripts
    By patlucas in forum Symbian
    Replies: 2
    Last Post: 2009-11-16, 12:18
  3. Replies: 8
    Last Post: 2009-09-15, 10:51
  4. Replies: 6
    Last Post: 2009-01-10, 09:40
  5. Replies: 5
    Last Post: 2007-11-14, 21:06

Posting Permissions

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