-
Notifications
You must be signed in to change notification settings - Fork 12
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
Issue #110 - Made GUI port optionally configurable #120
Issue #110 - Made GUI port optionally configurable #120
Conversation
Instead of defaulting to port 8080, the ait gui should now look at the ait config and pull the defined gui.port number from there if its defined. If it is not defined, then it will use the default of 8080. All of which gets overwritten if the user provided a port number to the init method
Hey @robschneider16, thanks for the pull request. The changes here definitely cover the functionality we need but there's a bit of a change in our config layout now that we've switched over to the new server architecture. The
Here, Thoughts? |
Action requested from the PR review. Moved the port argument to the plugin class init as a kwarg with a default to port 8080. Kwarg gets populated based on whats defined in config.yaml.
Instead of passing in the values to the GUIs self.init method, the init method will see if the plugin has the port and host items defined as attributes.
ait/gui/__init__.py
Outdated
@@ -255,7 +255,14 @@ def handle(pathname): | |||
def handle(pathname): | |||
return bottle.static_file(pathname, root=HTMLRoot.User) | |||
|
|||
if host is None: | |||
if hasattr(self, 'port'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that it's not a problem in this instance but we should avoid hasattr
in 2.x in my opinion. Of course, we're moving to 3.x shortly and it won't matter at all but sticking with try ... except
here in 2.x is safer in the general case (it's also the same number of lines in this example). I also realize this is already present in the code so I don't blame you much =D. Don't need to change it, just a general comment for future consideration.
Soap boxing aside, isn't getattr
cleaner here or is there a reason for the expanded check?
port = int(getattr(self, 'port', 8080))
ait/gui/__init__.py
Outdated
if host is None: | ||
host = 'localhost' | ||
port = int(getattr(self, 'port', 8080)): | ||
host = getattr(self, 'port', 'localhost'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a typo snuck in here @robschneider16
host = getattr(self, 'port', 'localhost'):
should be
host = getattr(self, 'host', 'localhost'):
Thanks @robschneider16!! |
Instead of defaulting to port 8080, the ait gui should now look at the
ait config and pull the defined gui.port number from there if its defined.
If it is not defined, then it will use the default of 8080. All of which
gets overwritten if the user provided a port number to the init method