Skip to content

CPP input in python tutor #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2017
Merged

CPP input in python tutor #1

merged 1 commit into from
Jun 16, 2017

Conversation

amrondonp
Copy link
Member

@amrondonp amrondonp commented Jun 12, 2017

This changes allow the "run_cpp_backend.py" script to receive user input as a console parameter and use it as the stdin for the user code under execution.

valgrind debugger redirects stdin all the way to the user program, so, if we redirect the user input parameter into the debugger stdin it will be used as the stdin for the original problem

@0xDCA @larranaga @milderhc
Could you guys take a look at it?

Copy link

@larranaga larranaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if len(sys.argv) > 3:
if sys.argv[3] == '--prettydump':
prettydump = True
thrid_argument_is_input = (sys.argv[3] != '--prettydump')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Change to third_argument_is_input

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

prettydump = True
thrid_argument_is_input = (sys.argv[3] != '--prettydump')
if thrid_argument_is_input:
USER_INPUT = sys.argv[3]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I understand this well, but are you sending the entire STDIN in a command line argument? This seems inefficient and error-prone. For example, how do you make sure that the contents of the input are not interpreted as a fourth argument when you send it from the command line? IMHO a better approach is saving the input in a file, and sending the file name as a command-line argument

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Daniel, I also have this concern. However, it is the way that the author did initially with the user code and it also has spaces and special characters. Could you look a this file?https://github.com/JuezUN/OnlinePythonTutor/blob/cpp-input/v4-cokapi/cokapi.js#L243 I assumed this would be safe as the code is also sent via command line and it has a lot of spaces and special characters

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this input sent from?

@amrondonp amrondonp merged commit d0f8b6a into master Jun 16, 2017
@amrondonp amrondonp deleted the input-from-user branch June 16, 2017 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants