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

4 trivia - cleanups and tiny fixes #525

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

Conversation

sourcejedi
Copy link

Hi!

I found these trivia while looking at error handling. The rest of my work didn't seem to depend on them. So I've split these ones out, to help keep things manageable.

(If you want to leave reviewing this until I send the more hefty PR(s) as well, that's fine :-).

Thanks
Alan

Also, removing the lone print() call makes the code more consistent.
setup_logging() already relies on an initial `log` object being setup
elsewhere, pointing to stderr.

I think that is pretty conventional.  python's built-in logging
module works the same way.
…ypo?)

Exit status 1 is fine. We don't need to use a confusing negative underflow
to exit status 255 here.
The "right place" already has the same comment.
Copy link
Collaborator

@erig0 erig0 left a comment

Choose a reason for hiding this comment

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

Otherwise looks good.

@@ -170,8 +170,8 @@ def startup(args):
def main():
# firewalld should only be run as the root user
if os.getuid() != 0:
print("You need to be root to run %s." % sys.argv[0])
sys.exit(-1)
log.fatal("You need to be root to run %s." % sys.argv[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't work. Logging isn't set up yet.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for (amazingly quick :-) review. It works for me:

$ src/firewalld
FATAL ERROR: You need to be root to run src/firewalld.

Do you disagree with the commit message? 4dccb48

I can change it to sys.stderr.write() if you prefer. It just seems a pity for the logging to implement this elegant convention, and then shy away from using it.

Copy link
Collaborator

@thom311 thom311 left a comment

Choose a reason for hiding this comment

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

lgtm

(though, needs a rebase, which causes some conflicts).

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.

3 participants