autostarting idle to run a python script

A forum for general discussion of the Python programming language.

autostarting idle to run a python script

Postby katesfb » Mon Feb 11, 2013 9:42 pm

Hi,
i have been using IDLE to write python scripts and have an application that requires auto-starting IDLE and then automatically running a script. Apparently i can use the command line option:

idle -s myfile.py

to do this. This opens the script for editing and opens the python idle shell but does not run the script. I also understand that i can use the idle environment variable $IDLESTARTUP to do the same thing however i have no idea how to do this.

Does anybody know what is the best option is and how to correctly do it.

Any help is much appreciated.

Cheers.
katesfb
 
Posts: 3
Joined: Mon Feb 11, 2013 9:32 pm

Re: autostarting idle to run a python script

Postby metulburr » Mon Feb 11, 2013 9:47 pm

Are you just trying to run a python script?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1312
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: autostarting idle to run a python script

Postby Mekire » Tue Feb 12, 2013 12:59 am

You can do this with:
Code: Select all
idle -r myfile.py
This will open an idle console window and immediately run your script; it won't however open your script for editing. This should both run it and open it for editing but... it doesn't.
Code: Select all
idle -e -r myfile.py
Go figure.
As Metul was alluding to however, there is no circumstance ever that I can think of that would require you to do this. IDLE is just an IDE, and a fairly bad one at that. What possible reason would your program "require" you to run it this way?
User avatar
Mekire
 
Posts: 982
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: autostarting idle to run a python script

Postby katesfb » Tue Feb 12, 2013 10:00 am

Hi,
Thanks for the reply. I'll give that a try.

The reason is that i have a python script set up as a logger, running on the raspberry pi mini computer. The pi is running headless and is in a remote location such that it needs the ability to be able to be started and begin logging without having a user with a laptop to actually set it up. So, the IDLE command will go inside a bash script that gets executed after the desktop has loaded on the pi.

Thanks for your help.

Cheers.
katesfb
 
Posts: 3
Joined: Mon Feb 11, 2013 9:32 pm

Re: autostarting idle to run a python script

Postby stranac » Tue Feb 12, 2013 11:20 am

You don't have to execute a python script with IDLE.
It is actually recommended not to do so.

You should just run your script with python:
Code: Select all
python my_script.py
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Re: autostarting idle to run a python script

Postby katesfb » Wed Feb 13, 2013 9:36 am

Hi,
And thanks for the replies.

Have decided to go with command line python to execute the script however this was mainly becos i actually noticed that the command
Code: Select all
idle -r myfile.py

does not work on my LXDE laptop (linux mint ) or on the raspberry pi (also LXDE - wheezy raspian) but does work on my desktop (linux gnome cinnamon) - would there be any reason for the -r option not working on the LXDE systems. I also noticed that the IDLE on my laptop seems to default to "no subprocess" but i thought you had to use the -n option to get this.

Any help is much appreciated.

Cheers.
katesfb
 
Posts: 3
Joined: Mon Feb 11, 2013 9:32 pm

Re: autostarting idle to run a python script

Postby stranac » Wed Feb 13, 2013 11:28 am

IDLE is not a part of python.
It does sometimes come packaged with it, but that depends on how python was installed.
That's why it's not always available.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Re: autostarting idle to run a python script

Postby metulburr » Wed Feb 13, 2013 10:10 pm

I think you are confused between the difference of IDLE and Python, and executing python, read Executing Python
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1312
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests