Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using an interactive program (e.g. python) under conch #32

Closed
holtzermann17 opened this issue Aug 23, 2016 · 1 comment
Closed

using an interactive program (e.g. python) under conch #32

holtzermann17 opened this issue Aug 23, 2016 · 1 comment

Comments

@holtzermann17
Copy link
Contributor

This seems related to #10, but as a specific example I wonder whether this can be made to work properly. I repeat the example from the docs to show that cat is working, but python behaves differently. Can an interactive program be made to work with Conch?

flowrweb.core=> (def p (sh/proc "cat"))
#'flowrweb.core/p
flowrweb.core=> (future (sh/stream-to-out p :out))
#future[{:status :pending, :val nil} 0x6e1e2ba]
flowrweb.core=> (sh/feed-from-string p "foo\n")
foo
nil
flowrweb.core=> (def py (sh/proc "python"))
#'flowrweb.core/py
flowrweb.core=> (future (sh/stream-to-out py :out))
#future[{:status :pending, :val nil} 0x5645b83]
flowrweb.core=> (sh/feed-from-string py "1+1\n")
nil
flowrweb.core=> (future (sh/stream-to-out py :err))
#future[{:status :pending, :val nil} 0x455548ec]
flowrweb.core=> (sh/feed-from-string py "1+1\n")
nil
flowrweb.core=> 
@holtzermann17
Copy link
Contributor Author

holtzermann17 commented Aug 24, 2016

Mainly, python needs to be called with the -i flag.

And there's at least one further confusing point, starting with (*) below.

(def sh-python (sh/proc "python" "-i"))
;=> #'flowrweb.core/sh-python
(future (sh/stream-to-out sh-python :out))      
#future[{:status :pending, :val nil} 0x24cf71f]
(sh/feed-from-string sh-python "1+1\n")
;=> 2
;=> nil
(def sh-python (sh/proc "python" "-i"))
;=> #'flowrweb.core/sh-python
(future (sh/stream-to-out sh-python :out))           ;;; (*) for e.g. numeric output
;=> #future[{:status :pending, :val nil} 0x24cf71f]
(future (sh/stream-to-out sh-python :err))           ;;; (*) for >>> decorations etc.
;=> Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
;=> [GCC 4.9.2] on linux2
;=> Type "help", "copyright", "credits" or "license" for more information.
;=> >>>
;=> #future[{:status :pending, :val nil} 0x2aea9bf0]
(sh/feed-from-string sh-python "1+1\n")
;=> >>> 2
;=> nil

Note in that output from both *err* and *out* is redirected to the *nrepl-server* buffer under CIDER; cf #1588 in the CIDER issue queue.

I think this may be helped on the Conch side from #31.

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant