Re: Excute script only from another file

2013-11-26 Thread Chris Angelico
On Wed, Nov 27, 2013 at 12:56 PM, Rick Johnson wrote: > Most people are unaware that life *even* exists beyond the > "point and click". Heck, If you opened a command prompt in > front of them, they'd run and hide in a closet for the next > three hours consumed with fear. They'd probably convince >

Re: Excute script only from another file

2013-11-26 Thread Rick Johnson
On Tuesday, November 26, 2013 5:09:13 PM UTC-6, Chris Angelico wrote: > My point was that Rick had made the assumption that the GUI was > *everything* and that users were able to do nothing beyond > double-clicking on icons For some people the GUI *is* everything. Most people are unaware that li

Re: Excute script only from another file

2013-11-26 Thread Chris Angelico
On Wed, Nov 27, 2013 at 4:25 AM, Dennis Lee Bieber wrote: > On Tue, 26 Nov 2013 13:41:07 +1100, Chris Angelico > declaimed the following: > >> >>Totally sure-fire. Absolutely prevents any execution until it's >>renamed. By the way, what does "associate" mean, and what does it have >>to do with fi

Re: Excute script only from another file

2013-11-26 Thread Larry Hudson
On 11/24/2013 07:20 PM, Dave Angel wrote: Are you really trying to protect against yourself accidentally invoking it or someone maliciously doing it? I would probably give scrpt2 an obnoxious name like htrerttcdrrthyyh.py or put it in an obscure directory. But if you explain the rationale we m

Re: Excute script only from another file

2013-11-25 Thread Rick Johnson
On Monday, November 25, 2013 8:41:07 PM UTC-6, Chris Angelico wrote: > Totally sure-fire. Absolutely prevents any execution until it's > renamed. Doh! It seems Python's quite the sneaky little snake! > By the way, what does "associate" mean, and what does it have > to do with file names? Hmm,

Re: Excute script only from another file

2013-11-25 Thread Steven D'Aprano
On Mon, 25 Nov 2013 18:28:42 -0800, Rick Johnson wrote: > On Monday, November 25, 2013 4:52:46 AM UTC-6, Himanshu Garg wrote: > >> My motive is "I will give scripts to somebody else and he should not >> run the script directly without running the parent script". > > The only sure fire method to

Re: Excute script only from another file

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 1:28 PM, Rick Johnson wrote: > The only sure fire method to prevent a file containing > Python code from executing on a machine with Python > installed is to use an extension that the system will not > associate with Python. > > ScriptFolder/ >script.py >mod_1.igno

Re: Excute script only from another file

2013-11-25 Thread Rick Johnson
On Monday, November 25, 2013 4:52:46 AM UTC-6, Himanshu Garg wrote: > My motive is "I will give scripts to somebody else and he > should not run the script directly without running the > parent script". The only sure fire method to prevent a file containing Python code from executing on a machin

Re: Excute script only from another file

2013-11-25 Thread Dave Angel
On Mon, 25 Nov 2013 02:52:46 -0800 (PST), Himanshu Garg wrote: My motive is "I will give scripts to somebody else and he should not run the script directly without running the parent script". Perhaps it should be a module, not a script. Have it protect itself with the usual if __name__ == "_

Re: Excute script only from another file

2013-11-25 Thread Himanshu Garg
I was also thinking to add a sys argument when invoking script and check it. My motive is "I will give scripts to somebody else and he should not run the script directly without running the parent script". -- https://mail.python.org/mailman/listinfo/python-list

Re: Excute script only from another file

2013-11-25 Thread Peter Otten
Himanshu Garg wrote: > I want that a script should only be executed when it is called from > another script and should not be directly executable through linux command > line. > > Like, I have two scripts "scrip1.py" and "script2.py" and there is a line > in "script1.py" to call "script2.py" as

Re: Excute script only from another file

2013-11-24 Thread Michael Torrie
On 11/24/2013 06:55 PM, Himanshu Garg wrote: > I want that a script should only be executed when it is called from > another script and should not be directly executable through linux > command line. > > Like, I have two scripts "scrip1.py" and "script2.py" and there is a > line in "script1.py" t

Re: Excute script only from another file

2013-11-24 Thread Dave Angel
On Sun, 24 Nov 2013 17:55:08 -0800 (PST), Himanshu Garg wrote: Like, I have two scripts "scrip1.py" and "script2.py" and there is a line in "script1.py" to call "script2.py" as subprocess.call(["python", "script2.py"]). Then this is should call script2 but I should not be able to directly

Re: Excute script only from another file

2013-11-24 Thread Chris Angelico
On Mon, Nov 25, 2013 at 12:55 PM, Himanshu Garg wrote: > I want that a script should only be executed when it is called from another > script and should not be directly executable through linux command line. > > Like, I have two scripts "scrip1.py" and "script2.py" and there is a line in > "scr

Excute script only from another file

2013-11-24 Thread Himanshu Garg
I want that a script should only be executed when it is called from another script and should not be directly executable through linux command line. Like, I have two scripts "scrip1.py" and "script2.py" and there is a line in "script1.py" to call "script2.py" as subprocess.call(["python", "scri