Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-08 Thread Martin Di Paola
Then, you must put the initialization (dynamically loading the modules) into the function executed in the foreign process. You could wrap the payload function into a class instances to achieve this. In the foreign process, you call the instance which first performs the initialization and then exe

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Dieter Maurer
Martin Di Paola wrote at 2022-3-6 20:42 +: >>Try to use `fork` as "start method" (instead of "spawn"). > >Yes but no. Indeed with `fork` there is no need to pickle anything. In >particular the child process will be a copy of the parent so it will >have all the modules loaded, including the dyna

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Martin Di Paola
I understand that yes, pickle.loads() imports any necessary module but only if they can be find in sys.path (like in any "import" statement). Dynamic code loaded from a plugin (which we presume it is *not* in sys.path) will not be loaded. Quick check. Run in one console the following: import mu

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Barry
> On 7 Mar 2022, at 02:33, Martin Di Paola wrote: > > Yes but I think that unpickle (pickle.loads()) does that plus > importing any module needed Are you sure that unpickle will import code? I thought it did not do that. Barry -- https://mail.python.org/mailman/listinfo/python-list

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
Yeup, that would be my first choice but the catch is that "sayhi" may not be a function of the given module. It could be a static method of some class or any other callable. Ah, fair. Are you able to define it by a "path", where each step in the path is a getattr() call? Yes but I think th

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
I'm not so sure about that. The author of the plugin knows they're writing code that will be dynamically loaded, and can therefore expect the kind of problem they're having. It could be argued that it's their responsibility to ensure that all the needed code is loaded into the subprocess. Ye

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Greg Ewing
On 7/03/22 9:36 am, Martin Di Paola wrote: It *would* be my fault if multiprocessing.Process fails only because I'm loading the code dynamically. I'm not so sure about that. The author of the plugin knows they're writing code that will be dynamically loaded, and can therefore expect the kind of

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Chris Angelico
On Mon, 7 Mar 2022 at 07:37, Martin Di Paola wrote: > > > > > > >The way you've described it, it's a hack. Allow me to slightly redescribe it. > > > >modules = loader() > >objs = init(modules) > > > >def invoke(mod, func): > ># I'm assuming that the loader is smart enough to not load > >#

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
Try to use `fork` as "start method" (instead of "spawn"). Yes but no. Indeed with `fork` there is no need to pickle anything. In particular the child process will be a copy of the parent so it will have all the modules loaded, including the dynamic ones. Perfect. The problem is that `fork` is t

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
The way you've described it, it's a hack. Allow me to slightly redescribe it. modules = loader() objs = init(modules) def invoke(mod, func): # I'm assuming that the loader is smart enough to not load # a module that's already loaded. Alternatively, load just the # module you need,

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Dieter Maurer
Martin Di Paola wrote at 2022-3-6 12:42 +: >Hi everyone. I implemented time ago a small plugin engine to load code >dynamically. > >So far it worked well but a few days ago an user told me that he wasn't >able to run in parallel a piece of code in MacOS. > >He was using multiprocessing.Process

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Chris Angelico
On Sun, 6 Mar 2022 at 23:43, Martin Di Paola wrote: > > Hi everyone. I implemented time ago a small plugin engine to load code > dynamically. > > So far it worked well but a few days ago an user told me that he wasn't > able to run in parallel a piece of code in MacOS. > > He was using multiproces

Re: Execute complex shell commands within python and obtain the output.

2019-09-03 Thread Hongyi Zhao
On Tue, 03 Sep 2019 17:27:59 +1000, Cameron Simpson wrote: > It was merely that it is hardwired in your code (and you need to wire in > something). Just keep in mind that _if_ this script runs in a non-utf8 > environment the decoding may be wrong. Unlikely to actually happen > though. Thanks, fix

Re: Execute complex shell commands within python and obtain the output.

2019-09-03 Thread Cameron Simpson
On 03Sep2019 03:59, Hongyi Zhao wrote: On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote: Finally, the .decode('utf8') assumes your locale is UTF8 based. It probably is, but if it isn't then you may get mojibake. Nowadays, most of the os use utf8 as the default locale. Am I wrong?

Re: Execute complex shell commands within python and obtain the output.

