From a1da995ce5da25b95b0760a4103ee099a101c239 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 22 Aug 2014 15:53:18 -0400 Subject: Don't log errors if files don't exists. Update the utils.get_file_data method so that it doesn't log errors if a file doesn't exist. --- os_net_config/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'os_net_config/utils.py') diff --git a/os_net_config/utils.py b/os_net_config/utils.py index e51d197..cd202f6 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -16,6 +16,7 @@ import glob import logging +import os logger = logging.getLogger(__name__) @@ -28,6 +29,9 @@ def write_config(filename, data): def get_file_data(filename): + if not os.path.exists(filename): + return '' + try: with open(filename, 'r') as f: return f.read() @@ -41,7 +45,7 @@ def interface_mac(name): with open('/sys/class/net/%s/address' % name, 'r') as f: return f.read().rstrip() except IOError: - logger.error("Unable to read file: %s" % name) + logger.error("Unable to read mac address: %s" % name) raise -- cgit 1.2.3-korg