-
Notifications
You must be signed in to change notification settings - Fork 49
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
[Stalled] Provide an Elsa class that can be used programmatically #39
base: master
Are you sure you want to change the base?
Conversation
elsa/_cli.py
Outdated
|
||
Arguments: | ||
|
||
* app: and instance of Flask WSGI application |
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.
*an instance of a Flask WSGI application
(typo and missing article)
elsa/_cli.py
Outdated
base_url = (base_url or self.base_url or | ||
self.app.config.get('FREEZER_BASE_URL')) | ||
if not base_url: | ||
raise ValueError('No base URL provided!') |
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 errors don't use punctuation by convention
warnings.filterwarnings('error', | ||
category=flask_frozen.FrozenFlaskWarning) | ||
|
||
print('Generating HTML...') |
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.
Should an API like this print on its own? Perhaps logging as INFO would be better, since a logger is already in use. Alternatively, a verbose
parameter.
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.
Nope, it definitively should not, I say that in the PR description. A logger is already in use?
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 missed that, sorry. Also, I didn't realize warnings
is not directly related to logging
. My mistake.
print('Generating HTML...') | ||
self.freezer.freeze() | ||
|
||
def freeze_fail_exit(self, path=None, base_url=None): |
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.
Is this useful? Usually libraries don't quit on their own.
Could it be collapsed into a parameter of freeze
(like exit_on_failure
)?
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 need to do it twice, so I created a function. Maybe it should be underscored, not to be part of the API.
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 can only see you using it once right now. If it's only used in the CLI, I'd say it could be defined in there, but your CLI is intertwined with the Elsa class anyway (probably not really a bad thing).
Underscore should be fine too.
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 can only see you using it once right now
Good catch. Now I use it twice :D
elsa/_cli.py
Outdated
|
||
def serve(self, port=DEFAULT_PORT): | ||
"""Serve the frozen app using the freezers ability to serve what was | ||
frozen""" |
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.
*freezer's
Should the |
I'm honestly not sure. I probably would have put it outside myself, but I don't think the current state of things is wrong. |
OK, let me work on this as is, will try to fix all the printing and error reporting and change it so that only the actual CLI is talking. Will also try to add some unittests, since now we are defining an API. |
Sounds good to me! |
BTW I was thinking about this more and I think making cli() a separate function once again and just create an Elsa instance on each command will be more maintainable. |
I want to block this somehow, yet I cannot add my own "change required" review
Related: #32
This is still very much work in progress, currently:
freeze()
,serve()
anddeploy()
cli(...)
is now a shortcut toElsa(...).cli()
However:
I'd like an early feedback if possible.