public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* Python not reading result from bash command
@ 2015-11-23  9:02 Aaron Schneider
  2015-11-23  9:04 ` Aaron Schneider
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Schneider @ 2015-11-23  9:02 UTC (permalink / raw)
  To: cygwin-apps

Trying to read an argument as string, however doesn't work on python for cygwin. Tested on Python 3.5.0 (32-bit) from Python Software Foundation and works perfectly.

test.py:
import datetime
import sys
my_date = str(sys.argv[1])
temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")

$ python test.py $(adb shell 'su 0 date +"%Y%m%d%H%M%S"')
Traceback (most recent call last):
  File "test.py", line 32, in <module>
    temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")
  File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: 		 	   		  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Python not reading result from bash command
  2015-11-23  9:02 Python not reading result from bash command Aaron Schneider
@ 2015-11-23  9:04 ` Aaron Schneider
  2015-11-23  9:13   ` Marco Atzeri
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Schneider @ 2015-11-23  9:04 UTC (permalink / raw)
  To: cygwin-apps

> Subject: Python not reading result from bash command
>
> Trying to read an argument as string, however doesn't work on python for cygwin. Tested on Python 3.5.0 (32-bit) from Python Software Foundation and works perfectly.
>
> test.py:
> import datetime
> import sys
> my_date = str(sys.argv[1])
> temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")
>
> $ python test.py $(adb shell 'su 0 date +"%Y%m%d%H%M%S"')
> Traceback (most recent call last):
> File "test.py", line 32, in <module>
> temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")
> File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
> data_string[found.end():])
> ValueError: unconverted data remains:

I mean that works perfectly from Windows Powershell with official Python for windows. 		 	   		  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python not reading result from bash command
  2015-11-23  9:04 ` Aaron Schneider
@ 2015-11-23  9:13   ` Marco Atzeri
  2015-11-23  9:26     ` Aaron Schneider
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Atzeri @ 2015-11-23  9:13 UTC (permalink / raw)
  To: cygwin-apps



On 23/11/2015 10:04, Aaron Schneider wrote:
>> Subject: Python not reading result from bash command
>>
>> Trying to read an argument as string, however doesn't work on python for cygwin. Tested on Python 3.5.0 (32-bit) from Python Software Foundation and works perfectly.
>>
>> test.py:
>> import datetime
>> import sys
>> my_date = str(sys.argv[1])
>> temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")
>>
>> $ python test.py $(adb shell 'su 0 date +"%Y%m%d%H%M%S"')
>> Traceback (most recent call last):
>> File "test.py", line 32, in <module>
>> temp_date = datetime.datetime.strptime(some_date, "%Y%m%d%H%M%S")
>> File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
>> data_string[found.end():])
>> ValueError: unconverted data remains:
>
> I mean that works perfectly from Windows Powershell with official Python for windows. 		 	   		
>

what is adb ?

I suspect it is mainly pty communication (or lack of) between
cygwin and not cygwin programs.
See
   https://github.com/mintty/mintty/issues/56

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Python not reading result from bash command
  2015-11-23  9:13   ` Marco Atzeri
@ 2015-11-23  9:26     ` Aaron Schneider
  2015-11-23 15:03       ` cyg Simple
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Schneider @ 2015-11-23  9:26 UTC (permalink / raw)
  To: cygwin-apps

----------------------------------------
> Subject: Re: Python not reading result from bash command
>
> what is adb ?
>
> I suspect it is mainly pty communication (or lack of) between
> cygwin and not cygwin programs.
> See
> https://github.com/mintty/mintty/issues/56

adb is the Android Debugging Bridge. It's a command to communicate with any android smartphone and execute commands inside or get a results (kind of chroot+remote shell). So I'm trying to get the date of the device with that adb command and operate with it. I've checked the same exact bash command on Windows Powershell (%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe) and works perfectly the way I want it. Looks like the windows poweshell has some kind of bash+tools inside which are very powerful (much more than command.com which is the msdos tool and doesn't allow the bash syntax. 

I'll report the issue to MinTTY and see if they can look further into the issue. 		 	   		  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Python not reading result from bash command
  2015-11-23  9:26     ` Aaron Schneider
@ 2015-11-23 15:03       ` cyg Simple
  0 siblings, 0 replies; 5+ messages in thread
From: cyg Simple @ 2015-11-23 15:03 UTC (permalink / raw)
  To: cygwin-apps

On 11/23/2015 4:25 AM, Aaron Schneider wrote:
> ----------------------------------------
>> Subject: Re: Python not reading result from bash command
>>
>> what is adb ?
>>
>> I suspect it is mainly pty communication (or lack of) between
>> cygwin and not cygwin programs.
>> See
>> https://github.com/mintty/mintty/issues/56
> 
> adb is the Android Debugging Bridge. It's a command to communicate with any android smartphone and execute commands inside or get a results (kind of chroot+remote shell). So I'm trying to get the date of the device with that adb command and operate with it. I've checked the same exact bash command on Windows Powershell (%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe) and works perfectly the way I want it. Looks like the windows poweshell has some kind of bash+tools inside which are very powerful (much more than command.com which is the msdos tool and doesn't allow the bash syntax. 
> 
> I'll report the issue to MinTTY and see if they can look further into the issue. 		 	   		  
> 

If this is a PTY issue then MinTTY won't be able to help that I know of.
 Windows Powershell uses .NET objects for it's methods.  So if .NET can
do it so can Powershell.

The PTY issue has tried to be debugged to work with Cygwin -> Non-Cygwin
for years with no luck.  It's simply impossible ATM.

-- 
cyg Simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-23 15:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-23  9:02 Python not reading result from bash command Aaron Schneider
2015-11-23  9:04 ` Aaron Schneider
2015-11-23  9:13   ` Marco Atzeri
2015-11-23  9:26     ` Aaron Schneider
2015-11-23 15:03       ` cyg Simple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).