You Are Here:

Community: Developer Discussion Boards

#1 Old Arguments for Python executable? - 2008-04-03, 03:56

Join Date: Apr 2008
Posts: 17
thetao
Offline
Registered User
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!
Reply With Quote

#2 Old Re: Arguments for Python executable? - 2008-04-03, 05:27

Join Date: Dec 2007
Posts: 134
Location: India
kandyfloss's Avatar
kandyfloss
Offline
Regular Contributor
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

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


Kandyfloss

V 7.0642.0
18-10-06
RH-51
Nokia 7610
Reply With Quote

#3 Old Re: Arguments for Python executable? - 2008-04-03, 15:58

Join Date: Apr 2008
Posts: 17
thetao
Offline
Registered User
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.
Reply With Quote

#4 Old Re: Arguments for Python executable? - 2008-04-04, 09:40

Join Date: Mar 2008
Posts: 47
maggias
Offline
Registered User
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
Reply With Quote

#5 Old Re: Arguments for Python executable? - 2008-04-04, 10:35

Join Date: Mar 2008
Posts: 57
nokia_e70
Offline
Regular Contributor
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".
Reply With Quote

#6 Old Re: Arguments for Python executable? - 2008-04-04, 16:58

Join Date: Apr 2008
Posts: 17
thetao
Offline
Registered User
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?
Reply With Quote

#7 Old Re: Arguments for Python executable? - 2008-04-04, 17:30

Join Date: Mar 2008
Posts: 57
nokia_e70
Offline
Regular Contributor
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.
Reply With Quote

#8 Old Re: Arguments for Python executable? - 2008-04-04, 18:59

Join Date: Apr 2008
Posts: 17
thetao
Offline
Registered User
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.
Reply With Quote

#9 Old Re: Arguments for Python executable? - 2008-04-04, 21:03

Join Date: Mar 2008
Posts: 57
nokia_e70
Offline
Regular Contributor
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.

Quote:
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.
Reply With Quote

#10 Old Re: Arguments for Python executable? - 2008-04-04, 21:41

Join Date: Apr 2008
Posts: 17
thetao
Offline
Registered User
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.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem reading command line arguments blackcat95! General Symbian C++ 4 2009-05-02 15:57
再问关于symbian编译汇编 cloufei2007 Symbian 0 2008-02-03 11:05
PKG File: executing an exe with command line arguments vaibhavjain Symbian Tools & SDKs 8 2007-09-25 11:12
Can't find Executable class arachidyl Mobile Java General 1 2007-07-06 20:27
Could not browser the source code of imported executable robinhuang Carbide.c++ IDE and plug-ins 0 2007-06-19 20:12

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia