×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    30

    Arguments for Python executable?

    I'm new to Symbian programming, and actually new to Python, too. My company uses Intellisync Mobile Suite and a variety of wireless devices including some E61i's. I'm trying to find a way to do some housekeeping on the E61i's by means of a Python script. I've spent several hours reading about device security, Ensymble, code signing, etc., and becoming annoyed. All of this doesn't seem to "simplify application development" one bit. But onward...

    Would someone familiar with the S60 3rd Edition Python source code tell me if the Python interpreter (I assume either C:\sys\bin\python_launcher.exe or C:\sys\bin\Python.exe ?) will accept a Python script as a command line argument? Intellisync lets me run any executable in C:\sys, assuming I know the filename, and it would be really helpful if there was a switch I could use to then add the path to the .py file. (I'm guessing it's unfortunately not that simple.)

    All I need to do is a) read and parse a few text files, b) potentially rename a few files in C:\Data, c) potentially write a new text file and delete a text file...and do it without displaying a GUI or requiring user intervention. As far as I know, none of these files are protected by the OS.

    Assuming there is no simple switch to supply a Python file, what is the easiest means to an end, given that I want to run one script on many devices? Could there be an older version of Python that does accept a script on the command line? Would a self-signed script be able to perform the tasks above on multiple devices? I'd appreciate any help. Thanks!

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

    Re: Arguments for Python executable?

    Hi,

    Do you want to run a script from the shell or from a script?

    The latter is possible.
    Use the code below
    Code:
    import appuifw, e32
     
    def quit(): 
      app_lock.signal()
     
    appuifw.app.exit_key_handler=quit
     
    file='C:\\Python\\second.py'
    execfile(file)
     
    app_lock=e32.Ao_lock()
    app_lock.wait()
    This allows you to run the second.py

    You can trim the code and use the approprite line on the interpreter (considering them commands) to run the scrpit.

    Here is the trimmed code

    file='C:\\Python\\second.py'
    execfile(file)
    Kandyfloss

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

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    30

    Re: Arguments for Python executable?

    To avoid making this overcomplicated, I want to simulate the existence of a "recognizer" for .py files...either a way to launch the .py file by the same means Intellisync uses to launch .exe files, or by supplying it as the target of another executable. I suppose that means I want to run it from the shell. Not possible?

    If I launch the script by means of another script, then how would I launch the FIRST script? Sounds a bit like a "chicken and egg" problem.

    I need this to work, but also want to make sure I'm not doing unnecessary work. Thanks for the reply and thanks in advance for helping me sort through this out.

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

    Re: Arguments for Python executable?

    hi kandyfloss,

    Using
    Code:
    file='C:\\Python\\second.py'
    execfile(file)
    How would you pass string arguments to second.py script, is it possible?

    Best regards,
    Magnus

  5. #5
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    57

    Re: Arguments for Python executable?

    Quote Originally Posted by thetao View Post
    Would someone familiar with the S60 3rd Edition Python source code tell me if the Python interpreter (I assume either C:\sys\bin\python_launcher.exe or C:\sys\bin\Python.exe ?) will accept a Python script as a command line argument? Intellisync lets me run any executable in C:\sys, assuming I know the filename, and it would be really helpful if there was a switch I could use to then add the path to the .py file. (I'm guessing it's unfortunately not that simple.)
    Why are You guessing? Why don't You just try? There's no magic switch, just "python.exe your_script.py".

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    30

    Re: Arguments for Python executable?

    I did try and it doesn't work. I decided to ask because I'm new at this and wanted to make sure there wasn't some trick I was missing.

    Does it work for you?

  7. #7
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    57

    Re: Arguments for Python executable?

    Quote Originally Posted by thetao View Post
    I did try and it doesn't work. I decided to ask because I'm new at this and wanted to make sure there wasn't some trick I was missing.

    Does it work for you?
    No, I mean I didn't try, but You didn't say if You tried or not. I had a brief look at the source and it seemed that python_launcher leaves the command line arguments (sys.argv) unchanged. Also when running the python shell, there is sys.argv and its contents is the current running script (default.py). So all the signs on heaven and earth show that it SHOULD work.

    Well if it doesn't, there's one option You could try. Ensymble puts python scripts into their own installers, within them an exe is contained (and installed in sys/bin). I guess it's the launchpad for the script and You can try running that.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    30

    Re: Arguments for Python executable?

    Okay, so I definitely should be using python_launcher.exe and not python.exe. I recall the latter launches the interactive console, which is not what I want. What I'm doing is supplying "C:\sys\bin\python_launcher.exe" as the command and "C:\Python\ball.py" (etc.) as the argument, and nothing happens. I wish there was a debug mode in either Python or the Intellisync client so I could better see what is going on. Might it be possible this is a bad test, and the console brings extra resources to bear, which are not available if I launch the script this way? I could try running a really short, basic script to be absolutely certain it's not doing anything...

    I've been eyeing Ensymble, but wasn't sure I could write a script that runs on multiple devices. For what I want to do (see below), a commercial certificate would not be necessary?

    Thanks again for the help. I could eventually figure this out myself, but didn't want to spent 2 weeks struggling.

  9. #9
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    57

    Re: Arguments for Python executable?

    Quote Originally Posted by thetao View Post
    What I'm doing is supplying "C:\sys\bin\python_launcher.exe" as the command and "C:\Python\ball.py" (etc.) as the argument, and nothing happens.
    The python_launcher is for server scripts so I don't think You'll get much output from it (no gui stuff). Write a script that writes "hello" to a file in some public directory, like:

    Code:
    myfile = "c:\\Data\\myfile.txt"
    
    f=open(myfile,'w')
    f.write("hello")
    f.close()
    ...and see if it created the file.

    I've been eyeing Ensymble, but wasn't sure I could write a script that runs on multiple devices. For what I want to do (see below), a commercial certificate would not be necessary?
    No certificate necessary. The install will run on s60v3 devices. There are similar tools for s60v1/v2 devices, so if you'll need to support them you can just write a batch that makes two install packages out of one python script.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    30

    Re: Arguments for Python executable?

    Okay, so now I know it really doesn't work. Wish I knew why. I'll have a closer look at Ensymble and try to get something working next week. Thanks again for the help.

Similar Threads

  1. Problem reading command line arguments
    By blackcat95! in forum Symbian
    Replies: 4
    Last Post: 2009-05-02, 14:57
  2. PKG File: executing an exe with command line arguments
    By vaibhavjain in forum Symbian Tools & SDKs
    Replies: 8
    Last Post: 2007-09-25, 10:12
  3. Can't find Executable class
    By arachidyl in forum Mobile Java General
    Replies: 1
    Last Post: 2007-07-06, 19:27
  4. Could not browser the source code of imported executable
    By robinhuang in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-06-19, 19:12

Posting Permissions

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