Re: Running a subprocess in a venv

2023-10-21 Thread Mats Wichmann via Python-list
On 10/21/23 07:01, Larry Martell via Python-list wrote: I have a python script, and from that I want to run another script in a subprocess in a venv. What is the best way to do that? I could write a file that activates the venv then runs the script, then run that file, but that seems messy. Is

Re: Running a subprocess in a venv

2023-10-21 Thread Thomas Passin via Python-list
On 10/21/2023 11:32 AM, Larry Martell via Python-list wrote: On Sat, Oct 21, 2023 at 9:49 AM Johannes Findeisen wrote: On Sat, 21 Oct 2023 09:01:18 -0400 Larry Martell via Python-list wrote: I have a python script, and from that I want to run another script in a subprocess in a venv. What

Re: Running a subprocess in a venv

2023-10-21 Thread Larry Martell via Python-list
rry Martell via Python-list wrote: > > > > > > > I have a python script, and from that I want to run another > > > > script in a subprocess in a venv. What is the best way to do > > > > that? I could write a file that activates the venv then

Re: Running a subprocess in a venv

2023-10-21 Thread Johannes Findeisen via Python-list
I want to run another > > > script in a subprocess in a venv. What is the best way to do > > > that? I could write a file that activates the venv then runs the > > > script, then run that file, but that seems messy. Is there a > > > better way? > > > > H

Re: Running a subprocess in a venv

2023-10-21 Thread Larry Martell via Python-list
On Sat, Oct 21, 2023 at 9:49 AM Johannes Findeisen wrote: > > On Sat, 21 Oct 2023 09:01:18 -0400 > Larry Martell via Python-list wrote: > > > I have a python script, and from that I want to run another script in > > a subprocess in a venv. What is the best way to do t

Re: Running a subprocess in a venv

2023-10-21 Thread Roel Schroeven via Python-list
Larry Martell via Python-list schreef op 21/10/2023 om 15:01: I have a python script, and from that I want to run another script in a subprocess in a venv. What is the best way to do that? I could write a file that activates the venv then runs the script, then run that file, but that seems messy

Re: Running a subprocess in a venv

2023-10-21 Thread Johannes Findeisen via Python-list
On Sat, 21 Oct 2023 09:01:18 -0400 Larry Martell via Python-list wrote: > I have a python script, and from that I want to run another script in > a subprocess in a venv. What is the best way to do that? I could write > a file that activates the venv then runs the script, then run th

Running a subprocess in a venv

2023-10-21 Thread Larry Martell via Python-list
I have a python script, and from that I want to run another script in a subprocess in a venv. What is the best way to do that? I could write a file that activates the venv then runs the script, then run that file, but that seems messy. Is there a better way? -- https://mail.python.org/mailman

subprocess: TTYs and preexec_fn

2023-09-17 Thread Antonio Russo via Python-list
Hello! I'm trying to run a subprocess (actually several), and control their terminals (not just stdin and stdout). I have a use case, but I won't bore everyone with those details. I'd rather not use pexpect or ptyprocess, because those expose a very different interface than Pope

Re: Why does IDLE use a subprocess?

2023-05-31 Thread James Schaffler via Python-list
On Tuesday, May 30th, 2023 at 10:18 PM, Chris Angelico wrote: > Yep, what you're seeing there is the namespace and nothing else. But > if you mess with an actual builtin object, it'll be changed for the > other interpreter too. > > > > > import ctypes > > > > ctypes.cast(id(42), ctypes.POINTER(cty

Re: Why does IDLE use a subprocess?

2023-05-30 Thread Chris Angelico
On Wed, 31 May 2023 at 12:03, James Schaffler via Python-list wrote: > > On Tuesday, May 30th, 2023 at 9:14 PM, Greg Ewing wrote: > > Globals you create by executing code in the REPL have their own > > namespace. But everything else is shared -- builtins, imported > > Python modules, imported C ex

Re: Why does IDLE use a subprocess?

2023-05-30 Thread James Schaffler via Python-list
On Tuesday, May 30th, 2023 at 9:14 PM, Greg Ewing wrote: > Globals you create by executing code in the REPL have their own > namespace. But everything else is shared -- builtins, imported > Python modules, imported C extension modules, etc. etc. Thanks for the explanation. Could you elaborate on p

Re: Why does IDLE use a subprocess?

2023-05-30 Thread Greg Ewing via Python-list
CPython is structured makes that very difficult to achieve, and as far as I know it's not there yet. In the case of IDLE, there's really no reason not to use a subprocess[1]. It's easy and guarantees 100% isolation. [1] Well, mostly. There used to be a small hitch on Windows with the defa

Re: Why does IDLE use a subprocess?

2023-05-30 Thread Chris Angelico
On Wed, 31 May 2023 at 08:16, Barry wrote: > I don’t think it security but robustness that needs the subprocess. > > Also if your code use tk then it would conflict with idle’s use of tk. > From my memory, it's precisely this - it's much MUCH easier to allow you to use

Re: Why does IDLE use a subprocess?

2023-05-30 Thread Barry
uses > executes user code in a "subprocess" that's separate from the Python > interpreter that is running IDLE itself (which does tasks such as making the > window and coloring the text). > > As far as I understand, IDLE runs a modified version of > code.InteractiveIn

Why does IDLE use a subprocess?

2023-05-30 Thread James Schaffler via Python-list
Originally posted to idle-dev, but thought this might be a better place. Let me know if it isn't. Hi, I was curious about the internals of IDLE, and noticed that IDLE uses executes user code in a "subprocess" that's separate from the Python interpreter that is running IDL

Re: subprocess equivalent for "os.execvp()"?

2023-01-09 Thread Eryk Sun
On 1/9/23, c.bu...@posteo.jp wrote: > > On Python for Windows what is the appropriate way how a process can call > itself again? > > Let me give you an example [1]: > There is a project "bitcli" having two entry points > > [project.scripts] > bitcli = "bitcli.__main__:main" > bitcli-root = "bitcli

Re: subprocess equivalent for "os.execvp()"?

2023-01-09 Thread c . buhtz
Dear Eryk, Am 08.01.2023 17:22 schrieb Eryk Sun: Avoid using any of the `os.exec*` functions on Windows. There's no support for replacing a Windows process image, so the `exec*()` functions simply spawn a child process and terminate the current one. Thanks for bringing this up. On Python for

Re: subprocess equivalent for "os.execvp()"?

2023-01-08 Thread Eryk Sun
On 1/8/23, c.bu...@posteo.jp wrote: > > is there an equivalent in the subprocess module for "os.execvp()" to > replace the current process with the new called one? A note for Windows users Avoid using any of the `os.exec*` functions on Windows. There's no support for rep

Re: subprocess equivalent for "os.execvp()"?

2023-01-08 Thread Chris Angelico
On Sun, 8 Jan 2023 at 21:51, wrote: > > Hello, > > is there an equivalent in the subprocess module for "os.execvp()" to > replace the current process with the new called one? It won't make a subprocess, so no. It's in the os module - under the name exec

subprocess equivalent for "os.execvp()"?

2023-01-08 Thread c.buhtz
Hello, is there an equivalent in the subprocess module for "os.execvp()" to replace the current process with the new called one? Kind Christian -- https://mail.python.org/mailman/listinfo/python-list

Re: when I open a python idle it's constantly showing subprocess connection error

2022-09-20 Thread Mats Wichmann
On 9/20/22 09:36, asika wrote: Sent from [1]Mail for Windows References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 dunno if you were trying to send screenshots or something, that doesn't work here. Try: https://docs.python.org/3/libra

when I open a python idle it's constantly showing subprocess connection error

2022-09-20 Thread asika
    Sent from [1]Mail for Windows   References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting the exit code of a subprocess

2021-12-15 Thread Jason
On Wed, Dec 15, 2021 at 08:19:16PM -0800, Kushal Kumaran wrote: > On Wed, Dec 15 2021 at 09:38:48 PM, Jason wrote: > > Hello, > > > > How can I find out the exit code of a process when using the > > subprocess module? I am passing an email message to a shell script and

Re: Getting the exit code of a subprocess

2021-12-15 Thread Kushal Kumaran
On Wed, Dec 15 2021 at 09:38:48 PM, Jason wrote: > Hello, > > How can I find out the exit code of a process when using the > subprocess module? I am passing an email message to a shell script and > I need to know whether the shell script threw an error. > > Here is my

Getting the exit code of a subprocess

2021-12-15 Thread Jason
Hello, How can I find out the exit code of a process when using the subprocess module? I am passing an email message to a shell script and I need to know whether the shell script threw an error. Here is my code: p = Popen(cmd, stdout=None, stdin=PIPE, stderr=None) p.communicate(input=msg) I

Re: Subprocess Connection error

2021-11-23 Thread Dan Stromberg
ext of any error messages you get. BTW, it's important to cut and paste TEXT - don't just send screenshots. Good luck. On Tue, Nov 23, 2021 at 8:03 AM wrote: >Hello, > > > >I have been 3.8.10 version of python until I ran the code for tkinter > and >

Subprocess Connection error

2021-11-23 Thread nuu.05.05
Hello,   I have been 3.8.10 version of python until I ran the code for tkinter and I started getting subprocess connection error. After this I haven’t been able to open python for use as I get this error upon startup.   Please help resolve the matter soon.   Best

Re: Subprocess Connection Error

2020-10-17 Thread Greg Ewing
On 17/10/20 4:04 pm, Dave Dungan wrote: One more thing, the book says to save it as "types.py". Which is probably a bad thing to do, because there is a built-in module called "types" that this will shadow. If IDLE happens to use that module, bad things could happen. Have you tried using a diff

Re: Subprocess Connection Error

2020-10-17 Thread Terry Reedy
On 10/17/2020 5:00 PM, Dan Stromberg wrote: Does this help? https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start I believe I included every legitimate answer on stackoverflow, including that post, in the doc section linked

Re: Subprocess Connection Error

2020-10-17 Thread Dan Stromberg
Does this help? https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start On Sat, Oct 17, 2020 at 12:44 PM Dave Dungan via Python-list < python-list@python.org> wrote: > Hello, > > I bought a book called Coding f

Subprocess Connection Error

2020-10-17 Thread Dave Dungan via Python-list
Hello, I bought a book called Coding for Beginners to learn how to code using Python. The first few exercises went fine. When I got to the page called Recognizing types and did the exercise and saved it and tried to run the module it comes up with a Subprocess Connection Error. It says

ANN: Version 0.1.6 of sarge (a subprocess wrapper library) has been released.

2020-08-24 Thread Vinay Sajip via Python-list
Version 0.1.6 of Sarge, a cross-platform library which wraps the subprocess module in the standard library, has been released. What changed? - - Fixed #44: Added an optional timeout to Command.wait() and Pipeline.wait(), which   only takes effect on Python >= 3.3. - Fixed

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: python3 subprocess run sudo cmd in remote failed

2019-09-17 Thread Eli the Bearded
In comp.lang.python, lampahome wrote: > what I tried many times like enter password, but it failed. > I just want to use ps.stdin.write(password) to send password, but it always > jump password prompt immediately. Passwords are frequently read from stderr, not stdin, so that tools can get a huma

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Chris Angelico
On Tue, Sep 17, 2019 at 3:25 PM Cameron Simpson wrote: > However, I repeat my recommendation to use a keypair for the > authentication, as it avoids needing interactive passwords (and having > your programme know the password has its own suite of problems to do > with where that password comes fro

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Cameron Simpson
urity (having a terminal is a proxy for "talking to a human"), and partly because ssh normally passes stdin to the remote process once authentication is complete, so things get fiddly. You can give it a terminal by obtaining a pty and associating the subprocess with that. You could inst

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread lampahome
he far > end either. You can get ssh to open a remote tty with the -t option. > > But I suspect you don't want stdin=PIPE or stdout=PIPE at all. Why are > they there? > > I thought I can use ps.stdin.write(password), so I make stdin and stdout be pipe as input and output.

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Cameron Simpson
On 17Sep2019 12:13, lampahome wrote: Hello, I use python3.5 and found no way to solve this problem from subprocess import Popen, PIPE ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello@192.168.80.11 \'sudo sysctl -w vm.drop_caches=3\', stdin=PIPE, stdout=PIP

python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread lampahome
Hello, I use python3.5 and found no way to solve this problem >from subprocess import Popen, PIPE >ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello@192.168.80.11 \'sudo sysctl -w vm.drop_caches=3\', stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=0, shell

Async subprocess context manager

2019-09-01 Thread Peter Sutton
Hi all, First time posting! I need an async context manager that ensures a Process has finished before it `__exit__()`s, either by graceful or forceful termination, and regardless of cancellation. I've put my code at the bottom. I'm relatively new to asyncio, so I'm looking for feedback on any as

Re: Subprocess

2019-06-17 Thread Terry Reedy
On 6/17/2019 11:36 AM, Terry Reedy wrote: On 6/14/2019 11:09 AM, Douglas Beard via Python-list wrote: Error: IDLE's Subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall is blocking the connection.python has been working fine until to

Re: Subprocess

2019-06-17 Thread Terry Reedy
On 6/14/2019 11:09 AM, Douglas Beard via Python-list wrote: Error: IDLE's Subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall is blocking the connection.python has been working fine until today. I used the python repair but no luck. it do

Subprocess

2019-06-17 Thread Douglas Beard via Python-list
Error: IDLE's Subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall is blocking the connection.python has been working fine until today. I used the python repair but no luck. it does not seem my firewall is blocking. please help -- https://

Re: Where is getstatusoutput() in subprocess module?

2019-05-03 Thread MRAB
ed to the subprocess module. Where are they? Here: https://docs.python.org/3/library/subprocess.html#subprocess.getstatusoutput -- https://mail.python.org/mailman/listinfo/python-list

Re: Where is getstatusoutput() in subprocess module?

2019-05-03 Thread Grant Edwards
utput() have been moved to the subprocess > module. > > Where are they? Doh, never mind. They were only moved in Python3. I didn't realize that the "In Python 3.x" qualifier from the beginning of the previous sentence applied to the entire paragraph. -- Grant Edwards

Where is getstatusoutput() in subprocess module?

2019-05-03 Thread Grant Edwards
I'm trying to update a python2 app to make it python3 compatible. It uses commands.getstatusoutput(), which according to https://docs.python.org/2/library/commands.html#commands.getstatusoutput ... getstatusoutput() and getoutput() have been moved to the subprocess module. Where are

Re: running "python -i" in subprocess shows no prompt

2019-03-19 Thread finnkochinski
uot;license" for more information. >>> >1 >> 4 >>> 9 >>> 1>>> 6 > I found that the pty module might be a solution, also from the helpful comments in this thread, but I can't find a simple example how to make it work. regards Finn This is my l

Re: running "python -i" in subprocess shows no prompt

2019-03-18 Thread Terry Reedy
On 3/18/2019 9:10 AM, finnkochin...@keemail.me wrote: I try to start a separate python subprocess using the attached code. This example should catch all stdout and stderr output from the launched subprocess and send commands to its stdin. Subprocess is not intended for interaction. My

Re: subprocess svn checkout password issue

2019-03-18 Thread Barry
> On 15 Mar 2019, at 22:17, Martin De Kauwe wrote: > > Hi, > > I'm trying to write a script that will make a checkout from a svn repo and > build the result for the user. However, when I attempt to interface with the > shell it asks the user for their filename and I don't know how to captur

Re: running "python -i" in subprocess shows no prompt

2019-03-18 Thread Grant Edwards
On 2019-03-18, wrote: > I try to start a separate python subprocess using the attached > code. This example should catch all stdout and stderr output from > the launched subprocess and send commands to its stdin. The problem > is that the prompt ">>>" asking for

Re: running "python -i" in subprocess shows no prompt

2019-03-18 Thread Chris Angelico
On Tue, Mar 19, 2019 at 2:50 AM wrote: > > Hello, > I try to start a separate python subprocess using the attached code. This > example should catch all stdout and stderr output from the launched > subprocess and send commands to its stdin. > The problem is that the prompt &qu

running "python -i" in subprocess shows no prompt

2019-03-18 Thread finnkochinski
Hello, I try to start a separate python subprocess using the attached code. This example should catch all stdout and stderr output from the launched subprocess and send commands to its stdin. The problem is that the prompt ">>>" asking for then next input is neither sent to s

Re: subprocess svn checkout password issue

2019-03-16 Thread Michael Torrie
ut. That allowed their use in a pipeline > without contaminating the pipe's data with the password prompt and > password. In "normal" usage /dev/tty and stdin/stdout/stderr are all > the same device, but when used via a library like subprocess, you > couldn't provide

Re: subprocess svn checkout password issue

2019-03-16 Thread Grant Edwards
On 2019-03-16, dieter wrote: > Otherwise, you must monitor what it written to the subprocess' > "stdout" and "stderr", recognized the interaction request > perform the interaction with the user and send the result > to the subprocess' stdin. I don'

Re: subprocess svn checkout password issue

2019-03-16 Thread Dan Sommers
ration file. Otherwise, you must monitor what it written to the subprocess' "stdout" and "stderr", recognized the interaction request perform the interaction with the user and send the result to the subprocess' stdin. Thanks, I think this solution will work. import s

Re: subprocess svn checkout password issue

2019-03-15 Thread Martin De Kauwe
; > approach, would be much appreciated. I need to solve this with standard > > python libs as I'm trying to make this as simple as possible for the user. > > That is non-trivial. > > Read the "svn" documentation. You might be able to pass in the > required informatio

Re: subprocess svn checkout password issue

2019-03-15 Thread dieter
Read the "svn" documentation. You might be able to pass in the required information by other means, maybe an option, maybe an envvar, maybe via a configuration file. Otherwise, you must monitor what it written to the subprocess' "stdout" and "stderr", recognized the interaction request perform the interaction with the user and send the result to the subprocess' stdin. -- https://mail.python.org/mailman/listinfo/python-list

subprocess svn checkout password issue

2019-03-15 Thread Martin De Kauwe
Hi, I'm trying to write a script that will make a checkout from a svn repo and build the result for the user. However, when I attempt to interface with the shell it asks the user for their filename and I don't know how to capture this with my implementation. user = "XXX578" root="https://trac

Re: Multiprocessing vs subprocess

2019-03-13 Thread oliver
subprocess: subprocess is limited to pipes (unless you build your own alternate comms mechanism), whereas multiprocessing takes care of marshalling python objects and transporting them to the other processes. This can be huge in some applications, like we were using it to run batch monte carlo

RE: Multiprocessing vs subprocess

2019-03-12 Thread Schachner, Joseph
s are launched independent of the parent (manager) process?" I just want to point out that subprocess (which uses the operating system to start another processes, to run whatever you say - doesn't have to be Python running another script, can be an .exe) does not have that restriction. The

Re: Multiprocessing vs subprocess to run Python scripts in parallel

2019-03-12 Thread Chris Angelico
ipts may end > up running in parallel. There are no dependencies between individual worker > scripts. I'm looking for the pros and cons of using multiprocessing or > subprocess to launch these worker scripts. Looking for a solution that works > across Windows and Linux. Open to usin

Multiprocessing vs subprocess to run Python scripts in parallel

2019-03-12 Thread Malcolm Greene
individual worker scripts. I'm looking for the pros and cons of using multiprocessing or subprocess to launch these worker scripts. Looking for a solution that works across Windows and Linux. Open to using a 3rd party library. Hoping to avoid the use of yet another system component like Cele

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
r". > > > > ChrisA > > Yeah, and once you find out you need to go faster and subsequently start > looking into ways you *can* go faster, you finally end up with code similar > to what is implemented in the grep family of tools. > Maybe... but most likely not using

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
info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : The Code executes but the output is in screen and does not get stored in a variable. I am interested if I can achieve the same result with subp

Error while calling a subprocess and execute another script from one py file

2018-12-30 Thread sandeep . bayi6
uot; " in arg) or ("\t" in arg) or not arg TypeError: argument of type 'module' is not iterable -- > I'm currently facing this error while execute another py_script from one > script. > and i

Re: Issue in parsing the string output from the command using "subprocess"

2018-11-18 Thread srinivasan
gt; On 2018-11-18 14:59, srinivasan wrote: > > Dear Python Experts Team, > > > > As am newbie to python and learning python, working on embedded linux > > platform, my intention is to delete all the SSID's before connecting my > > Wi-Fi module to specific SSID.,

Re: Issue in parsing the string output from the command using "subprocess"

2018-11-18 Thread MRAB
g the "subprocess" with wrapper "execute_cmd_output_string" written on it described as below, using the nmcli commands "*nmcli -t -f TYPE,UUID con" and "**"nmcli connection delete uuid ".* Could you please help me, what could be the bug in the below met

Issue in parsing the string output from the command using "subprocess"

2018-11-18 Thread srinivasan
Dear Python Experts Team, As am newbie to python and learning python, working on embedded linux platform, my intention is to delete all the SSID's before connecting my Wi-Fi module to specific SSID., I am trying to parse command output using the "subprocess"

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-12 Thread Chris Angelico
On Mon, Nov 12, 2018 at 11:20 PM Anssi Saari wrote: > > Chris Angelico writes: > > > On Fri, Nov 9, 2018 at 11:11 PM Anssi Saari wrote: > >> > >> Chris Angelico writes: > >> > >> > No helper needed. Safe against command injection. Uses the known > >> > format of the command's output; if you wan

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-12 Thread Anssi Saari
ell >> > as the type, you could get that too. >> >> Can someone let me in on this secret helper module? Doesn't seem to >> match the helper module in PyPI at least. >> > > What helper? Helper module used in the original post. I assumed you know what it

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Cousin Stanley
srinivasan wrote: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="1084

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Chris Angelico
oo. > > Can someone let me in on this secret helper module? Doesn't seem to > match the helper module in PyPI at least. > What helper? I said you don't need one. Just use subprocess directly. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Anssi Saari
Chris Angelico writes: > No helper needed. Safe against command injection. Uses the known > format of the command's output; if you want other information as well > as the type, you could get that too. Can someone let me in on this secret helper module? Doesn't seem to match the helper module in

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Many Thanks a lot , I can use for reliably "lsblk %s -n -o FSTYPE" in the reused code of mine as below cmd = "lsblk %s -n -o FSTYPE" % partition_path return self._helper.execute_cmd_output_string(cmd) I really appreciate for all your support w.r.t this.. I feel I have kick start

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Ben Bacarisse
srinivasan writes: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="108

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:42 PM srinivasan wrote: > > Some I managed to fix temporarily as below, might be useful for others. Also > please correct me if anything wrong or for any improvements in the below > > cmd = "blkid -o export %s" % partition_path > out = self._helper.execut

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Some I managed to fix temporarily as below, might be useful for others. Also please correct me if anything wrong or for any improvements in the below cmd = "blkid -o export %s" % partition_path out = self._helper.execute_cmd_output_string(cmd) var = out.split("TYPE=", 1)[1]

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:36 PM Qian Cai wrote: > > srinivasan wrote: > > Even after changing as per the below > > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > > or: > > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > > or: > > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" >

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Qian Cai
srinivasan wrote: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="1084

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Even after changing as per the below "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" or: 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' or: "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" Still my output is: */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* My expected outp

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Brian J. Oney via Python-list
On Wed, 2018-11-07 at 10:22 +0100, srinivasan wrote: > blkid -o export %s | grep \'TYPE\' | cut -d\"=\" -f3 You don't need to escape the single quotes. Try either: "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" or: 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' or: "blkid -o export %s | g

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
x27;TYPE' | cut -d" > and BETA=" -f3" > > Other issues may also be there. > -Original Message- > From: Tutor On Behalf Of > Alan Gauld via Tutor > Sent: Tuesday, November 6, 2018 7:37 PM > To: tu...@python.org > Cc: python-...@python.org > Subje

Re: SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-06 Thread Rhodri James
On 06/11/2018 18:10, srinivasan wrote: root:~/qa/test_library# python3 sd.py File "sd.py", line 99 *cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)* * ^* *SyntaxError: can't assign to literal* Look at the 'cut' element of the pipeline. You have used double quotes

SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-06 Thread srinivasan
Dear Python Experts Team, As am newbie to python development, I am trying to use the below function to get verify the filesystem type of the SD card parition using bash command in python using subprocess module, I ma seeing the below Error "SyntaxError: can't assign to liter

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-03 Thread Chris Angelico
gt;> well be able to get something that works well enough for your specific >>> needs - but it's not obvious from your snippet of code what you're >>> trying to achieve). >> >> To send and receive text from a subprocess..even when there are exceptions. >

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-03 Thread Oscar Benjamin
it's not obvious from your snippet of code what you're >> trying to achieve). > > To send and receive text from a subprocess..even when there are exceptions. You can do this without threads on Linux using select (or similar): https://docs.python.org/3.7/library/select.html#select.select -- Oscar -- https://mail.python.org/mailman/listinfo/python-list

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Terry Reedy
On 8/2/2018 3:52 PM, cseber...@gmail.com wrote: subprocess is not meant for interaction through the pipes. That is why, I have been told, IDLE uses a socket for interaction. Multiprocess is apparently better suited for interaction without resorting to a socket. So use normal socket on

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Paul Moore
;re > > trying to achieve). > > To send and receive text from a subprocess..even when there are exceptions. For an arbitrary program as the subprocess? You need some sort of threading in your process, or maybe some sort of async processing with non-blocking reads/writes, as you cannot as

  1   2   3   4   5   6   7   8   9   10   >