Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 4 deletions library/juniper_junos_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@
'''

# Standard library imports
# Python 2.x and 3.x portable open
from io import open
import json
import os.path

Expand Down Expand Up @@ -311,8 +309,8 @@ def save_inventory(junos_module, inventory):
file_path = os.path.normpath(os.path.join(save_dir, file_name))
junos_module.logger.debug("Saving inventory to: %s.", file_path)
try:
with open(file_path, 'wt', encoding='utf-8') as fact_file:
fact_file.write(inventory)
with open(file_path, 'wb') as fact_file:
fact_file.write(inventory.encode(encoding='utf-8'))
junos_module.logger.debug("Inventory saved to: %s.", file_path)
except IOError:
junos_module.fail_json(msg="Unable to save inventory. Failed to "
Expand Down
8 changes: 3 additions & 5 deletions module_utils/juniper_junos_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
# Standard library imports
from argparse import ArgumentParser
from distutils.version import LooseVersion
# Python 2.x and 3.x portable open
from io import open
import json
import logging
import os
Expand Down Expand Up @@ -1806,7 +1804,7 @@ def save_text_output(self, name, format, text):
- If the destination file is not writable.
"""
file_path = None
mode = 'wt'
mode = 'wb'
if name == 'diff':
if self.params.get('diffs_file') is not None:
file_path = os.path.normpath(self.params.get('diffs_file'))
Expand All @@ -1832,8 +1830,8 @@ def save_text_output(self, name, format, text):
file_path = os.path.normpath(os.path.join(dest_dir, file_name))
if file_path is not None:
try:
with open(file_path, mode, encoding='utf-8') as save_file:
save_file.write(text)
with open(file_path, mode) as save_file:
save_file.write(text.encode(encoding='utf-8'))
self.logger.debug("Output saved to: %s.", file_path)
except IOError:
self.fail_json(msg="Unable to save output. Failed to "
Expand Down
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = "2.0.1.dev0"
DATE = "2018-Jan-11"
VERSION = "2.0.1"
DATE = "2018-Jan-15"