mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Adding file check and empty list return to freebsd_sysctl.py
This commit is contained in:
parent
469c090330
commit
95a7f125a7
@ -6,6 +6,7 @@ Module for viewing and modifying sysctl parameters
|
|||||||
# Import Python libs
|
# Import Python libs
|
||||||
from __future__ import absolute_import, unicode_literals, print_function
|
from __future__ import absolute_import, unicode_literals, print_function
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
# Import salt libs
|
# Import salt libs
|
||||||
import salt.utils.files
|
import salt.utils.files
|
||||||
@ -66,6 +67,10 @@ def show(config_file=False):
|
|||||||
comps = ['']
|
comps = ['']
|
||||||
|
|
||||||
if config_file:
|
if config_file:
|
||||||
|
# If the file doesn't exist, return an empty list
|
||||||
|
if not os.path.exists(config_file):
|
||||||
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with salt.utils.files.fopen(config_file, 'r') as f:
|
with salt.utils.files.fopen(config_file, 'r') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
|
Loading…
Reference in New Issue
Block a user