Skip to content

Commit 421d97b

Browse files
committed
REF better code maybe
1 parent 72329a4 commit 421d97b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

conda_forge_tick/provide_source_code.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ def provide_source_code_local(recipe_dir):
103103
out = None
104104
err = None
105105

106+
def _print_out_err():
107+
try:
108+
if out:
109+
sys.stdout.write(out.read())
110+
if err:
111+
sys.stderr.write(err.read())
112+
except Exception as e:
113+
logger.error(
114+
"Error printing out/err in getting conda build src!", exc_info=e
115+
)
116+
106117
try:
107118
with wurlitzer.pipes() as (out, err):
108119
from conda_build.api import render
@@ -123,14 +134,7 @@ def provide_source_code_local(recipe_dir):
123134
# provide source dir
124135
yield provide(md)
125136
except (SystemExit, Exception) as e:
126-
if out:
127-
sys.stdout.write(out.getvalue())
128-
if err:
129-
sys.stderr.write(err.getvalue())
130-
137+
_print_out_err()
131138
raise RuntimeError("conda build src exception: " + str(e))
132139

133-
if out:
134-
sys.stdout.write(out.getvalue())
135-
if err:
136-
sys.stderr.write(err.getvalue())
140+
_print_out_err()

0 commit comments

Comments
 (0)