-
Notifications
You must be signed in to change notification settings - Fork 35
Proposal to fix #154 (v2) #161
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
Merged
dmitry-lipetsk
merged 13 commits into
postgrespro:master
from
dmitry-lipetsk:master-fix154--v02
Dec 10, 2024
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f9ddd04
Proposal to fix #154 (v2)
dmitry-lipetsk 2bb38dc
[BUG FIX] PostgresNode::safe_psql did not respect "expect_error" para…
dmitry-lipetsk 45b8dc0
[BUG FIX] A problem in psql/safe_psql and 'input' data was fixed [loc…
dmitry-lipetsk f848a63
PostgresNode::safe_psql raises InvalidOperationException
dmitry-lipetsk db0744e
A problem with InvalidOperationException and flake8 is fixed
dmitry-lipetsk 5bb1510
A code style is fixed [flake8]
dmitry-lipetsk 31c7bce
[BUG FIX] Wrappers for psql use subprocess.PIPE for stdout and stderr
dmitry-lipetsk b013801
[BUG FIX] TestgresTests::test_safe_psql__expect_error uses rm_carriag…
dmitry-lipetsk c49ee4c
node.py is updated [formatting]
dmitry-lipetsk 6a0e714
Formatting
dmitry-lipetsk 3cc19d2
raise_error.py is moved into testgres/operations from testgres/helpers
dmitry-lipetsk 7b70e9e
Helpers.GetDefaultEncoding is added
dmitry-lipetsk cd0b5f8
Code normalization
dmitry-lipetsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from ..exceptions import ExecUtilException | ||
|
||
|
||
class RaiseError: | ||
def UtilityExitedWithNonZeroCode(cmd, exit_code, msg_arg, error, out): | ||
assert type(exit_code) == int # noqa: E721 | ||
|
||
msg_arg_s = __class__._TranslateDataIntoString(msg_arg).strip() | ||
assert type(msg_arg_s) == str # noqa: E721 | ||
|
||
if msg_arg_s == "": | ||
msg_arg_s = "#no_error_message" | ||
|
||
message = "Utility exited with non-zero code. Error: `" + msg_arg_s + "`" | ||
raise ExecUtilException( | ||
message=message, | ||
command=cmd, | ||
exit_code=exit_code, | ||
out=out, | ||
error=error) | ||
|
||
def _TranslateDataIntoString(data): | ||
if type(data) == bytes: # noqa: E721 | ||
return __class__._TranslateDataIntoString__FromBinary(data) | ||
|
||
return str(data) | ||
|
||
def _TranslateDataIntoString__FromBinary(data): | ||
assert type(data) == bytes # noqa: E721 | ||
dmitry-lipetsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
try: | ||
return data.decode('utf-8') | ||
dmitry-lipetsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
except UnicodeDecodeError: | ||
pass | ||
|
||
return "#cannot_decode_text" | ||
|
||
def _BinaryIsASCII(data): | ||
assert type(data) == bytes # noqa: E721 | ||
|
||
for b in data: | ||
if not (b >= 0 and b <= 127): | ||
return False | ||
|
||
return True |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Helpers: | ||
def PrepareProcessInput(input, encoding): | ||
if not input: | ||
return None | ||
|
||
if type(input) == str: # noqa: E721 | ||
if encoding is None: | ||
return input.encode() | ||
dmitry-lipetsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
assert type(encoding) == str # noqa: E721 | ||
return input.encode(encoding) | ||
|
||
# It is expected! | ||
assert type(input) == bytes # noqa: E721 | ||
return input |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.