Re: Subprocess Popen confusion

2020-05-19 Thread Barry Scott
> On 18 May 2020, at 21:50, Dick Holmes wrote: snip > Per Peter's suggestion I tried readline and it works "as expected". I > also discovered that the reason the read operations were stalling was > that they followed a write and the write doesn't actually occur until > "flush" is called ev

Re: Subprocess Popen confusion

2020-05-18 Thread Dick Holmes
pexpect > > https://pexpect.readthedocs.io/en/stable/index.html > > does this naturally, but I don't know if Windows support is sufficient for > your needs. > > > I've looked at various mechanisms and the > > class that seems to fit my needs is Popen in t

Re: Subprocess Popen confusion

2020-05-14 Thread Dick Holmes
pexpect > > https://pexpect.readthedocs.io/en/stable/index.html > > does this naturally, but I don't know if Windows support is sufficient for > your needs. > > > I've looked at various mechanisms and the > > class that seems to fit my needs is Popen in t

Re: Subprocess Popen confusion

2020-05-14 Thread Terry Reedy
On 5/13/2020 11:13 PM, Dick Holmes wrote: https://occovid19.ochealthinfo.com/coronavirus-in-oc I'm trying to communicate using a continuing dialog between two processes on the same system Try multiprocessing and pipes. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-lis

Re: Subprocess Popen confusion

2020-05-14 Thread Peter Otten
#x27;t know if Windows support is sufficient for your needs. > I've looked at various mechanisms and the > class that seems to fit my needs is Popen in the subprocess module, but > I can't seem to get more than a single round-trip message through Popen. > I first call Popen

Subprocess Popen confusion

2020-05-13 Thread Dick Holmes
https://occovid19.ochealthinfo.com/coronavirus-in-oc I'm trying to communicate using a continuing dialog between two processes on the same system. I've looked at various mechanisms and the class that seems to fit my needs is Popen in the subprocess module, but I can't seem to

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread Peter Otten
info.strip('||') > print g_info > print info > fp.close() > Error: > AttributeError: 'Popen' object has no attribute 'read' You have to specify the stream/file, e. g. g_info.stdout.read() but when want both stdout and stderr your rea

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread Chris Angelico
On Fri, Jan 4, 2019 at 10:16 PM wrote: > > On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > > I am no expert in python but I found grep is lot faster in than the > > > methods of reading files from python point

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread marco . nawijn
On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > I am no expert in python but I found grep is lot faster in than the methods > > of reading files from python point me to direction if you know of > > anything faste

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Chris Angelico
On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > I am no expert in python but I found grep is lot faster in than the methods > of reading files from python point me to direction if you know of > anything faster I would appreciate it. > Try doing things the simple and easy way in Python,

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Mohan Mohta
On Thursday, January 3, 2019 at 1:49:31 PM UTC-6, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > > > Hello, > > I am trying to grep the keyword (which I got from report_file ) from > > report_file > > > > I tried multiple ways but am unable to get it to work. > > H

RE: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread David Raymond
Agreeing with the other poster that it's probably not the best way to handle it. But for the sake of helping with subprocess: https://docs.python.org/3.7/library/subprocess.html#popen-objects Popen Objects don't have read() as the error says. That's on their .stdout and .std

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Chris Angelico
On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > Hello, > I am trying to grep the keyword (which I got from report_file ) from > report_file > > I tried multiple ways but am unable to get it to work. How about, instead, you simply open the file and iterate through it, looking for the keywor

subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Mohan Mohta
g_info=subprocess.Popen('cat report_file| grep -i '+var1, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: &

Re: error from Popen only when run from cron

2018-04-17 Thread Dan Stromberg
On Tue, Apr 17, 2018 at 4:11 PM, wrote: > W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik larry@gmail.com > napisał: >> I have a script that does this: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> >> When I ru

Re: error from Popen only when run from cron

2018-04-17 Thread daniel . chmielewski
W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik larry@gmail.com napisał: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I r

Re: error from Popen only when run from cron

2018-01-27 Thread Wildman via Python-list
On Sat, 27 Jan 2018 10:58:36 -0500, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > >

Re: error from Popen only when run from cron

2018-01-27 Thread Larry Martell
On Sat, Jan 27, 2018 at 11:09 AM, Chris Angelico wrote: > On Sun, Jan 28, 2018 at 2:58 AM, Larry Martell > wrote: >> I have a script that does this: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> >> When I run it from the com

Re: error from Popen only when run from cron

2018-01-27 Thread Dan Stromberg
If you have your script set $PATH and $HOME, you can test it with: env - ./my-script The difference between running a script from the command line, and running a script from cron, is often environment variables. env - clears the environment. On Sat, Jan 27, 2018 at 7:58 AM, Larry Martell wrote:

Re: error from Popen only when run from cron

2018-01-27 Thread Grant Edwards
On 2018-01-27, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['s

Re: error from Popen only when run from cron

2018-01-27 Thread Chris Angelico
On Sun, Jan 28, 2018 at 2:58 AM, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > su

error from Popen only when run from cron

2018-01-27 Thread Larry Martell
I have a script that does this: subprocess.Popen(['service', 'some_service', 'status'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) When I run it from the command line it works fine. When I run it from cron I get: subprocess.Popen(['service', 'some_service', 'status'], stdout=subproces

Re: Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

2016-04-02 Thread Hongyi Zhao
5, in >> os.environ.update(line.partition('=')[::2] for line in output.split >> ('\0')) >> AttributeError: 'Popen' object has no attribute 'split' >> --- > > So your problem is nothing to do with “update ‘o

Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

2016-04-02 Thread Ben Finney
> > Traceback (most recent call last): > File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/ > runjasp.py", line 125, in > os.environ.update(line.partition('=')[::2] for line in output.split > ('\0')) > Att

Re: Best way to rewrite Popen

2015-05-19 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: > At the moment I am playing with things like: > p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) > > I think that most of the times this are the values I want. So it would > be nice to overrule the defaults. What is the best way to do this? > So cr

Re: Best way to rewrite Popen

2015-05-19 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: > At the moment I am playing with things like: > p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) > > I think that most of the times this are the values I want. So it would > be nice to overrule the defaults. What is the best way to do this? > So cr

Re: Best way to rewrite Popen

2015-05-19 Thread Cecil Westerhof
Op Wednesday 20 May 2015 01:20 CEST schreef MRAB: > On 2015-05-19 23:23, Cecil Westerhof wrote: >> Op Tuesday 19 May 2015 23:28 CEST schreef Jon Ribbens: >> >>> On 2015-05-19, Cecil Westerhof wrote: It looks like that this does what I want (the dot is needed so that it also works with 2

Re: Best way to rewrite Popen

2015-05-19 Thread MRAB
On 2015-05-19 23:23, Cecil Westerhof wrote: Op Tuesday 19 May 2015 23:28 CEST schreef Jon Ribbens: On 2015-05-19, Cecil Westerhof wrote: It looks like that this does what I want (the dot is needed so that it also works with 2.7): files = sorted(os.listdir('.')) p = re.compile('actions-2015-05

Re: Best way to rewrite Popen

2015-05-19 Thread Cecil Westerhof
Op Tuesday 19 May 2015 23:28 CEST schreef Jon Ribbens: > On 2015-05-19, Cecil Westerhof wrote: >> It looks like that this does what I want (the dot is needed so that >> it also works with 2.7): files = sorted(os.listdir('.')) p = >> re.compile('actions-2015-05-[0-9][0-9].sql$') current_month = [

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > It looks like that this does what I want (the dot is needed so that it > also works with 2.7): > files = sorted(os.listdir('.')) > p = re.compile('actions-2015-05-[0-9][0-9].sql$') > current_month = [ file for file in files if p.match(file) ] Yo

Re: Best way to rewrite Popen

2015-05-19 Thread Cecil Westerhof
ing this anyway, rather than using os.listdir()? >> Invoking subprocesses via the shell is very rarely a good idea. > > I want to rewrite a Bash script into a Python script. The 'ls -1' is > only an example. But Popen and listdir give a different output. The > sorting is

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
tdout (and maybe stderr). >> >> Yes. >> >> def shellprocess(cmd, **kwargs): >> return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, >> **kwargs) > > Will that not go wrong if I call it with? > shellprocess('ls -1', shell = False) Yes

Re: Best way to rewrite Popen

2015-05-19 Thread Cecil Westerhof
rocess.getstatusoutput('ls -1') >> files_new = output.splitlines() But it is still nice to know. > > Why are you doing this anyway, rather than using os.listdir()? > Invoking subprocesses via the shell is very rarely a good idea. I want to rewrite a Bash script into a Pytho

Re: Best way to rewrite Popen

2015-05-19 Thread Chris Angelico
On Wed, May 20, 2015 at 3:55 AM, Zachary Ware wrote: >> def capture_stdout(*a, **kw): >> if 'stdout' not in kw: kw['stdout'] = subprocess.PIPE > > Just a quick note that this line can be simplified nicely to: > > kw.setdefault('stdout', subprocess.PIPE) Yes, in the simple case. That does requ

Re: Best way to rewrite Popen

2015-05-19 Thread Zachary Ware
as > the command, but if you make that the default, you'll end up exposing > yourself in some situation where it isn't hard-coded.) With that > change, there's really only one parameter that you're defaulting, so > there's not as much point making the change, b

Re: Best way to rewrite Popen

2015-05-19 Thread Chris Angelico
there's really only one parameter that you're defaulting, so there's not as much point making the change, but the technique still works, and maybe you'll add more to the setup: @functools.wraps(subprocess.Popen) def Popen(*a, **kw): if 'stdout' not in kw: kw['

Re: Best way to rewrite Popen

2015-05-19 Thread Jonas Wielicki
On 19.05.2015 19:01, Cecil Westerhof wrote: > At the moment I am playing with things like: > p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) > > I think that most of the times this are the values I want. So it would > be nice to overrule the defaults. What is the best way

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > At the moment I am playing with things like: > p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) > > I think that most of the times this are the values I want. So it would > be nice to overrule the defaults. What is the best way to do

Best way to rewrite Popen

2015-05-19 Thread Cecil Westerhof
At the moment I am playing with things like: p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) I think that most of the times this are the values I want. So it would be nice to overrule the defaults. What is the best way to do this? So creating a function that is exactly th

Re: Popen class?

2014-10-31 Thread Steven D'Aprano
satishmlm...@gmail.com wrote: > What is Popen class? Googling could answer that: https://duckduckgo.com/html/?q=python+popen+class If you have a specific question, please be more detailed when you ask your question, then we can give more specific answers. -- Steven -- ht

Re: Popen class?

2014-10-31 Thread Cameron Simpson
On 31Oct2014 05:28, satishmlm...@gmail.com wrote: What is Popen class? It's a class from the subprocess module: https://docs.python.org/3/library/subprocess.html#module-subprocess used for starting external programs, waiting for them to execute, and using their input and ou

Popen class?

2014-10-31 Thread satishmlmlml
What is Popen class? -- https://mail.python.org/mailman/listinfo/python-list

Flushing out data from Popen buffer

2014-01-21 Thread abc79721
ffer size! By reducing the tail_buffer size , the script worked fine. I cant use subprocess(Python Version is 2.4.3) I do not want to rely on tail_buffer size. Ideally the script should be independent of it! Is there a way to flush data from the POPEN buffer ? -- https://mail.python.org/mailman/listinfo/python-list

Re: New line conversion with Popen attached to a pty

2013-06-21 Thread Dave Angel
On 06/20/2013 06:20 AM, Jonathan Harden wrote: Hi, We have a class which executes external processes in a controlled environment and does "things" specified by the client program with each line of output. To do this we have been attaching stdout from the subprocess.Popen to a pseudo terminal (

Re: New line conversion with Popen attached to a pty

2013-06-21 Thread jfharden
On Thursday, 20 June 2013 11:20:20 UTC+1, Jonathan Harden wrote: > ...SNIP > Sorry about the second post, it took a very long time to show up, long enough I thought it had been lost. -- http://mail.python.org/mailman/listinfo/python-list

Re: New line conversion with Popen attached to a pty

2013-06-21 Thread jfharden
On Thursday, 20 June 2013 23:04:39 UTC+1, Peter Otten wrote: > (2) Fiddle with terminal options, e. g. > > attrs = termios.tcgetattr(outSlave) > attrs[1] = attrs[1] & (~termios.ONLCR) | termios.ONLRET > termios.tcsetattr(outSlave, termios.TCSANOW, attrs) > > p = subprocess.Pop

New line conversion with Popen attached to a pty

2013-06-21 Thread Jonathan Harden
pened with os.fdopen. I noticed that we kept getting a bunch of extra new line characters. This is all using python 2.6.4 in a centos6 environment. After some investigation I realised we needed to use universal_newline support so I enabled it for the Popen and specified the mode in the fdope

Re: New line conversion with Popen attached to a pty

2013-06-20 Thread Peter Otten
gt; line characters. Mixing subprocess and explicit select() looks a bit odd to me. Perhaps you should do it completely without subprocess. Did you consider pexpect? > This is all using python 2.6.4 in a centos6 environment. > > After some investigation I realised we needed to use universal

New line conversion with Popen attached to a pty

2013-06-20 Thread jfharden
After some investigation I realised we needed to use universal_newline support so I enabled it for the Popen and specified the mode in the fdopen to be rU. Things still seemed to be coming out wrong so I wrote up a test program boiling it down to the simplest cases (which is at the end of this mes

Re: Popen in Python3

2013-06-19 Thread Nobody
On Wed, 19 Jun 2013 23:03:05 +, Joseph L. Casale wrote: > I am trying to invoke a binary that requires dll's in two places all of > which are included in the path env variable in windows. When running this > binary with popen it can not find either, passing env=os.environ to

Popen in Python3

2013-06-19 Thread Joseph L. Casale
I am trying to invoke a binary that requires dll's in two places all of which are included in the path env variable in windows. When running this binary with popen it can not find either, passing env=os.environ to open made no difference. Anyone know what might cause this or how to work a

RE: Popen and reading stdout in windows

2013-06-11 Thread Nobody
On Tue, 11 Jun 2013 01:50:07 +, Joseph L. Casale wrote: > I am using Popen to run the exe with communicate() and I have sent stdout > to PIPE without luck. Just not sure what is the proper way to iterate over > the stdout as it eventually makes its way from the buffer. The prop

Re: Popen and reading stdout in windows

2013-06-11 Thread Chris Rebert
one of those days, the post was rather > > useless... > > > > I am using Popen to run the exe with communicate() and I have sent > > stdout to PIPE without luck. Just not sure what is the proper way to > > iterate over the stdout as it eventually makes its way fr

Re: Popen and reading stdout in windows

2013-06-11 Thread Pete Forman
"Joseph L. Casale" writes: >> You leave out an awful amount of detail. I have no idea what ST is, >> so I'll have to guess your real problem. > > Ugh, sorry guys its been one of those days, the post was rather > useless... > > I am using Popen to run

RE: Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
> You leave out an awful amount of detail. I have no idea what ST is, so > I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luc

Re: Popen and reading stdout in windows

2013-06-10 Thread Dave Angel
On 06/10/2013 02:37 PM, Joseph L. Casale wrote: I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyo

Re: Popen and reading stdout in windows

2013-06-10 Thread Grant Edwards
On 2013-06-10, Joseph L. Casale wrote: > I have a use where writing an interim file is not convenient and I > was hoping to iterate through maybe 100k lines of output by a process > as its generated or roughly anyways. > > Seems to be a common question on ST, and more easily solved in Linux. > An

Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyone currently doing this with Python 2.7 in windows

Re: How to hide console with Popen on Windows?

2012-05-22 Thread xliiv
On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote: > On May 22, 3:00 am, xliiv wrote: > > Now I know that my 'solution' is not a solution and problem still bugs me. > > Any ideas how to deal with it? > > I haven't tried it but this thread talks about being able to use a > standard install o

Re: How to hide console with Popen on Windows?

2012-05-21 Thread alex23
On May 22, 3:00 am, xliiv wrote: > Now I know that my 'solution' is not a solution and problem still bugs me. > Any ideas how to deal with it? I haven't tried it but this thread talks about being able to use a standard install of Python with OpenOffice: http://user.services.openoffice.org/en/for

Re: How to hide console with Popen on Windows?

2012-05-21 Thread xliiv
.py file is > executing. Unless you're able to make the file a .pyw file - which you > are apparently not as you're using OpenOffice - then executing the > code that uses Popen is what is displaying a console, not the call to > Popen itself. Ok, thanks for explanation. Now I

Re: How to hide console with Popen on Windows?

2012-05-20 Thread alex23
not as you're using OpenOffice - then executing the code that uses Popen is what is displaying a console, not the call to Popen itself. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to hide console with Popen on Windows?

2012-05-18 Thread Kevin Walzer
On 5/18/12 4:22 AM, xliiv wrote: Like the topic, more details in followed links.. http://stackoverflow.com/questions/10637450/how-to-hide-console-with-popen-on-windows http://code.activestate.com/recipes/409002-launching-a-subprocess-without-a-console-window/?c=14452 Please help :( Any hint

Re: How to hide console with Popen on Windows?

2012-05-18 Thread Chris Angelico
On Fri, May 18, 2012 at 6:22 PM, xliiv wrote: > Like the topic, more details in followed links.. > > > http://stackoverflow.com/questions/10637450/how-to-hide-console-with-popen-on-windows As you've already been advised, the way to avoid a console is to use pythonw.exe (wh

Re: Daemonization / Popen / pipe issue

2012-03-21 Thread Lee Clemens
code below - but I get the same results (inconsistent termination, logs still match up as though everything worked fine. If I'm not in DAEMONIZE mode and hold down enter, I can get stdout from the Popen process too - which I have seen with and without the DaemonContext package. There seems to be

Re: Daemonization / Popen / pipe issue

2012-03-17 Thread Cameron Simpson
On 18Mar2012 12:35, John O'Hagan wrote: | On Sat, 17 Mar 2012 18:17:10 -0400 | Lee Clemens wrote: | > Is it generally not recommended to daemonize Python applications using | > this method? | | I'm no guru, but not that I know of. I haven't seen the os.fork method you use | before; out of inter

Re: Daemonization / Popen / pipe issue

2012-03-17 Thread John O'Hagan
On Sat, 17 Mar 2012 18:17:10 -0400 Lee Clemens wrote: > On 03/16/2012 11:37 PM, John O'Hagan wrote: > > On Fri, 16 Mar 2012 22:12:14 -0400 > > Lee Clemens wrote: > > > >> I have a multi-threaded application > >> > >> I have provided a test-case here: https://gist.github.com/2054194 > > I haven't

Re: Daemonization / Popen / pipe issue

2012-03-17 Thread Lee Clemens
On 03/16/2012 11:37 PM, John O'Hagan wrote: > On Fri, 16 Mar 2012 22:12:14 -0400 > Lee Clemens wrote: > >> I have a multi-threaded application >> >> I have provided a test-case here: https://gist.github.com/2054194 > I haven't looked at your test case yet, but a possible cause is the fact that > t

Re: Daemonization / Popen / pipe issue

2012-03-16 Thread John O'Hagan
On Fri, 16 Mar 2012 22:12:14 -0400 Lee Clemens wrote: > > I have a multi-threaded application, each thread has an instance of a class > which calls Popen. The command(s) being executed (shell=True) include pipes. > The errors I have seen involve "broken pipe" and

Daemonization / Popen / pipe issue

2012-03-16 Thread Lee Clemens
class which calls Popen. The command(s) being executed (shell=True) include pipes. The errors I have seen involve "broken pipe" and unexepected output (as demonstrated in the test case). This issues only seem to occur when the application is "daemonized", using a double-

SSL and os.system/Popen

2012-03-01 Thread Marek Lipert
Hi! I have a problem with SSL and threaded os.system (rewritten to Popen but still not working). First - the set-up: I am using windows 2003 server with current python 2.6. When new connection comes to my server-side application, i do accept, and then: self.client = ssl.wrap_socket

Re: Popen in main and subprocess

2012-01-28 Thread Thomas Rachel
Am 28.01.2012 11:19 schrieb pistacchio: the following code (in the main thread) works well, I grep some files and the search until the first 100 results are found (writing the results to a file), then exit: command = 'grep -F "%s" %s*.txt' % (search_string, DATA_P

Popen in main and subprocess

2012-01-28 Thread pistacchio
the following code (in the main thread) works well, I grep some files and the search until the first 100 results are found (writing the results to a file), then exit: command = 'grep -F "%s" %s*.txt' % (search_string, DATA_PATH) p = Popen(['/bin/bash',

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 04.08.2011 10:42 schrieb Chris Rebert: I was considering the more general case where one of the strings may have come from user input. You then need to also escape $looks_like_a_var, `some_command`, and way more other such stuff that your simple function doesn't cover. Even these things are

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 1:10 AM, Thomas Rachel wrote: > Am 03.08.2011 19:27 schrieb Chris Rebert: > >>>                     shell= True, >> >> I would strongly encourage you to avoid shell=True. > > ACK, but not because it is hard, but because it is unnecessary and unelegant > at this point. > >> Y

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 17:29 schrieb Phlip: Groupies: This is either a code snippet, if you like it, or a request for a critique, if you don't. Well, at first, I cannot see the real point about it... def command(*cmdz): process = Popen( flatten(cmdz), shell=

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 19:27 schrieb Chris Rebert: shell= True, I would strongly encourage you to avoid shell=True. ACK, but not because it is hard, but because it is unnecessary and unelegant at this point. You really don't want to have to worry about doing proper shell esca

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Terry Reedy
On 8/3/2011 11:29 AM, Phlip wrote: This is either a code snippet, if you like it, or a request for a critique, if you don't. A learning exercise but pretty useless otherwise. As others pointed out, immediately stripping off \n is a bug relative to *your* function description. Also, you yours

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Phlip
> flatten() being defined as...? Python Cookbook recipe 4.6 def flatten(sequence): # CONSIDER: Reconcile with utils... for item in sequence: if isinstance(item, (list, tuple)): for subitem in flatten(list(item)): yield subitem else: y

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Chris Rebert
s application-specifically > as possible. Anyone could think of a way to productize this: > > def command(*cmdz): > >    process = Popen( flatten(cmdz), flatten() being defined as...? >                     shell= True, I would strongly encourage you to avoid shell=True. You re

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Thomas Jollans
lication-specifically > as possible. Anyone could think of a way to productize this: > > def command(*cmdz): > > process = Popen( flatten(cmdz), > shell= True, > stdout= subprocess.PIPE, > stderr= subprocess.PIPE, &

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Peter Otten
s an object. And I want to do it as application-specifically > as possible. Anyone could think of a way to productize this: > > def command(*cmdz): > > process = Popen( flatten(cmdz), > shell= True, > stdout= subprocess.PIPE, &g

Re: How to catch a line with Popen

2011-05-31 Thread TheSaint
Chris Torek wrote: > Since it is a generator that only requests another line when called, > it should be fine Is it, then, that until the new itaration, the callee is on pause? -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: How to catch a line with Popen

2011-05-30 Thread Chris Torek
terminating -- in this case, after you force it to do so. >That looks good enough. I noted some little delay for the first lines, >mostly sure Popen assign some buffer even it is not set. According to the documentation, the default buffer size of Python 2 is 0, which is passed to fdopen()

Re: How to catch a line with Popen

2011-05-30 Thread TheSaint
Chris Torek wrote: > In at least some versions of Python 2 I'm with P3k :P. However thank you for your guidelines. Last my attempt was to use a *for* p.wait() , as mentioned earlier That looks good enough. I noted some little delay for the first lines, mostly sure Popen assign some buf

Re: How to catch a line with Popen

2011-05-29 Thread Chris Torek
In article TheSaint wrote: >Chris Rebert wrote: >I just suppose to elaborate the latest line, as soon it's written on the >pipe, and print some result on the screen. >Imaging something like > > p= Popen(['ping','-c40','www.google.com'], stdo

Re: How to catch a line with Popen

2011-05-29 Thread TheSaint
TheSaint wrote: > I just suppose to elaborate the latest line, as soon it's written on the > pipe, and print some result on the screen. I think some info is also here: http://alexandredeverteuil.blogspot.com/ -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: How to catch a line with Popen

2011-05-29 Thread TheSaint
Chris Rebert wrote: > What do you mean by "on-the-fly" in this context I just suppose to elaborate the latest line, as soon it's written on the pipe, and print some result on the screen. Imaging something like p= Popen(['ping','-c40','www.googl

Re: How to catch a line with Popen

2011-05-29 Thread Chris Rebert
On Sun, May 29, 2011 at 3:02 AM, TheSaint wrote: > Tim Roberts wrote: > >> Are you specifying a buffer size in the Popen command?  If not, then the >> Python side of things is unbuffered > > The buffer is as per default. The program reports one line around 1/2 second >

Re: How to catch a line with Popen

2011-05-29 Thread TheSaint
Tim Roberts wrote: > Are you specifying a buffer size in the Popen command? If not, then the > Python side of things is unbuffered The buffer is as per default. The program reports one line around 1/2 second time. I think I'll look into the option as Nobody states:

Re: How to catch a line with Popen

2011-05-28 Thread Dan Stromberg
ry line that prgram may blow > >during the process, but the output is given only when the child process is > >ended. > >I'd like to process the lines to display an information in percentage > during > >the running time of the child. > > Are you specifying a b

Re: How to catch a line with Popen

2011-05-28 Thread Tim Roberts
y when the child process is >ended. >I'd like to process the lines to display an information in percentage during >the running time of the child. Are you specifying a buffer size in the Popen command? If not, then the Python side of things is unbuffered. It's possible that the

Re: How to catch a line with Popen

2011-05-28 Thread Nobody
On Sun, 29 May 2011 00:01:56 +0800, TheSaint wrote: > I'm looking into subprocess.Popen docs. I've launch the program with its > arguments and that's smooth. I'm expecting to read the output by > *comunicate()* at every line that prgram may blow during the process, but > the output is given only w

How to catch a line with Popen

2011-05-28 Thread TheSaint
Hello. I'm looking into subprocess.Popen docs. I've launch the program with its arguments and that's smooth. I'm expecting to read the output by *comunicate()* at every line that prgram may blow during the process, but the output is given only when the child process is ended. I'd like to process

Re: Popen to get stdout and stderr for ffmpeg - No such file or directory ?

2011-04-18 Thread goldtech
> Read The Fine > Manual:http://docs.python.org/library/subprocess.html#subprocess.Popen: snip... > > Try instead: > cmd3 = ['ffmpeg', '-i', '/home/giga/Desktop/Guitar1.flv'] > > Cheers, > Chris > --http://blog.rebertia.com No doubt, I should RTFM...you're right! Yes, works like a charm now.

Re: Popen to get stdout and stderr for ffmpeg - No such file or directory ?

2011-04-18 Thread Rhodri James
On Tue, 19 Apr 2011 00:07:46 +0100, goldtech wrote: Trying to learn how to run a linux command and get the stdout and stderr. I'm trying the following: cmd3 = r'ffmpeg -i /home/giga/Desktop/Guitar1.flv' p = Popen(cmd3, stdout=PIPE, stderr=PIPE) Traceback (most recent cal

Re: Popen to get stdout and stderr for ffmpeg - No such file or directory ?

2011-04-18 Thread Chris Rebert
On Mon, Apr 18, 2011 at 4:07 PM, goldtech wrote: > Hi, > > Trying to learn how to run a linux command and get the stdout and > stderr. I'm trying the following: > >>>> cmd3 = r'ffmpeg -i /home/giga/Desktop/Guitar1.flv' >>>> p = Popen(cmd3, std

Popen to get stdout and stderr for ffmpeg - No such file or directory ?

2011-04-18 Thread goldtech
Hi, Trying to learn how to run a linux command and get the stdout and stderr. I'm trying the following: >>> cmd3 = r'ffmpeg -i /home/giga/Desktop/Guitar1.flv' >>> p = Popen(cmd3, stdout=PIPE, stderr=PIPE) Traceback (most recent call last): File "",

Re: How to get a PID of a child process from a process openden with Popen()

2011-04-08 Thread Chris Angelico
On Sat, Apr 9, 2011 at 5:28 AM, Nobody wrote: > There isn't a robust solution to the OP's problem. It's typically > impossible to determine whether one process is an ancestor of another if > any of the intermediate processes have terminated. Upstart and gdb can both detect forks and follow the ch

Re: How to get a PID of a child process from a process openden with Popen()

2011-04-08 Thread Nobody
On Fri, 08 Apr 2011 07:43:41 -0700, Miki Tebeka wrote: >> p = subprocess.Popen(shlex.split("kdesu -u test program")) >> >> How can I aquire the PID of the program which kdesu starts? > > You can run "ps --ppid " and get the line containing test program. > The first field there should be the

  1   2   3   4   5   >