2019-09-02 Thread Hongyi Zhao
On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote: > It seems reasonable to me, but I would not use stderr=subprocess.STDOUT. > Why did you do that? The stderr stream pretty much exists to avoid > polluting stdout with error messages. Thanks for your suggestion. > > For really complex s

Re: Execute complex shell commands within python and obtain the output.

2019-09-02 Thread Cameron Simpson
On 02Sep2019 13:20, Hongyi Zhao wrote: I try to execute some complex shell commands with in python and obtain the output, I tried the following method: For python 3.x: import subprocess cmd= some_complex_command_with_pipe_and_others ps = subprocess.Popen (cmd,shell=True,stdout=subprocess.PIPE,

Re: Execute Python Scripts

2015-10-14 Thread Larry Hudson via Python-list
On 10/14/2015 10:04 AM, Cai Gengyang wrote: So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ Managed to create a file with these contents : 1 #!/usr/bin/env python3 2 3 print('hello world') and saved it as hello.py You did write that f

Re: Execute Python Scripts

2015-10-14 Thread Cai Gengyang
Ok thanks ... this --- https://docs.python.org/3/tutorial/index.html looks like a way more comprehensive resource. Paul Graham has written an excellent essay called "The Python Paradox" : http://www.paulgraham.com/pypar.html. Putting it here for sharing and discussion ... On Thursday, October

Re: Execute Python Scripts

2015-10-14 Thread Ian Kelly
On Wed, Oct 14, 2015 at 11:04 AM, Cai Gengyang wrote: > So I am going through this article on Python for newbies > ---http://askpython.com/execute-python-scripts/ That looks like a terrible resource. There are plenty of tutorials and books out there that are actually good. I suggest starting wit

Re: Execute Python Scripts

2015-10-14 Thread Cai Gengyang
On Thursday, October 15, 2015 at 1:18:27 AM UTC+8, paul.her...@gmail.com wrote: > > Where do I find the "command line" ? > > Welcome to Python. > > Starting a command shell depends on which operating system you are running. > > If you are on Microsoft Windows, choose the Start button, then type

Re: Execute Python Scripts

2015-10-14 Thread paul.hermeneutic
> Where do I find the "command line" ? Welcome to Python. Starting a command shell depends on which operating system you are running. If you are on Microsoft Windows, choose the Start button, then type "cmd" into the edit control, then press Enter. -- https://mail.python.org/mailman/listinfo/py

Re: execute commands as su on remote server

2015-10-01 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i

Re: execute commands as su on remote server

2015-09-02 Thread Antoon Pardon
Op 18-08-15 om 04:57 schreef harirammanohar...@gmail.com: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i can achieve this u

Re: execute commands as su on remote server

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 05:16:48 -0700, harirammanohar...@gmail.com wr ites: >On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: >> execute commands as su on remote server >> >> Postby hariram » Mon Aug 17, 2015 4:02 am >> Needed: >> I need to execute commands aft

Re: execute commands as su on remote server

2015-09-01 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i

Re: execute commands as su on remote server

2015-08-19 Thread Laura Creighton
In a message of Wed, 19 Aug 2015 10:44:53 +0200, Laura Creighton writes: >I haven't tried this but fabric looks encouraging: > >>From >>http://docs.fabfile.org/en/latest/api/core/operations.html#fabric.operations.run > > fabric.operations.run(*args, **kwargs) > >Run a shell command on a remote

Re: execute commands as su on remote server

2015-08-19 Thread Laura Creighton
I haven't tried this but fabric looks encouraging: >From >http://docs.fabfile.org/en/latest/api/core/operations.html#fabric.operations.run fabric.operations.run(*args, **kwargs) Run a shell command on a remote host. ... Any text entered in your local terminal will be forwarded to

Re: execute commands as su on remote server

2015-08-19 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i

Re: execute commands as su on remote server

2015-08-19 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i

Re: execute commands as su on remote server

2015-08-18 Thread Julio Oña
Hi, try to use http://www.fabfile.org/ look at: http://docs.fabfile.org/en/latest/api/core/operations.html sudo() call has the posibility to change to another user besides root, with: with settings(sudo_user='mysql'): sudo("whoami") # prints 'mysql' El lun., 17 de ago. de 2015 a la(s) 1

Re: execute commands as su on remote server

2015-08-17 Thread Chris Angelico
On Tue, Aug 18, 2015 at 12:57 PM, wrote: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i can achieve this using python? > I googled and came to know that its not possible, so just for confirmation > asking again, is it

Re: Execute a python script with CGI ?

2014-06-27 Thread dandrigo
Dear all, 1/ On my windows 8, i installed apache 2.2, python 2.7. I coded a python script. I would like to execute this python script in CGI.I would like enable GET pattern only (no POST pattern). Up to now : *i edited these following lines of my apache httpd.conf: --

Re: Execute a python script with CGI ?

2014-06-26 Thread Ian Kelly
On Thu, Jun 26, 2014 at 9:24 AM, dandrigo wrote: > Dear all, > > I coded a python script (web service with query postgresql/postgis). Up to > now, i did several test on my local laptop station (windows). > > Now i want to execute this python script on our remote server (Web server : > Apache;OS :

Re: Execute a python script with CGI ?

2014-06-26 Thread gregor
Hi, Am Thu, 26 Jun 2014 08:24:56 -0700 (PDT) schrieb dandrigo : > I coded a python script (web service with query postgresql/postgis). > Up to now, i did several test on my local laptop station (windows). > > Now i want to execute this python script on our remote server (Web > server : Apache;O

Re: Execute python within Oracle

2011-12-09 Thread Ian Kelly
2011/12/9 André Lopes : > Hi all, > > > >    I wrote a simple Java program to be called within an Oracle database. The > goal is to execute a Python program within the DB itself, by the means of a > Java program. The problem is that when I execute the procedure inside the > DB, nothing happens… > >

Re: Execute a command on remote machine in python

2011-11-15 Thread Rodrick Brown
You could easily script this with popen calling secure shell to execute a command and capture the output. Sent from my iPhone On Nov 15, 2011, at 7:04 AM, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem

Re: Execute a command on remote machine in python

2011-11-15 Thread Marco Nawijn
On Nov 15, 1:04 pm, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of

Re: Execute a command on remote machine in python

2011-11-15 Thread Roy Smith
In article , Chris Angelico wrote: > On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > > Hi, > > > > I want to execute a windows command within python script from a client > > machine on a remote target server, and would want the output of the > > command written in a file on client machine. Wha

Re: Execute a command on remote machine in python

2011-11-15 Thread Xavier Ho
It sounds like Fabric is what you're after. We use it at work and it's the best thing since ssh. ;] http://docs.fabfile.org/en/1.3.2/index.html (Actually, it uses ssh internally and allows you to do remote shell-like programming in a pythonic fashion.) Cheers, Xav On 15 November 2011 22:04, R

Re: Execute a command on remote machine in python

2011-11-15 Thread Chris Angelico
On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > Hi, > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. This looks l

Re: Execute a command on remote machine in python

2011-11-15 Thread Jean-Michel Pichavant
Martin P. Hellwig wrote: On 11/15/11 12:04, Roark wrote: Hi, I am first time trying my hands on python scripting and would need some guidance from the experts on my problem. I want to execute a windows command within python script from a client machine on a remote target server, and would want

Re: Execute a command on remote machine in python

2011-11-15 Thread Martin P. Hellwig
On 11/15/11 12:04, Roark wrote: Hi, I am first time trying my hands on python scripting and would need some guidance from the experts on my problem. I want to execute a windows command within python script from a client machine on a remote target server, and would want the output of the command

Re: Execute code after Shut Down command given --- How?

2011-09-22 Thread Steven D'Aprano
Virgil Stokes wrote: > I would like to execute some Python code (popup message to be displayed) > when > Windows Vista/7 is shut down. That is, this code should execute after > "Shut Down" is given from the "Shut Down Windows" popup, but before the > actual shut down sequence starts. > > How to

Re: Execute a method in a file in an egg

2011-08-24 Thread Sebastien Douche
On Wed, Aug 24, 2011 at 12:04, Gabriel Genellina wrote: >> Is there a way to do this from the command line? Thanks. > > Something like this? > > python -c "import the.module;the.module.someclass().method(arguments)" Or with console_scripts option in setup.py. -- Sebastien Douche Twitter : @sd

Re: Execute a method in a file in an egg

2011-08-24 Thread Gabriel Genellina
En Tue, 23 Aug 2011 13:14:06 -0300, RVince escribió: Is there a way to do this from the command line? Thanks. Something like this? python -c "import the.module;the.module.someclass().method(arguments)" -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Execute script from ipython

2011-08-22 Thread Johan Ekh
Thanks Chris! I tried using "!" instead of "run". It works but with a significant performance penalty. Best regards, Johan On Fri, Aug 19, 2011 at 5:11 PM, Chris Rebert wrote: > On Fri, Aug 19, 2011 at 6:00 AM, Johan Ekh wrote: > > Hi all, > > I have a script "myscript.py" located in "/usr/lo

Re: Execute script from ipython

2011-08-19 Thread Chris Rebert
On Fri, Aug 19, 2011 at 6:00 AM, Johan Ekh wrote: > Hi all, > I have a script "myscript.py" located in "/usr/local/bin" on my linux box. > I can execute it in ipython with > > run /usr/local/bin/myscript.py > > but not with > > run myscript.py > > even though /usr/local/bin is in my $PATH and in m

Re: execute shell script from python, needs sys.argv

2010-11-07 Thread Lawrence D'Oliveiro
In message <1vmbd65uaj2snq1v0vo49ktn0lsc2o5...@4ax.com>, Tim Roberts wrote: > I KNOW that we're still working on syntax here, and that it's too early > for optimization, but it bothers me to see "cat" as the first thing in a > pipeline. An anti-UUOC instinct. Very good. :) -- http://mail.python.

Re: execute shell script from python, needs sys.argv

2010-11-06 Thread Tim Roberts
Benjamin Kaplan wrote: > >Python is not the shell. Shell commands are not python commands. You >need either a string or a list of strings, so any literal have to be >in quotes. Also, subprocess can't handle the redirection. You need to >run it as two commands. > >proc1 = subprocess.Popen(["cat", s

Re: execute shell script from python, needs sys.argv

2010-11-04 Thread Peter Otten
Matt wrote: > I am trying to execute a shell script from within python.. This shell > script takes the format, where $1 and $2 are variables from the > command line: cat $1 | Fastx_trimmer -n COUNT -o $2 > > straight into the cmd line it would be: cat file.1 | Fastx_trimmer -n > COUNT -o file.2

Re: execute shell script from python, needs sys.argv

2010-11-04 Thread Benjamin Kaplan
On Thu, Nov 4, 2010 at 11:37 AM, Matt wrote: > Hi All, > > I am trying to execute a shell script from within python..  This shell > script takes the format, where $1 and $2 are variables from the > command line: cat $1 | Fastx_trimmer -n COUNT -o $2 > > straight into the cmd line it would be:  cat

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
actually using the -i param in the command to subprocess doesn't seem to work as well as setting PS1 to some garbage, it starts a new interactive shell therein kicking me out of python. :/ Thank you, -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
for the broken pipe error, perhaps theres a different way I can get shell output other than using subprocess? I need the output of alias command into a string and output of declare command into a string as well, I would like to also avoid creating of a single liner script to make this happen if at

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
I do have a problem however that I don't know how to solve. My application dies abruptly at random times because of this and I get this output error in the terminal: bash: line 0: declare: write error: Broken pipe and sometimes it crashes and I get this output error; this one maybe gtk related, y

Re: execute bash builtins in python

2010-03-21 Thread alex goretoy
Thank you for the great suggestions. Steve Holden that is a good one, I will try to adapt my application to your suggestion. This way I don't have to source .bashrc when it could do all that for me including other things that it does in the background. Thank you so much. Nobody, I was not aware of

Re: execute bash builtins in python

2010-03-17 Thread Chris Colbert
On Wed, Mar 17, 2010 at 11:44 AM, Nobody wrote: > On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote: > > > For shell=True I believe you should provide the command as a single > > string, not a list of arguments. > > Using shell=True with an argument list is valid. > > On Unix, it's seldom wh

Re: execute bash builtins in python

2010-03-17 Thread Nobody
On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote: > For shell=True I believe you should provide the command as a single > string, not a list of arguments. Using shell=True with an argument list is valid. On Unix, it's seldom what you want: it will invoke /bin/sh to execute the first argume

Re: execute bash builtins in python

2010-03-13 Thread Steve Holden
alex goretoy wrote: > I found this to be even better; maybe someone will find this useful, who > knows. > just export PS1, duh > Popen(["bash -c 'export PS1='python'; source > $HOME/.bashrc;alias'"],shell=True,stdout=PIPE).stdout.read() > Try using an interactive shell: >>> from subprocess import

Re: execute bash builtins in python

2010-03-13 Thread alex goretoy
I found this to be even better; maybe someone will find this useful, who knows. just export PS1, duh Popen(["bash -c 'export PS1='python'; source $HOME/.bashrc;alias'"],shell=True,stdout=PIPE).stdout.read() -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list

Re: execute bash builtins in python

2010-03-12 Thread alex goretoy
Steve thank you. The problem is that you can only run commands from Popen or os.system and stuff. You cant run bash shell builtin commands for some reason. I was able to get this to work. What I did is call this: Popen(["bash -c 'source $HOME/.bashrc;alias'"],shell=True,stdout=PIPE).stdout.read()

Re: execute bash builtins in python

2010-03-12 Thread Steve Holden
alex goretoy wrote: > hi, > i'm trying to write a section of my program that needs to run bash > builtin alias and declare, i've googled and tried every type of example > i could find no to avail. this is what I've tried below and it doesn't > work, is there a way for me to execute a bah builin fro

Re: execute sqlite3 dot commands in python

2010-02-11 Thread Aahz
In article , Steve Holden wrote: > >No. That's not how you pass commands to sqlite3 - you connect to a >database, create a cursor on the connection, and then execute SQL >statements (not sqlite commands) on the cursor. Like this: > import sqlite3 c = sqlite3.connect("deleteme") cu

Re: execute sqlite3 dot commands in python

2010-02-08 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 gintare statkute wrote: > Does anybody know if it possible to execute sqlite3 dot commands in python? The dot commands are parsed and executed by different code not part of the standard SQLite library. However if you want interactive shell functional

Re: execute sqlite3 dot commands in python

2010-02-06 Thread Carl Banks
On Feb 5, 3:19 pm, Steve Holden wrote: > gintare statkute wrote: > > Does anybody know if it possible to execute sqlite3 dot commands in python? > > > dovanotas:/pages/links# python > > Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26) > > [GCC 4.3.2] on linux2 > > Type "help", "copyright", "credit

Re: execute sqlite3 dot commands in python

2010-02-05 Thread Steve Holden
gintare statkute wrote: > Does anybody know if it possible to execute sqlite3 dot commands in python? > > dovanotas:/pages/links# python > Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import s

Re: execute a function before and after any method of a parent class

2008-10-07 Thread Gabriel Genellina
En Tue, 07 Oct 2008 10:34:44 -0300, Michele Simionato <[EMAIL PROTECTED]> escribió: On Oct 3, 9:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: Ok, but then you have to explicitely decorate every method. To avoid this,   you may use a metaclass; this article by Michael Foord explains

Re: execute a function before and after any method of a parent class

2008-10-07 Thread Michele Simionato
On Oct 3, 9:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Ok, but then you have to explicitely decorate every method. To avoid this,   > you may use a metaclass; this article by Michael Foord explains > how:http://www.voidspace.org.uk/python/articles/metaclasses.shtml#a-metho... Since

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 16:03:22 +0200, TP wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to > obtain a class B(A), with all methods of B being the methods of A > preceded by a special method of B called _before_any_method_of_A( self > ), and followed by a

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Terry Reedy
Gabriel Genellina wrote: En Fri, 03 Oct 2008 11:03:22 -0300, TP <[EMAIL PROTECTED]> escribió: I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A(

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 11:03:22 -0300, TP <[EMAIL PROTECTED]> escribió: I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A( self ), and followed

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 9:03 am, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to obtain a > class B(A), with all methods of B being the methods of A preceded by a > special method of B called _before_any_method_of_A( self ), and followed by >

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Almar Klein
Maybe you can use __getattribute__. I tried it, but got stuck trying to let __getattribute__ work normal without calling itself. class A(object): def foo(self): print "hi" class B(A): def __getattribute__(self,name): try: fun = A.__dict__[name] except K

Re: execute another python script

2008-08-18 Thread Alexandru Mosoi
On Aug 18, 11:34 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >  >>> import sys, subprocess >  >>> subprocess.call([sys.executable, "-c", "print 'hello'"]) > hello > 0 10x :). exactly what I was looking for. -- http://mail.python.org/mailman/listinfo/python-list

Re: execute another python script

2008-08-18 Thread Fredrik Lundh
Alexandru Mosoi wrote: how do I execute another python script under a different process? I want the script to be run using the same interpretoer as the one running current script. I tried using os.execlp but I don't know how to get the name/path of the interpreter. >>> import sys, subprocess >

Re: Execute a script on a remote machine

2008-06-20 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 srinivasan srinivas wrote: > Is there any other way rather than communicating back to the caller? No, the remote PID isn't magically transferred via RSH. The remote script must communicate the PID back. Just writing it remotely as first line and on t

Re: Execute a script on a remote machine

2008-06-20 Thread srinivasan srinivas
This is ok. Is there any other way to find it out? Thanks, Srini - Original Message From: Gerhard Häring <[EMAIL PROTECTED]> To: python-list@python.org Sent: Friday, 20 June, 2008 10:03:30 PM Subject: Re: Execute a script on a remote machine srinivasan srinivas wrote: >

Re: Execute a script on a remote machine

2008-06-20 Thread Gerhard Häring
srinivasan srinivas wrote: Hi, My requirement is i have to execute a python script on a remote machine as a subprocess from a python script and to get the subprocess pid of the process running the script. Is there anyway to do that?? I have used subprocess.popen() method to do that. I have done

Re: execute python script question

2008-03-11 Thread Piet van Oostrum
> Gabriel Rossetti <[EMAIL PROTECTED]> (GR) wrote: >GR> not a stupid question, I think that may be it. I tried setting PYTHONPATH >GR> like Sam suggested and it worked, but I was unable to do it programmically. >GR> I tried putting it in the __init__.py file like a web post suggested but it >G

Re: execute python script question

2008-03-11 Thread Gabriel Rossetti
Michael Wieher wrote: > stupid question: you have myPackage somewhere on sys.path? > > I mean, module1.py only knows it lives in a directory, it doesn't know > anything about anything above it. > > > > 2008/3/10, Gabriel Rossetti <[EMAIL PROTECTED] > >: > > Hello, >

Re: execute python script question

2008-03-11 Thread Gabriel Rossetti
Sam wrote: > Hello, > > I may misunderstand your problem, but it may be related to the > execution environment, especially the PYTHONPATH variable. Have a look > at the following log: > > [EMAIL PROTECTED]:/$ pwd > / > [EMAIL PROTECTED]:/$ cat -n /tmp/test_import.py > 1 class A(object): >

Re: execute python script question

2008-03-10 Thread Sam
Hello, I may misunderstand your problem, but it may be related to the execution environment, especially the PYTHONPATH variable. Have a look at the following log: [EMAIL PROTECTED]:/$ pwd / [EMAIL PROTECTED]:/$ cat -n /tmp/test_import.py 1 class A(object): 2 def __init__(self):

Re: execute

2008-03-09 Thread Benjamin
On Mar 9, 4:22 pm, Gif <[EMAIL PROTECTED]> wrote: > i'm trying to execute a file without replacing the current process, > but after searching the help file, documentations and the web, i can't > a way of doing that. > > os.exec*() will close the current program. Have a look at the subprocess module

Re: execute

2008-03-09 Thread castironpi
> >  os.exec*() will close the current program. > > On *nix, you can use os.fork().  According > tohttp://effbot.org/librarybook/os.htm, you can use Do you mean, and block for the process to terminate? Or do you mean, do something else in the meantime, perhaps for a certain amount (of meantime)?

Re: execute

2008-03-09 Thread Dan Upton
On Sun, Mar 9, 2008 at 5:22 PM, Gif <[EMAIL PROTECTED]> wrote: > i'm trying to execute a file without replacing the current process, > but after searching the help file, documentations and the web, i can't > a way of doing that. > > os.exec*() will close the current program. > > ps: by executin

Re: execute

2008-03-09 Thread Gif
ok i found a workaround. -- http://mail.python.org/mailman/listinfo/python-list

Re: execute

2008-03-09 Thread Gif
i know os.popen() but i want to execute a file with args -- http://mail.python.org/mailman/listinfo/python-list

Re: execute script in certain directory

2007-07-09 Thread Gabriel Genellina
En Mon, 09 Jul 2007 14:09:40 -0300, Alex Popescu <[EMAIL PROTECTED]> escribió: > Interesting. I was wondering about the opposit: being in the parent > dir, how can I run a module from a package. (the current behavior when > running python dir_name\module.py is to consider the dir_name the > curr

Re: execute script in certain directory

2007-07-09 Thread Gabriel Genellina
En Mon, 09 Jul 2007 14:14:07 -0300, vasudevram <[EMAIL PROTECTED]> escribió: > On Jul 9, 8:31 pm, brad <[EMAIL PROTECTED]> wrote: >> When I use idle or a shell to execute a python script, the script >> executes in the directory it is currently in (in this case, my desktop). >> However, when usin

Re: execute script in certain directory

2007-07-09 Thread vasudevram
On Jul 9, 8:31 pm, brad <[EMAIL PROTECTED]> wrote: > When I use idle or a shell to execute a python script, the script > executes in the directory it is currently in (in this case, my desktop). > However, when using GNOME and right clicking the py script and selecting > 'open with python', the exec

Re: execute script in certain directory

2007-07-09 Thread Alex Popescu
On Jul 9, 6:31 pm, brad <[EMAIL PROTECTED]> wrote: > When I use idle or a shell to execute a python script, the script > executes in the directory it is currently in (in this case, my desktop). > However, when using GNOME and right clicking the py script and selecting > 'open with python', the exec

RE: Execute script on remote computer

2007-06-20 Thread Vikas Saini
June 20, 2007 10:09 AM To: Vikas Saini Cc: python-list@python.org Subject: Re: Execute script on remote computer Does the script resides on the remote machine or do we have to transfer the script to the remote machine.If remote and agent machine are linux then you can use rsh/ssh to do so. On

Re: Execute script on remote computer

2007-06-20 Thread Laurent Pointal
Evan Klitzke a écrit : > On 6/19/07, Vikas Saini <[EMAIL PROTECTED]> wrote: >> I am trying to run the agent on one machine that will execute the >> script of >> a remote machine. > > It's not clear what OS you're using. But if you're running a > Unix/Linux system and it's a relatively simple scri

RE: Execute script on remote computer

2007-06-19 Thread Vikas Saini
The os I am using is window Xp. Thanks&Regards, Vikas Saini Do or do not. There is no try. -Original Message- From: Evan Klitzke [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 20, 2007 10:21 AM To: Vikas Saini Cc: python-list@python.org Subject: Re: Exe

Re: Execute script on remote computer

2007-06-19 Thread Evan Klitzke
On 6/19/07, Vikas Saini <[EMAIL PROTECTED]> wrote: > I am trying to run the agent on one machine that will execute the script of > a remote machine. It's not clear what OS you're using. But if you're running a Unix/Linux system and it's a relatively simple script that you want to run, you should j

Re: Execute script on remote computer

2007-06-19 Thread rishi pathak
Does the script resides on the remote machine or do we have to transfer the script to the remote machine.If remote and agent machine are linux then you can use rsh/ssh to do so. On 6/19/07, Vikas Saini <[EMAIL PROTECTED]> wrote: I am trying to run the agent on one machine that will execute the

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- stef <[EMAIL PROTECTED]> wrote: > the language I want to simulate (JAL), > is very Pascal like, > and therefor can be easily converted into equivalent > Python code. > One more idea. If you haven't already, maybe you can post something to the PyPy community to effect of this: ''' I have a P

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- stef <[EMAIL PROTECTED]> wrote: > Steve, > that's exactly what I've in mind. > The screen shots, looks really good, > and I'll definitely will take a deeper look into > your code. Cool, good luck. Feel free to contact me privately if you have questions about the implementation. There's als

Re: execute a function after each source code line ?

2007-06-01 Thread stef
Diez B. Roggisch wrote: > stef wrote: > > >> hello, >> >> doing a simulation of another language (JAL), >> I translate the other language into Python code, >> then I execute this converted Python code. >> >> Now I need todo some checks and give visual feedback to the user, >> each time a line of

Re: execute a function after each source code line ?

2007-06-01 Thread stef
Steve Howell wrote: > --- stef <[EMAIL PROTECTED]> wrote: > >> doing a simulation of another language (JAL), >> I translate the other language into Python code, >> then I execute this converted Python code. >> [...] >> (btw the whole program is running as an graphical >> (wxPython) application)

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Are there any other (simple) ways of achieving > this ? > > (btw the whole program is running as an graphical > (wxPython) application) > > use the python trace facilities. > > http://docs.python.org/lib/module-trace.html > I'm not sure how

  1   2   >