Skip to content
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

Added shutting down calls to the visualization server #241

Merged
merged 13 commits into from
Jun 18, 2015
Merged
Prev Previous commit
Next Next commit
Fixed response string on server exit
  • Loading branch information
sahilshekhawat committed Jun 17, 2015
commit d2d4940ebfeba7898f1aa6ae5942f33ec2f19c9f
4 changes: 3 additions & 1 deletion pydy/viz/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import os
import sys
import signal
import socket
import webbrowser
Expand Down Expand Up @@ -103,7 +104,8 @@ def _stop_server(self, signal, frame):

"""
res = raw_input("Shutdown this visualization server ([y]/n)? ")
Copy link
Member

Choose a reason for hiding this comment

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

This will fail in Python 3. Oliver had the fix for this in this file before this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

What are the options then, should I use input()?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it!

if res.lower()[0:1] is (None or 'y'):
res = res.lower()[0:1]
Copy link
Contributor

Choose a reason for hiding this comment

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

res.lower()[0] can be used instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup! changing.

if res == '' or res == 'y':
Copy link
Member Author

Choose a reason for hiding this comment

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

This works even for strings like "Yes"

print("Shutdown confirmed")
print("Shutting down server...")
self.httpd.stop()
Expand Down