well, you have to put that man-in-the-middle communicate() or something
similar: reading the pipes and redirecting the output to their local
counterparts. btw, you might also want to check out plumbum for this use
case: http://plumbum.readthedocs.org/en/latest/

as for the second version,

proc = conn.modules.subprocess.Popen("ls", stdout = sys.stdout, stderr
= sys.stdin)

it won't work because rpyc can't fool the OS. internally, popen dup()s the
file handles and does the necessary witchcraft for pipe redirection (which
is different under windows, but still involves the OS). the objects you
passed are files in the local process, but only proxies to files in the
remote side. the actual error you get is meaningless, the problem is it's
simply not possible.



-tomer

-----------------------------------------------------------------

*Tomer Filiba*
tomerfiliba.com     <http://www.facebook.com/tomerfiliba>
<http://il.linkedin.com/in/tomerfiliba>


On Fri, Jul 18, 2014 at 12:17 AM, Tony Cappellini <[email protected]>
wrote:

>
> Would someone point me to a better example of redirection stdio-
> so that I don't need to do this?
>
> proc = conn.modules.subprocess.Popen("ls", stdout = -1, stderr = -1)stdout, 
> stderr = proc.communicate()print stdout.split()
>
>
> http://rpyc.readthedocs.org/en/latest/docs/classic.html#classic
>
> If we are running a script on another machine, having to do
>
> stdout, stderr = proc.communicate()print stdout.split()
>
> is not very helpful.
>
> Ideally, what the user experiences on the remote machine, should
>
> be seen on the local machine.
>
> For some reason,
>
> proc = conn.modules.subprocess.Popen("ls", stdout = sys.stdout, stderr = 
> sys.stdin)
>
> causes a terrible exception.
>
> I don't understand this
>
> >>>
> proc=conn.modules.subprocess.Popen("dir",stdout=sys.stdout,stderr=sys.stderr)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\Python27\Lib\site-packages\rpyc\core\netref.py", line 196, in
> __call__
>     return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
>   File "C:\Python27\Lib\site-packages\rpyc\core\netref.py", line 71, in
> syncreq
>     return conn.sync_request(handler, oid, *args)
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 441, in
> sync_request
>     raise obj
> AttributeError: 'file' object has no attribute '__eq__'
>
> ========= Remote Traceback (2) =========
> Traceback (most recent call last):
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 305, in
> _dispatch_request
>     res = self._HANDLERS[handler](self, *args)
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 535, in
> _handle_call
>     return self._local_objects[oid](*args, **dict(kwargs))
>   File "C:\Python27\lib\subprocess.py", line 701, in __init__
>     errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr)
>   File "C:\Python27\lib\subprocess.py", line 842, in _get_handles
>     elif stdout == PIPE:
>   File "C:\Python27\Lib\site-packages\rpyc\core\netref.py", line 210, in
> method
>     return syncreq(_self, consts.HANDLE_CALLATTR, name, args, kwargs)
>   File "C:\Python27\Lib\site-packages\rpyc\core\netref.py", line 71, in
> syncreq
>     return conn.sync_request(handler, oid, *args)
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 441, in
> sync_request
>     raise obj
> AttributeError: 'file' object has no attribute '__eq__'
>
> ========= Remote Traceback (1) =========
> Traceback (most recent call last):
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 305, in
> _dispatch_request
>     res = self._HANDLERS[handler](self, *args)
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 547, in
> _handle_callattr
>     return self._handle_getattr(oid, name)(*args, **dict(kwargs))
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 541, in
> _handle_getattr
>     return self._access_attr(oid, name, (), "_rpyc_getattr",
> "allow_getattr", getattr)
>   File "C:\Python27\Lib\site-packages\rpyc\core\protocol.py", line 507, in
> _access_attr
>     return accessor(obj, name, *args)
> AttributeError: 'file' object has no attribute '__eq__'
>
>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "rpyc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to