Fixed some errors in the builtin methods.
There are still some issues with $copy_files and $TODO. I will resolve them
later this week.
~
Dan
From 00dd16c268e9763e520825ab6339eae798010cc7 Mon Sep 17 00:00:00 2001
From: Dan Guernsey <[EMAIL PROTECTED]>
Date: Mon, 4 Aug 2008 01:43:39 -0500
Subject: [PATCH] Fixed errors in builtin methods
---
cobbler/templateapi.py | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/cobbler/templateapi.py b/cobbler/templateapi.py
index ab4bc78..586a110 100644
--- a/cobbler/templateapi.py
+++ b/cobbler/templateapi.py
@@ -38,18 +38,18 @@ BuiltinTemplate = Cheetah.Template.Template.compile(source="\n".join([
# Comment every line containing the pattern
"#def comment_lines($filename, $pattern, $commentchar='#')",
- "perl -npe 's/^(.*${pattern}.*)$/${commentchar}\${1}/' -i '$filename'",
+ "perl -npe 's/^(.*${pattern}.*)$/${commentchar}\\${1}/' -i '$filename'",
"#end def",
# Comments every line which contains only the exact pattern.
"#def comment_lines_exact($filename, $pattern, $commentchar='#')",
- "perl -npe 's/^(${pattern})$/${commentchar}\${1}/' -f '$filename'",
+ "perl -npe 's/^(${pattern})$/${commentchar}\\${1}/' -f '$filename'",
"#end def",
# Uncomments every (commented) line containing the pattern
# Patterns should not contain the #
"#def uncomment_lines($filename, $pattern, $commentchar='#')",
- "perl -npe 's/^[ \t]*${commentchar}(.*${pattern}.*)$/\${1}/' -i '$filename'",
+ "perl -npe 's/^[ \\t]*${commentchar}(.*${pattern}.*)$/\\${1}/' -i '$filename'",
"#end def",
# Nullify (by changing to 'true') all instances of a given sh command. This
@@ -59,11 +59,11 @@ BuiltinTemplate = Cheetah.Template.Template.compile(source="\n".join([
"#def delete_command($filename, $pattern)",
"sed -nr '",
" h",
- " s/^([^#]*)(#?.*)$/\1/",
- " s/((^|;)[ \t]*)${pattern}([ \t]*($|;))/\1true\3/g",
- " s/((^|;)[ \t]*)${pattern}([ \t]*($|;))/\1true\3/g",
+ " s/^([^#]*)(#?.*)$/\\1/",
+ " s/((^|;)[ \\t]*)${pattern}([ \\t]*($|;))/\\1true\\3/g",
+ " s/((^|;)[ \\t]*)${pattern}([ \\t]*($|;))/\\1true\\3/g",
" x",
- " s/^([^#]*)(#?.*)$/\2/",
+ " s/^([^#]*)(#?.*)$/\\2/",
" H",
" x",
" s/\\n//",
@@ -74,9 +74,9 @@ BuiltinTemplate = Cheetah.Template.Template.compile(source="\n".join([
# Replace a configuration parameter value, or add it if it doesn't exist.
# Assumes format is [param_name] [value]
"#def set_config_value($filename, $param_name, $value)",
- "if [ -n \"\$(grep -Ee '^[ \t]*${param_name}[ \t]+' '$filename')\" ]",
+ "if [ -n \"\\$(grep -Ee '^[ \\t]*${param_name}[ \\t]+' '$filename')\" ]",
"then",
- " perl -npe 's/^([ \t]*${param_name}[ \t]+)[\x21-\x7E]*([ \t]*(#.*)?)$/\${1}${sedesc($value)}\${2}/' -i '$filename'",
+ " perl -npe 's/^([ \\t]*${param_name}[ \\t]+)[\\x21-\\x7E]*([ \\t]*(#.*)?)$/\\${1}${sedesc($value)}\\${2}/' -i '$filename'",
"else",
" echo '$param_name $value' >> '$filename'",
"fi",
@@ -86,9 +86,9 @@ BuiltinTemplate = Cheetah.Template.Template.compile(source="\n".join([
# Assues format is [param_name] [delimiter] [value], where [delimiter] is
# usually '='.
"#def set_config_value_delim($filename, $param_name, $delim, $value)",
- "if [ -n \"\$(grep -Ee '^[ \t]*${param_name}[ \t]*${delim}[ \t]*' '$filename')\" ]",
+ "if [ -n \"\\$(grep -Ee '^[ \\t]*${param_name}[ \\t]*${delim}[ \\t]*' '$filename')\" ]",
"then",
- " perl -npe 's/^([ \t]*${param_name}[ \t]*${delim}[ \t]*)[\x21-\x7E]*([ \t]*(#.*)?)$/${1}${sedesc($value)}${2}/' -i '$filename'",
+ " perl -npe 's/^([ \\t]*${param_name}[ \\t]*${delim}[ \\t]*)[\\x21-\\x7E]*([ \\t]*(#.*)?)$/${1}${sedesc($value)}${2}/' -i '$filename'",
"else",
" echo '$param_name$delim$value' >> '$filename'",
"fi",
@@ -188,8 +188,8 @@ BuiltinTemplate = Cheetah.Template.Template.compile(source="\n".join([
# Cheeseball an entire directory.
"#def includeall($dir)",
"#import os",
- "#for $file in $os.listdir($snippetsdir + $dir)",
- "#include $snippetsdir + $dir + '/' + $file",
+ "#for $file in $os.listdir($snippetsdir + '/' + $dir)",
+ "#include $snippetsdir + '/' + $dir + '/' + $file",
"#end for",
"#end def",
@@ -309,4 +309,4 @@ class Template(BuiltinTemplate):
return '\\' + c
else:
return c
- return ''.join([escchar for c in value])
+ return ''.join([escchar(c) for c in value])
--
1.5.6.3
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler