Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure we close this file handle #19

Merged
merged 1 commit into from Aug 23, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

make sure we close this file handle

  • Loading branch information
Mike Blume
Mike Blume committed Aug 22, 2013
commit 76fa6dd8dbdbe9bf30fb608e7d9775759bea7677
@@ -651,7 +651,6 @@ def get_installed_syslog_configuration(syslog_id):
source = ''
Logger.printLog("Reading default configuration directory path from (%s)."
% default_config_file_name.get(syslog_id), prio = 'debug')
text_file = open(default_config_file_name.get(syslog_id), "r")

if syslog_id == PROD_RSYSLOG:
include_pattern = r"^\s*[^#]\s*IncludeConfig\s+([\S]+/)"
@@ -673,18 +672,19 @@ def get_installed_syslog_configuration(syslog_id):
auth_token_compiled_regex = re.compile(auth_token_pattern,
re.MULTILINE | re.IGNORECASE)

for line in text_file:
if len(default_directory) <= 0:
include_match_grp = include_compiled_regex.match(line.rstrip('\n'))
if include_match_grp:
default_directory = include_match_grp.group(1)
default_directory = default_directory.lstrip('"').rstrip('"')

if len(auth_token) <= 0:
auth_token_match_grp = auth_token_compiled_regex.match\
(line.rstrip('\n'))
if auth_token_match_grp:
auth_token = auth_token_match_grp.group(1)
with open(default_config_file_name.get(syslog_id), "r") as text_file:
for line in text_file:
if not default_directory:
include_match_grp = include_compiled_regex.match(line.rstrip('\n'))
if include_match_grp:
default_directory = include_match_grp.group(1)
default_directory = default_directory.lstrip('"').rstrip('"')

if not auth_token:
auth_token_match_grp = auth_token_compiled_regex.match\
(line.rstrip('\n'))
if auth_token_match_grp:
auth_token = auth_token_match_grp.group(1)

if syslog_id == PROD_SYSLOG_NG:
source = get_syslog_ng_source(default_config_file_name.get(syslog_id))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.