Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix some bugs with pipe on Windows#61

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
asavchkov merged 1 commit intopostgrespro:masterfromAnisimov-ds:master
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -865,8 +865,7 @@ def psql(self,
"-X", # no .psqlrc
"-A", # unaligned output
"-t", # print rows only
"-q", # run quietly
dbname
"-q" # run quietly
] # yapf: disable

# set variables before execution
Expand All@@ -881,6 +880,9 @@ def psql(self,
else:
raise QueryException('Query or filename must be provided')

# should be the last one
psql_params.append(dbname)

# start psql process
process = subprocess.Popen(
psql_params,
Expand Down
34 changes: 27 additions & 7 deletionstestgres/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@
import port_for
import subprocess
import sys
import tempfile

from contextlib import contextmanager
from distutils.version import LooseVersion
Expand DownExpand Up@@ -59,13 +60,32 @@ def execute_utility(args, logfile=None):
"""

# run utility
process = subprocess.Popen(
args, # util + params
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

# get result and decode it
out, _ = process.communicate()
if os.name == 'nt':
# using output to a temporary file in Windows
buf = tempfile.NamedTemporaryFile()

process = subprocess.Popen(
args, # util + params
stdout=buf,
stderr=subprocess.STDOUT
)
process.communicate()

# get result
buf.file.flush()
buf.file.seek(0)
out = buf.file.read()
buf.close()
else:
process = subprocess.Popen(
args, # util + params
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

# get result
out, _ = process.communicate()

# decode result
out = '' if not out else out.decode('utf-8')

# format command
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp