Add environment variable OSC_HTTP_MANUAL_APPROVE#2007
Draft
andrii-suse wants to merge 1 commit intomasterfrom
Draft
Add environment variable OSC_HTTP_MANUAL_APPROVE#2007andrii-suse wants to merge 1 commit intomasterfrom
andrii-suse wants to merge 1 commit intomasterfrom
Conversation
dmach
requested changes
Dec 1, 2025
| http.client.print(40 * '-') | ||
| http.client.print(method, url) | ||
|
|
||
| if method != "GET" and os.environ['OSC_HTTP_MANUAL_APPROVE']: |
Contributor
There was a problem hiding this comment.
os.environ['OSC_HTTP_MANUAL_APPROVE'] may raise KeyError.
| http.client.print(method, url) | ||
|
|
||
| if method != "GET" and os.environ['OSC_HTTP_MANUAL_APPROVE']: | ||
| print("osc is going to send "+ method +" request to " + urlopen_url) |
Contributor
There was a problem hiding this comment.
Could you use a f-string instead?
Maybe drop this print and rely on the prompt below?
| if method != "GET" and os.environ['OSC_HTTP_MANUAL_APPROVE']: | ||
| print("osc is going to send "+ method +" request to " + urlopen_url) | ||
| if data: | ||
| print(data.decode("utf-8")) |
Contributor
There was a problem hiding this comment.
This may fail. It is not guaranteed that the data is utf-8 text.
Comment on lines
+349
to
+352
| y = input("press 'y' to continue or any other key to cancel") | ||
| if y != 'y' and y != 'Y': | ||
| raise Exception("Manual abort") | ||
|
|
Contributor
There was a problem hiding this comment.
We should use functions and exceptions osc already offers:
(please excuse the wrong indendation, I've copied the code from a different place and slightly modified it to fit the scenario)
from .output import get_user_input
reply = get_user_input(
f"Do you want to make '{method}' request to '{urlopen_url}'?",
answers={"y": "yes", "n": "no"},
default_answer="n",
)
if reply == "n":
raise oscerr.UserAbort()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.