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
changed if-else with better return statement in server.py
  • Loading branch information
sahilshekhawat committed Jun 18, 2015
commit 5d995804cdc9efda4f14aaa550d2b30ae7899727
8 changes: 2 additions & 6 deletions pydy/viz/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class Server(object):

"""
def __init__(self, scene_file, directory=None, port=None):
if scene_file:
self.scene_file = scene_file
self.scene_file = scene_file
Copy link
Member

Choose a reason for hiding this comment

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

My suggestion in the previous commit was to have this call sig:

def __init__(scene_file, directory=None, port=8000)

The scene file should be required and the directory can default to the cwd if None is passed in.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add that in my new pr on static directory creation. Trying to make it atomic

Copy link
Member

Choose a reason for hiding this comment

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

But this is a whole new server code. It seems atomic to add this.


if directory:
Copy link
Contributor

Choose a reason for hiding this comment

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

Comparisons to singletons like None should always be done with is or is not:
if directory is not None

self.directory = directory
Expand Down Expand Up @@ -110,10 +109,7 @@ def run_server(self):
def _check_port(self, port):
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = soc.connect_ex(('127.0.0.1', port))
if result == 0:
return True
else:
return False
return result == 0

def _stop_server(self, signal, frame):
"""
Expand Down