Skip to content

Commit

Permalink
Modified pyth.py to redirect -d output to STDERR
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacg1 committed Sep 14, 2015
1 parent 7d1beab commit 7668e0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pyth.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,15 @@ def flag_on(short_form, long_form):

# Debug message
if debug_on:
print('{:=^50}'.format(' ' + str(len(pyth_code)) + ' chars '))
print(pyth_code)
print('='*50)
print('{:=^50}'.format(' ' + str(len(pyth_code)) + ' chars '), file=sys.stderr)
print(pyth_code, file=sys.stderr)
print('='*50, file=sys.stderr)

py_code_line = general_parse(pyth_code)

if debug_on:
print(py_code_line)
print('='*50)
print(py_code_line, file=sys.stderr)
print('='*50, file=sys.stderr)

if safe_mode:
# to fix most security problems, we will disable the use of
Expand Down
6 changes: 3 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def root():

def run_code(code_message, input_message, debug_on):
resp = ''

input_message += '\n'
pyth_code = '\n'.join(code_message.split("\r\n"))
pyth_process = \
Expand All @@ -41,7 +41,7 @@ def run_code(code_message, input_message, debug_on):

if code_message:
resp += output.decode() + (errors if errors else '')

return resp

@app.route('/submit', methods=['POST'])
Expand All @@ -58,7 +58,7 @@ def submit_test_suite():
input_size = int(request.form.get('input_size', '1'), 0)
inputs = ["\n".join(i) for i in zip(*[iter(request.form.get('input', '').split("\n"))]*input_size)]
debug_on = int(request.form.get('debug'), 0)

return Response("\n".join([run_code(code_message, inputs[0], debug_on)] + \
[run_code(code_message, i, False) for i in inputs[1:]]) if inputs else "")

Expand Down

0 comments on commit 7668e0c

Please sign in to comment.