View | Details | Raw Unified | Return to bug 49060
Collapse All | Expand All

(-)a/base/univention-config-registry/python/univention/config_registry/frontend.py (-1 / +1 lines)
 Lines 330-336   def handler_filter(args, opts=dict()): Link Here 
330
	"""Run filter on STDIN to STDOUT."""
330
	"""Run filter on STDIN to STDOUT."""
331
	ucr = ConfigRegistry()
331
	ucr = ConfigRegistry()
332
	ucr.load()
332
	ucr.load()
333
	sys.stdout.write(run_filter(sys.stdin.read(), ucr, opts=opts))
333
	os.write(sys.stdout.fileno(), run_filter(sys.stdin.read(), ucr, opts=opts))
334
334
335
335
336
def handler_search(args, opts=dict()):
336
def handler_search(args, opts=dict()):
(-)a/base/univention-config-registry/python/univention/config_registry/handler.py (-4 / +9 lines)
 Lines 59-65   __all__ = ['ConfigHandlers'] Link Here 
59
59
60
VARIABLE_PATTERN = re.compile('@%@([^@]+)@%@')
60
VARIABLE_PATTERN = re.compile('@%@([^@]+)@%@')
61
VARIABLE_TOKEN = re.compile('@%@')
61
VARIABLE_TOKEN = re.compile('@%@')
62
EXECUTE_TOKEN = re.compile('@!@')
62
EXECUTE_TOKEN = re.compile(b'@!@')
63
WARNING_PATTERN = re.compile('(UCRWARNING|BCWARNING|UCRWARNING_ASCII)=(.+)')
63
WARNING_PATTERN = re.compile('(UCRWARNING|BCWARNING|UCRWARNING_ASCII)=(.+)')
64
64
65
INFO_DIR = '/etc/univention/templates/info'
65
INFO_DIR = '/etc/univention/templates/info'
 Lines 89-94   def run_filter(template, directory, srcfiles=set(), opts=dict()): Link Here 
89
	:param opts: UNUSED.
89
	:param opts: UNUSED.
90
	:returns: The modified template with all UCR variables and sections replaced.
90
	:returns: The modified template with all UCR variables and sections replaced.
91
	"""
91
	"""
92
	if isinstance(template, bytes):
93
		template = template.decode('utf-8')
92
	while True:
94
	while True:
93
		i = VARIABLE_TOKEN.finditer(template)
95
		i = VARIABLE_TOKEN.finditer(template)
94
		try:
96
		try:
 Lines 115-120   def run_filter(template, directory, srcfiles=set(), opts=dict()): Link Here 
115
		except StopIteration:
117
		except StopIteration:
116
			break
118
			break
117
119
120
	template = template.encode('utf-8')
118
	while True:
121
	while True:
119
		i = EXECUTE_TOKEN.finditer(template)
122
		i = EXECUTE_TOKEN.finditer(template)
120
		try:
123
		try:
 Lines 124-131   def run_filter(template, directory, srcfiles=set(), opts=dict()): Link Here 
124
			proc = subprocess.Popen(
127
			proc = subprocess.Popen(
125
				(sys.executable,),
128
				(sys.executable,),
126
				stdin=subprocess.PIPE, stdout=subprocess.PIPE,
129
				stdin=subprocess.PIPE, stdout=subprocess.PIPE,
127
				close_fds=True, universal_newlines=True)
130
				close_fds=True)
128
			value = proc.communicate('''\
131
			content = template[start.end():end.start()]
132
			content = b'''\
129
# -*- coding: utf-8 -*-
133
# -*- coding: utf-8 -*-
130
import univention.config_registry
134
import univention.config_registry
131
configRegistry = univention.config_registry.ConfigRegistry()
135
configRegistry = univention.config_registry.ConfigRegistry()
 Lines 133-139   configRegistry.load() Link Here 
133
# for compatibility
137
# for compatibility
134
baseConfig = configRegistry
138
baseConfig = configRegistry
135
%s
139
%s
136
''' % template[start.end():end.start()])[0]
140
''' % (content,)
141
			value = proc.communicate(content)[0]
137
			template = template[:start.start()] + value + template[end.end():]
142
			template = template[:start.start()] + value + template[end.end():]
138
143
139
		except StopIteration:
144
		except StopIteration:

Return to bug 49060