[Tutor] What am I missing here?

Vũ Thanh Hải m at hvdev.cc
Fri Feb 11 22:42:14 EST 2022


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: www.hvdev.cc
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://nathantech.net 
 >  
 >  
 > _______________________________________________ 
 > Tutor maillist  - Tutor at python.org 
 > To unsubscribe or change subscription options: 
 > https://mail.python.org/mailman/listinfo/tutor 
 > 


More information about the Tutor mailing list