Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanups, make coqd not require json by default. add code to interp
- Loading branch information
Showing
7 changed files
with
78 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
Goal True -> True. | ||
>>> | ||
""" | ||
from urllib import urlencode | ||
|
||
import re | ||
import markdown | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
from code import InteractiveConsole | ||
from argparse import ArgumentParser | ||
from json import JSONDecoder, JSONEncoder | ||
import readline | ||
import logging | ||
from sys import argv | ||
import telnetlib | ||
|
||
|
||
def send(command): | ||
def send(command, serialize): | ||
try: | ||
tn = telnetlib.Telnet('localhost', 8003) | ||
tn.write(JSONEncoder().encode(dict(userid=0, | ||
command=command))) | ||
proofst = JSONDecoder().decode(tn.read_all()) | ||
proofst = proofst.get('response', None) | ||
if serialize: | ||
proofst = JSONDecoder().decode(tn.read_all()) | ||
proofst = proofst.get('response', None) | ||
else: | ||
proofst = tn.read_all() | ||
print proofst | ||
except Exception: | ||
logging.error("Connection to coqd failed") | ||
|
||
while True: | ||
try: | ||
prompt = raw_input(">>> ") | ||
send(prompt) | ||
except: | ||
pass | ||
|
||
def options(parser): | ||
parser.add_argument("--serialize", action="store_true", | ||
default=False, | ||
help="Serialize output to JSON") | ||
return parser | ||
|
||
|
||
def main(): | ||
""" | ||
Setup and run coqd | ||
""" | ||
parser = ArgumentParser(prog="Coqd", description="Options for Coqd", | ||
version="Coqd 0.1") | ||
parser = options(parser) | ||
opts = parser.parse_args(argv[1:]) | ||
|
||
while True: | ||
try: | ||
prompt = raw_input(">>> ") | ||
send(prompt, opts.serialize) | ||
except: | ||
pass | ||
|
||
if __name__ == '__main__': | ||
main() |
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