Rewrote retry loop in execute.py
This commit is contained in:
parent
8ef57a6250
commit
47b7836088
2 changed files with 12 additions and 11 deletions
|
@ -1,14 +1,19 @@
|
||||||
import http, web
|
import http, web
|
||||||
import json, urllib2, sys
|
|
||||||
|
|
||||||
|
|
||||||
def eval_py(code, paste_multiline=True):
|
def eval_py(code, paste_multiline=True):
|
||||||
|
attempts = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n')
|
try:
|
||||||
if output:
|
output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n')
|
||||||
break
|
except http.HTTPError:
|
||||||
else:
|
if attempts > 2:
|
||||||
pass
|
return "Failed to execute code."
|
||||||
|
else:
|
||||||
|
attempts += 1
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
|
||||||
if "Traceback (most recent call last):" in output:
|
if "Traceback (most recent call last):" in output:
|
||||||
status = "Python error: "
|
status = "Python error: "
|
||||||
|
|
|
@ -6,7 +6,7 @@ import urllib
|
||||||
import urllib2
|
import urllib2
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from urllib import quote as _quote, quote_plus as _quote_plus
|
from urllib import quote, quote_plus as _quote_plus
|
||||||
|
|
||||||
from lxml import etree, html
|
from lxml import etree, html
|
||||||
|
|
||||||
|
@ -99,10 +99,6 @@ def quote_plus(s):
|
||||||
return _quote_plus(to_utf8(s))
|
return _quote_plus(to_utf8(s))
|
||||||
|
|
||||||
|
|
||||||
def quote(s):
|
|
||||||
return _quote(to_utf8(s))
|
|
||||||
|
|
||||||
|
|
||||||
def unescape(s):
|
def unescape(s):
|
||||||
if not s.strip():
|
if not s.strip():
|
||||||
return s
|
return s
|
||||||
|
|
Reference in a new issue