Suppress error output in HTTP exceptions #352

Closed
fhdk wants to merge 0 commits from fix-check_internet_connection-function into master
fhdk commented 2024-11-06 07:31:14 +00:00 (Migrated from gitlab2.manjaro.org)

Modified exception handling in httpFn.py to suppress logging for Timeout and HTTPError exceptions by setting emit=False. This ensures that these specific errors do not generate noisy output logs.

Modified exception handling in `httpFn.py` to suppress logging for `Timeout` and `HTTPError` exceptions by setting `emit=False`. This ensures that these specific errors do not generate noisy output logs.
fhdk commented 2024-11-06 07:31:15 +00:00 (Migrated from gitlab2.manjaro.org)

requested review from @romangg

requested review from @romangg
fhdk commented 2024-11-06 07:31:15 +00:00 (Migrated from gitlab2.manjaro.org)

assigned to @fhdk

assigned to @fhdk
fhdk commented 2024-11-06 07:39:42 +00:00 (Migrated from gitlab2.manjaro.org)

mentioned in issue #197

mentioned in issue #197
fhdk commented 2024-11-06 07:40:45 +00:00 (Migrated from gitlab2.manjaro.org)

See issue #197

See issue #197
romangg commented 2024-11-06 08:16:42 +00:00 (Migrated from gitlab2.manjaro.org)

Will the error still be recorded somewhere? For my understanding are these errors being sent to stdout at the moment and not stderr?

Will the error still be recorded somewhere? For my understanding are these errors being sent to stdout at the moment and not stderr?
fhdk commented 2024-11-06 08:34:08 +00:00 (Migrated from gitlab2.manjaro.org)

To answer the question - a message will be printed later if the check is False

The returned boolen is used to determine how pacman-mirrors generate the mirrorlist.

If there is no network the mirrorlist is randomized from the available pool - whether this is custom or default.

See the main run() function in pacman_mirrors/pacman_mirrors.py

I am looking at moving the network check below cliFn.parse_command_line()

Something like

        # Setup config: retunrs the config dictionary and true/false on custom
        # Check for static config
        # Check working folders
        # Parse commandline
        # Check network
        # aarch64 check
        # sanitize config
        # Update mirror pool
        # Check if mirrorlist is not to be touched - normal exit
        # Handle missing network
        # Load default mirror pool
        # Build mirror list

I think the printing of the missing connection error is something added by Vitor in the process of counting installations.

To answer the question - a message will be printed later if the check is False The returned boolen is used to determine how pacman-mirrors generate the mirrorlist. If there is no network the mirrorlist is randomized from the available pool - whether this is custom or default. See the main run() function in pacman_mirrors/pacman_mirrors.py I am looking at moving the network check below cliFn.parse_command_line() Something like ``` # Setup config: retunrs the config dictionary and true/false on custom # Check for static config # Check working folders # Parse commandline # Check network # aarch64 check # sanitize config # Update mirror pool # Check if mirrorlist is not to be touched - normal exit # Handle missing network # Load default mirror pool # Build mirror list ``` I think the printing of the missing connection error is something added by Vitor in the process of counting installations.
romangg commented 2024-11-06 08:35:38 +00:00 (Migrated from gitlab2.manjaro.org)

Ok, but I'm talking specifically about the error happening on HTTP exceptions with your change. Will it be available still on stderr?

Because without your change I assume it's printed to stdout, right?

Ok, but I'm talking specifically about the error happening on HTTP exceptions with your change. Will it be available still on stderr? Because without your change I assume it's printed to stdout, right?
fhdk commented 2024-11-06 09:16:12 +00:00 (Migrated from gitlab2.manjaro.org)

what I did was a quick fix - nothing is set in stone - the local function output_err() takes a bool emit defaulting to True - which if set to False will not print the error.

But still in the main run() we have

        if not self.network:
            if not self.quiet:
                util.internet_message(tty=self.tty)
            self.config["method"] = "random"
            self.fasttrack = False

So the message to the user is still there - I don't know why there is the specific handling in check_internet_connection() to handle different exceptions - my guess is that it was something needed by Vitor's project - although I can see the value in returning a different value - but right now all errors make the function return False - which is not ideal.

what I did was a quick fix - nothing is set in stone - the local function output_err() takes a bool emit defaulting to True - which if set to False will not print the error. But still in the main run() we have ``` if not self.network: if not self.quiet: util.internet_message(tty=self.tty) self.config["method"] = "random" self.fasttrack = False ``` So the message to the user is still there - I don't know why there is the specific handling in check_internet_connection() to handle different exceptions - my guess is that it was something needed by Vitor's project - although I can see the value in returning a different value - but right now all errors make the function return False - which is not ideal.
fhdk commented 2024-11-06 09:33:36 +00:00 (Migrated from gitlab2.manjaro.org)

added 1 commit

  • 15baa841 - Refactor exception handling for host availability check

Compare with previous version

added 1 commit <ul><li>15baa841 - Refactor exception handling for host availability check</li></ul> [Compare with previous version](/applications/pacman-mirrors/-/merge_requests/154/diffs?diff_id=4323&start_sha=754eaa23840db9f669e93ea0a0d5b0ed8c5104d8)
fhdk commented 2024-11-06 09:44:37 +00:00 (Migrated from gitlab2.manjaro.org)

added 1 commit

  • 8e0ffd23 - Refactor run method to improve logical flow

Compare with previous version

added 1 commit <ul><li>8e0ffd23 - Refactor run method to improve logical flow</li></ul> [Compare with previous version](/applications/pacman-mirrors/-/merge_requests/154/diffs?diff_id=4325&start_sha=15baa841131bf81f311b5e9d91c0e8d10b45b48b)
fhdk commented 2024-11-06 09:53:39 +00:00 (Migrated from gitlab2.manjaro.org)

I have refactored the check - using a broad exception as the last to catch the rest and print it.

I have refactored the check - using a broad exception as the last to catch the rest and print it.
fhdk commented 2024-11-06 09:55:09 +00:00 (Migrated from gitlab2.manjaro.org)

I have reordered the function calls in the main run() so the network check occurs after parsing commandline - which will prevent the check if it is one of status arguments has been used

I have reordered the function calls in the main run() so the network check occurs after parsing commandline - which will prevent the check if it is one of status arguments has been used
fhdk commented 2024-11-06 10:04:18 +00:00 (Migrated from gitlab2.manjaro.org)

added 1 commit

  • 1e0a8e77 - reorder header

Compare with previous version

added 1 commit <ul><li>1e0a8e77 - reorder header</li></ul> [Compare with previous version](/applications/pacman-mirrors/-/merge_requests/154/diffs?diff_id=4327&start_sha=8e0ffd23685f4abcd6deabc1778ea0cf3b044f48)
fhdk commented 2024-11-06 10:32:00 +00:00 (Migrated from gitlab2.manjaro.org)

added 1 commit

  • 1f883dc5 - Update dependencies in poetry.lock

Compare with previous version

added 1 commit <ul><li>1f883dc5 - Update dependencies in poetry.lock</li></ul> [Compare with previous version](/applications/pacman-mirrors/-/merge_requests/154/diffs?diff_id=4329&start_sha=1e0a8e7714a7233c081b57e5c8c5542669b59219)
fhdk commented 2024-11-06 10:34:24 +00:00 (Migrated from gitlab2.manjaro.org)

added 3 commits

  • 1f883dc5...8c0bb938 - 2 commits from branch master
  • ac81c754 - Merge branch 'master' into 'fix-check_internet_connection-function'

Compare with previous version

added 3 commits <ul><li>1f883dc5...8c0bb938 - 2 commits from branch <code>master</code></li><li>ac81c754 - Merge branch &#39;master&#39; into &#39;fix-check_internet_connection-function&#39;</li></ul> [Compare with previous version](/applications/pacman-mirrors/-/merge_requests/154/diffs?diff_id=4330&start_sha=1f883dc54f774173e645f09400e2f44caa172437)
fhdk (Migrated from gitlab2.manjaro.org) closed this pull request 2024-11-06 10:34:49 +00:00
fhdk commented 2024-11-06 10:40:21 +00:00 (Migrated from gitlab2.manjaro.org)

I will rework this to make the commits clean

I will rework this to make the commits clean

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
applications/pacman-mirrors!352
No description provided.