[Tutor] What am I missing here?

Nathan Smith nathan-tech at hotmail.com
Sat Feb 12 04:46:37 EST 2022


Hi there,


To be honest, I just didn't think of it, I just kind of used it by reflex.

Even changing it over to this has the same problem though:

for line in handle.stdout:

  process the line


Once I try and execute the python command, output just stops flowing.


Is there another pipe I should be capturing other than stdout and stderr?


Nathan

On 12/02/2022 03:42, Vũ Thanh Hải wrote:
> Hi Nathan,
>
> I'm just curious why are you using get_line? That might not work when some command line program requires interactive input.
>
>   >
>   > hi
>   >
>   > c:/users/user/documents
>   >
>   >
>   > In my GUI that path does not always show, but I'm assuming that's just
>   > because it doesn't throw in an extra empty blank line or some such?
>   >
>
> The path will not show itself because it is not part of STDOUT, I guess.
>
> Thanks and kind regards,
>
> Vu Thanh Hai
> Full-stack Developer
>
> -o-0_o-0-o_0-o-0_o-0-o-
>> Website: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.hvdev.cc%2F&data=04%7C01%7C%7C6e83aefb6ab24f7382aa08d9edd9ad02%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637802341428866342%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=kd9YLMdzAT97QjLQvYvMgZj8%2B8z%2FNii%2BsUN%2BHhHSUqA%3D&reserved=0
> Email: m at hvdev.cc
> Twitter: @hvhvdevdev
> GitHub: @hvhvdevdev
>
> ---- On Sat, 12 Feb 2022 09:38:58 +0700 Nathan Smith <nathan-tech at hotmail.com> wrote ----
>
>   > Hi List,
>   >
>   >
>   > I wrote a proof of concept program, it was supposed to be a more
>   > accessible command line for windows.
>   >
>   > Essentially it was just supposed to be a pretty gui for command line.
>   >
>   > To act as command line, I had:
>   >
>   > handle=subprocess.Popen("c:\\windows\\System32\\cmd.exe",
>   > stderr=subprocess.PIPE, stdout=subprocess.PIPE,
>   > stdin=subprocess.PIPE,creationflags = subprocess.CREATE_NO_WINDOW,,
>   > universal_newlines=True)
>   >
>   >
>   > Then I tthreaded while loops to read from stdout and stderr and put the
>   > contents into a text box, while anything entered into the other box got
>   > written to stdin and flushed
>   >
>   > Such as:
>   >
>   > line=get_line()
>   >
>   > handle.stdin.write(line+"\n")
>   >
>   > handle.stdin.flush()
>   >
>   >
>   > And it works. Kind of.
>   >
>   >
>   > Two places it does not work:
>   >
>   > 1 In command line, it always puts the current directory at the end of
>   > the execution of a command, eg
>   >
>   > dir:
>   >
>   > output
>   >
>   > c:/users/user/documents
>   >
>   > echo hi
>   >
>   > hi
>   >
>   > c:/users/user/documents
>   >
>   >
>   > In my GUI that path does not always show, but I'm assuming that's just
>   > because it doesn't throw in an extra empty blank line or some such?
>   >
>   >
>   > More to the point though, if I run python from my gui, it just doesn't
>   > show anything. No output, nothing. It's like it disconnects.
>   >
>   > Am I missing something?
>   >
>   > Even if the python command puts us into it's own command line, surely
>   > subprocess's stdout and stderr should capture the output?
>   >
>   >
>   > Thanks in advance for any help..
>   >
>   > Confused
>   >
>   > --
>   >
>   > Best Wishes,
>   >
>   > Nathan Smith, BSC
>   >
>   >
>   > My Website: https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnathantech.net%2F&data=04%7C01%7C%7C6e83aefb6ab24f7382aa08d9edd9ad02%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637802341428866342%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=D3r6zFeDD6x%2Bb7HuajzSOec%2B50q238wCVzzvX3O8lbA%3D&reserved=0
>   >
>   >
>   > _______________________________________________
>   > Tutor maillist  - Tutor at python.org
>   > To unsubscribe or change subscription options:
>   > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&data=04%7C01%7C%7C6e83aefb6ab24f7382aa08d9edd9ad02%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637802341428866342%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Orjnp4fPh2fv7J9rHlf%2BUYfSATqczLdlzPLf9jVBsAY%3D&reserved=0
>   >
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net




More information about the Tutor mailing list