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

Update stop.py #71

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

SimonL22
Copy link

  • 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
Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Tiny improvements.

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):
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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.

Comment on lines 97 to 100
if try_to_kill(proc, pinfo):
return True
else:
return False
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if try_to_kill(proc, pinfo):
return True
else:
return False
return try_to_kill(proc, pinfo)

log.info("")
show_process_info(proc, "", show_heading=True)
return False
return True
Copy link
Member

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.

return True


def check_stop_remove_container(server_container):
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants