Skip to content

Instantly share code, notes, and snippets.

@SevereOverfl0w
Created July 19, 2016 18:31
Show Gist options
  • Save SevereOverfl0w/4b173fad16e7d13b2210555604fda8f6 to your computer and use it in GitHub Desktop.
Save SevereOverfl0w/4b173fad16e7d13b2210555604fda8f6 to your computer and use it in GitHub Desktop.
Interacting with Figwheel via Python
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