diff options
author | Tim Serong <tserong@suse.com> | 2020-05-01 22:49:35 +1000 |
---|---|---|
committer | Tim Serong <tserong@suse.com> | 2020-05-01 22:55:58 +1000 |
commit | bc6a155896c7136a7ef980870b6fe5481b0edf23 (patch) | |
tree | cd51c04148d370d1ae2f993e2e8e91afe6fe6618 | |
parent | da8f0cef114e7343a7ae96ff1db7c8c574f819be (diff) | |
download | configshell-fb-bc6a155896c7136a7ef980870b6fe5481b0edf23.tar.gz |
Don't warn if prefs file doesn't exist
The first time configshell is used, prefs.bin won't exist, so
you'll see something like:
Warning: Could not load preferences file /root/.whatever/prefs.bin.
If the file doesn't actually exist, this warning is just confusing,
so I've added an existence check to Prefs.load()
Signed-off-by: Tim Serong <tserong@suse.com>
-rw-r--r-- | configshell/prefs.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/configshell/prefs.py b/configshell/prefs.py index 7faa1fe..0c3bd9e 100644 --- a/configshell/prefs.py +++ b/configshell/prefs.py @@ -15,6 +15,7 @@ License for the specific language governing permissions and limitations under the License. ''' +import os import six import fcntl @@ -143,7 +144,7 @@ class Prefs(object): if filename is None: filename = self.filename - if filename is not None: + if filename is not None and os.path.exists(filename): fsock = open(filename, 'rb') fcntl.lockf(fsock, fcntl.LOCK_SH) try: |