mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 14:38:05 +00:00
Fix Ruff UP022 (replace-stdout-stderr)
https://docs.astral.sh/ruff/rules/replace-stdout-stderr/
This commit is contained in:
@@ -564,7 +564,7 @@ class IfcGit:
|
|||||||
"""Command to install Git on Windows using winget"""
|
"""Command to install Git on Windows using winget"""
|
||||||
command = ["winget", "install", "--id", "Git.Git", "-e", "--source", "winget"]
|
command = ["winget", "install", "--id", "Git.Git", "-e", "--source", "winget"]
|
||||||
try:
|
try:
|
||||||
subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.check_output(command)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
operator.report({"ERROR"}, f"Called Process Error occurred: {e}")
|
operator.report({"ERROR"}, f"Called Process Error occurred: {e}")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@@ -577,21 +577,20 @@ class IfcGit:
|
|||||||
ifc_str = ifc_file.to_string()
|
ifc_str = ifc_file.to_string()
|
||||||
|
|
||||||
# Avoid `text=True` as it's causing issues with colorful output.
|
# Avoid `text=True` as it's causing issues with colorful output.
|
||||||
result = subprocess.run(
|
try:
|
||||||
("git", "diff", "--no-index", "--color=always", "--", path, "-"),
|
subprocess.check_output(
|
||||||
input=ifc_str.encode(),
|
("git", "diff", "--no-index", "--color=always", "--", path, "-"),
|
||||||
stdout=subprocess.PIPE,
|
input=ifc_str.encode(),
|
||||||
stderr=subprocess.PIPE,
|
)
|
||||||
)
|
except subprocess.CalledProcessError as e:
|
||||||
if result.returncode == 0:
|
if e.returncode == 1:
|
||||||
operator.report({"INFO"}, "No changes since last save.")
|
print(e.stdout.decode())
|
||||||
return
|
operator.report({"INFO"}, "See system console for git diff output.")
|
||||||
elif result.returncode == 1:
|
return
|
||||||
print(result.stdout.decode())
|
print(e.output)
|
||||||
operator.report({"INFO"}, "See system console for git diff output.")
|
raise Exception("Error running git diff, see system console.")
|
||||||
return
|
|
||||||
print(result)
|
operator.report({"INFO"}, "No changes since last save.")
|
||||||
raise Exception("Error running git diff, see system console.")
|
|
||||||
|
|
||||||
|
|
||||||
class IfcGitRepo:
|
class IfcGitRepo:
|
||||||
|
|||||||
Reference in New Issue
Block a user