Created
July 19, 2016 18:31
-
-
Save SevereOverfl0w/4b173fad16e7d13b2210555604fda8f6 to your computer and use it in GitHub Desktop.
Interacting with Figwheel via Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
basedir = os.path.dirname(os.path.realpath(__file__)) | |
sys.path.append(os.path.join(basedir, "nrepl_python_client/")) | |
import nrepl | |
conn = nrepl.connect("nrepl://127.0.0.1:35243") | |
# Create a session | |
conn.write({"op": "clone"}) | |
session = conn.read().get('new-session') | |
# Start figwheel repl | |
conn.write({ | |
"op": "eval", | |
"file": "dev/user.clj", | |
"code": "(browser-repl)", | |
"session": session | |
}) | |
## Read all the lines from figwheel | |
x = conn.read() | |
while x.get('status', '') != ['done']: | |
print(x) | |
x = conn.read() | |
print("> Writing the source code") | |
conn.write({ | |
"op": "eval", | |
"code": "(cljs.repl/source uuid)", | |
"session": session | |
}) | |
x = conn.read() | |
while x.get('status', '') != ['done']: | |
print(x) | |
x = conn.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment