-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update stop.py #71
base: main
Are you sure you want to change the base?
Update stop.py #71
Conversation
SimonL22
commented
Sep 18, 2024
- Try-Except-block in extra function for more readability
- added return False if pinfo for an psutilprocess can't be created sucessfully (otherwise pinfo isn't defined for the next block)
- Linelenght <=79
- try except block in extra function for more readability - added return False if pinfo for an psutilprocess can't be created sucessfully (otherwise pinfo isn't defined for the next block) - Linelenght <=79
check_stop_remove_container Funktion hinzugefügt um Code aus der execute auszulagern
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.
Tiny improvements.
src/qlever/commands/stop.py
Outdated
from qlever.command import QleverCommand | ||
from qlever.commands.status import StatusCommand | ||
from qlever.containerize import Containerize | ||
from qlever.log import log | ||
from qlever.util import show_process_info | ||
|
||
|
||
def try_to_kill(proc, pinfo): |
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.
Try to kill the given process
, return true iff it was killed successfully. the process_info
is used for logging.
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.
(Also add documentation for the other functions you extract).
log.info(f"{container_system.capitalize()} container with " | ||
f"name \"{server_container}\" stopped " | ||
f" and removed") | ||
return True |
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 the return False
is missing at the end.
src/qlever/commands/stop.py
Outdated
if try_to_kill(proc, pinfo): | ||
return True | ||
else: | ||
return False |
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.
if try_to_kill(proc, pinfo): | |
return True | |
else: | |
return False | |
return try_to_kill(proc, pinfo) |
src/qlever/commands/stop.py
Outdated
log.info("") | ||
show_process_info(proc, "", show_heading=True) | ||
return False | ||
return True |
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.
If the return is inside the try:
clause, the code is much more readable.
src/qlever/commands/stop.py
Outdated
return True | ||
|
||
|
||
def check_stop_remove_container(server_container): |
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.
These two functions should have consistent names, e.g. stop_process
and stop_container
.