Skip to content

Commit b324424

Browse files
committed
Fixed some issues with the Py2/3 changes to the populate_yang_model_dirs management command.
- Legacy-Id: 16520
1 parent ee36993 commit b324424

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

ietf/utils/management/commands/populate_yang_model_dirs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010

1111
from pathlib2 import Path
12-
from io import StringIO
12+
from six import StringIO
1313
from textwrap import dedent
1414
from xym import xym
1515

@@ -83,15 +83,18 @@ def extract_from(file, dir, strict=True):
8383
model_list = [ n.replace('"','') for n in model_list ]
8484
except Exception as e:
8585
self.stderr.write("** Error when extracting from %s: %s" % (file, str(e)))
86-
sys.stdout = saved_stdout
87-
sys.stderr = saved_stderr
86+
finally:
87+
sys.stdout = saved_stdout
88+
sys.stderr = saved_stderr
8889
#
8990
if verbosity > 1:
9091
outmsg = xymout.getvalue()
91-
self.stdout.write(outmsg)
92+
if outmsg.strip():
93+
self.stdout.write(outmsg)
9294
if verbosity>2:
9395
errmsg = xymerr.getvalue()
94-
self.stderr.write(errmsg)
96+
if errmsg.strip():
97+
self.stderr.write(errmsg)
9598
return model_list
9699

97100
# Extract from new RFCs

0 commit comments

Comments
 (0)