0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
##
|
|
17 |
# @author <author>
|
|
18 |
'''
|
|
19 |
ConE plugin to run external applications/tools with given parameters in .commandml file. Notice that values can be also
|
|
20 |
fecthed from ConfML to maximize portability and minimize maintenance.
|
|
21 |
'''
|
|
22 |
|
|
23 |
import re
|
|
24 |
import os
|
|
25 |
import logging
|
|
26 |
import types
|
3
|
27 |
import pkg_resources
|
0
|
28 |
|
|
29 |
import subprocess
|
3
|
30 |
|
|
31 |
from cone.public import plugin,utils
|
0
|
32 |
|
3
|
33 |
def get_folder_set(folder):
|
|
34 |
"""
|
|
35 |
Get a set object containing all files of given folder
|
|
36 |
@param folder: the folder to create set for
|
|
37 |
@return: a python set
|
|
38 |
"""
|
|
39 |
fileset = set()
|
|
40 |
for (root, _, filenames) in os.walk(folder):
|
|
41 |
for filename in filenames:
|
|
42 |
fname = utils.relpath(os.path.join(root,filename), folder)
|
|
43 |
fileset.add(fname)
|
|
44 |
|
|
45 |
return fileset
|
0
|
46 |
|
|
47 |
class CommandImpl(plugin.ImplBase):
|
|
48 |
"""
|
|
49 |
Plugin implementation class.
|
|
50 |
"""
|
|
51 |
|
|
52 |
IMPL_TYPE_ID = "commandml"
|
|
53 |
|
|
54 |
|
|
55 |
def __init__(self,ref,configuration, reader):
|
|
56 |
"""
|
|
57 |
Overloading the default constructor
|
|
58 |
"""
|
|
59 |
plugin.ImplBase.__init__(self,ref,configuration)###3
|
|
60 |
self.desc = ""
|
|
61 |
self.logger = logging.getLogger('cone.commandml(%s)' % self.ref)
|
|
62 |
self.reader = reader
|
3
|
63 |
for element in self.reader.elements:
|
|
64 |
element.set_logger(self.logger)
|
0
|
65 |
|
|
66 |
|
|
67 |
def generate(self, context=None):
|
|
68 |
"""
|
|
69 |
Generate the given implementation.
|
|
70 |
"""
|
3
|
71 |
|
|
72 |
self.create_output(context)
|
0
|
73 |
return
|
|
74 |
|
|
75 |
def generate_layers(self,layers):
|
|
76 |
"""
|
|
77 |
Generate the given Configuration layers.
|
|
78 |
"""
|
|
79 |
self.logger.info('Generating layers %s' % layers)
|
|
80 |
self.create_output(layers)
|
|
81 |
return
|
|
82 |
|
3
|
83 |
def create_output(self, context, layers=None):
|
0
|
84 |
"""
|
|
85 |
Function to generate output files.
|
|
86 |
"""
|
3
|
87 |
self.context = context
|
0
|
88 |
tmpDict = self.__create_helper_variables()
|
3
|
89 |
# Get the contents of output folder before the generation
|
|
90 |
outset_before = get_folder_set(context.output)
|
0
|
91 |
for element in self.reader.elements:
|
|
92 |
#Element can be either command or condition.
|
|
93 |
element.set_logger(self.logger)
|
3
|
94 |
element.execute(context, tmpDict)
|
|
95 |
|
|
96 |
# Get the contents of output folder after the generation
|
|
97 |
# and get the new files created by the set difference.
|
|
98 |
# NOTE! this does not recognize files outside output folder!
|
|
99 |
outset_after = get_folder_set(context.output)
|
|
100 |
outset = outset_after - outset_before
|
|
101 |
for outfile in outset:
|
|
102 |
context.add_file(outfile, implementation=self)
|
0
|
103 |
return
|
|
104 |
|
|
105 |
def __create_helper_variables(self):
|
|
106 |
"""
|
|
107 |
Internal function to create dictionary containing most often used ConE "environment" variables.
|
|
108 |
"""
|
|
109 |
tmp = {}
|
3
|
110 |
tmp["%CONE_OUT%"] = os.path.join(self.context.output, self.output).rstrip('\\')
|
|
111 |
tmp["%CONE_OUT_ABSOLUTE%"] = os.path.abspath(os.path.join(self.context.output, self.output)).rstrip('\\')
|
0
|
112 |
return tmp
|
|
113 |
|
|
114 |
def has_ref(self, refs):
|
|
115 |
"""
|
|
116 |
@returns True if the implementation uses the given ref as input value.
|
|
117 |
Otherwise return False.
|
|
118 |
"""
|
|
119 |
|
|
120 |
# return true for now so that content copying is not filtered
|
|
121 |
return None
|
|
122 |
|
|
123 |
class CommandImplReader(plugin.ReaderBase):
|
|
124 |
"""
|
|
125 |
Parses a single commandml file
|
|
126 |
"""
|
|
127 |
NAMESPACE = 'http://www.s60.com/xml/commandml/1'
|
3
|
128 |
NAMESPACE_ID = 'commandml'
|
|
129 |
ROOT_ELEMENT_NAME = 'commandml'
|
0
|
130 |
FILE_EXTENSIONS = ['commandml']
|
|
131 |
|
|
132 |
def __init__(self):
|
|
133 |
"""
|
|
134 |
Constructor
|
|
135 |
"""
|
|
136 |
self.output_dir = None
|
|
137 |
self.input_dir = None
|
|
138 |
self.namespaces = [self.NAMESPACE]
|
|
139 |
self.dview = None
|
|
140 |
self.elements = []
|
|
141 |
self.tags = None
|
|
142 |
|
|
143 |
@classmethod
|
|
144 |
def read_impl(cls, resource_ref, configuration, etree):
|
|
145 |
reader = CommandImplReader()
|
|
146 |
reader.set_default_view(configuration.get_default_view())
|
|
147 |
reader.from_etree(etree)
|
|
148 |
impl = CommandImpl(resource_ref, configuration, reader)
|
|
149 |
if reader.tags:
|
|
150 |
impl.set_tags(reader.tags)
|
|
151 |
return impl
|
3
|
152 |
|
|
153 |
@classmethod
|
|
154 |
def get_schema_data(cls):
|
|
155 |
return pkg_resources.resource_string('commandplugin', 'xsd/commandml.xsd')
|
|
156 |
|
0
|
157 |
def set_default_view(self, dview):
|
|
158 |
"""
|
|
159 |
Function to set default view that is needed when solving out ConfML reference information
|
|
160 |
"""
|
|
161 |
self.dview = dview
|
|
162 |
|
|
163 |
def from_etree(self, etree):
|
|
164 |
"""
|
|
165 |
Parser function for commandml element.
|
|
166 |
"""
|
|
167 |
self.parse_tree(etree)
|
|
168 |
|
|
169 |
def parse_tree(self, etree):
|
|
170 |
"""
|
|
171 |
General parse function for condition and command elements.
|
|
172 |
"""
|
|
173 |
elements = list(etree)
|
|
174 |
for element in elements:
|
|
175 |
if element.tag == "{%s}condition" % self.namespaces[0]:
|
|
176 |
self.elements.append(self.parse_condition(element))
|
|
177 |
elif element.tag == "{%s}command" % self.namespaces[0]:
|
|
178 |
self.elements.append(self.parse_command(element))
|
|
179 |
else:
|
|
180 |
pass
|
|
181 |
self.tags = self.parse_tags(etree)
|
|
182 |
|
|
183 |
def parse_condition(self, etree):
|
|
184 |
"""
|
|
185 |
Parse function for condition element.
|
|
186 |
"""
|
|
187 |
condition = Condition()
|
|
188 |
condition.set_condition(etree.get("value"))
|
|
189 |
condition.set_commands(self.parse_commands(etree))
|
|
190 |
condition.set_default_view(self.dview)
|
|
191 |
return condition
|
|
192 |
|
|
193 |
def parse_commands(self,etree):
|
|
194 |
"""
|
|
195 |
Parser function for commands.
|
|
196 |
"""
|
|
197 |
commands = []
|
|
198 |
for com_elem in etree.findall("{%s}command" % self.namespaces[0]):
|
|
199 |
commands.append(self.parse_command(com_elem))
|
|
200 |
return commands
|
|
201 |
|
|
202 |
def parse_command(self,etree):
|
|
203 |
"""
|
|
204 |
Parser function for single command.
|
|
205 |
"""
|
|
206 |
cmd = Command()
|
|
207 |
cmd.set_executable(etree.get("executable"))
|
|
208 |
cmd.set_shell(etree.get("shell"))
|
|
209 |
cmd.set_bufsize(etree.get("bufsize"))
|
|
210 |
cmd.set_cwd(etree.get("cwd"))
|
|
211 |
cmd.set_all_envs(etree.get("env"))
|
|
212 |
cmd.set_all_arguments(self.parse_arguments(etree))
|
|
213 |
cmd.set_all_pipes(self.parse_pipes(etree))
|
|
214 |
cmd.set_filters(self.parse_filters(etree))
|
|
215 |
cmd.set_default_view(self.dview)
|
|
216 |
return cmd
|
|
217 |
|
|
218 |
def parse_arguments(self,etree):
|
|
219 |
"""
|
|
220 |
Parser function for command's arguments.
|
|
221 |
"""
|
|
222 |
arguments = []
|
|
223 |
for argument in etree.findall("{%s}argument" % self.namespaces[0]):
|
|
224 |
value = argument.get("value")
|
|
225 |
if value:
|
|
226 |
arguments.append(value)
|
|
227 |
return arguments
|
|
228 |
|
|
229 |
def parse_pipes(self,etree):
|
|
230 |
"""
|
|
231 |
Parser function for command's pipes.
|
|
232 |
"""
|
|
233 |
pipes = {}
|
|
234 |
for argument in etree.findall("{%s}pipe" % self.namespaces[0]):
|
|
235 |
name = argument.get("name")
|
|
236 |
value = argument.get("value")
|
|
237 |
if name:
|
|
238 |
pipes[name] = value
|
|
239 |
return pipes
|
|
240 |
|
|
241 |
def parse_filters(self,etree):
|
|
242 |
"""
|
|
243 |
Parser function for command's filters.
|
|
244 |
"""
|
|
245 |
filters = []
|
|
246 |
for argument in etree.findall("{%s}filter" % self.namespaces[0]):
|
|
247 |
f = Filter()
|
|
248 |
f.set_severity(argument.get("severity"))
|
|
249 |
f.set_condition(argument.get("condition"))
|
|
250 |
f.set_input(argument.get("input"))
|
|
251 |
f.set_formatter(argument.get("formatter"))
|
|
252 |
filters.append(f)
|
|
253 |
return filters
|
|
254 |
|
|
255 |
def parse_tags(self,etree):
|
|
256 |
tags = {}
|
|
257 |
for tag in etree.getiterator("{%s}tag" % self.namespaces[0]):
|
|
258 |
tagname = tag.get('name','')
|
|
259 |
tagvalue = tag.get('value')
|
|
260 |
values = tags.get(tagname,[])
|
|
261 |
values.append(tagvalue)
|
|
262 |
tags[tagname] = values
|
|
263 |
return tags
|
|
264 |
|
|
265 |
|
|
266 |
class Condition(object):
|
|
267 |
"""
|
|
268 |
Condition class is a simple wrapper class for commands so that commands are executed
|
|
269 |
only if condition is True. Otherwise class does nothing. Class has similar interface
|
|
270 |
than Command class so that they can be used similar way from plugin perspective.
|
|
271 |
"""
|
|
272 |
|
|
273 |
def __init__(self):
|
|
274 |
self.condition = None
|
|
275 |
self.commands = []
|
|
276 |
self.logger = None
|
|
277 |
self.dview = None
|
|
278 |
|
|
279 |
def set_condition(self, condition):
|
|
280 |
self.condition = condition
|
|
281 |
|
|
282 |
def set_default_view(self, dview):
|
|
283 |
self.dview = dview
|
|
284 |
|
|
285 |
def set_commands(self, commands):
|
|
286 |
self.commands = commands
|
|
287 |
|
|
288 |
def set_logger(self, logger):
|
|
289 |
self.logger = logger
|
|
290 |
for cmd in self.commands:
|
|
291 |
cmd.set_logger(logger)
|
|
292 |
|
|
293 |
def add_command(self, command):
|
3
|
294 |
self.commands.append(command)
|
0
|
295 |
|
3
|
296 |
def execute(self, context, replaceDict=None):
|
|
297 |
if self._solve_condition(self.condition, context):
|
0
|
298 |
#Condition is true -> running command
|
|
299 |
for command in self.commands:
|
3
|
300 |
command.execute(context, replaceDict)
|
0
|
301 |
else:
|
|
302 |
self.logger.info("Ignoring %s because it is evaluated as False." % self.condition)
|
|
303 |
|
3
|
304 |
def _solve_condition(self, condition_str, context):
|
0
|
305 |
"""
|
|
306 |
Internal function to handle condition
|
|
307 |
"""
|
|
308 |
if condition_str != "":
|
|
309 |
#Expanding ConfML information
|
|
310 |
modstr = utils.expand_delimited_tokens(
|
|
311 |
condition_str,
|
3
|
312 |
lambda ref, index: repr(context.configuration.get_default_view().get_feature(ref).get_value()))
|
0
|
313 |
return eval(modstr)
|
|
314 |
else:
|
|
315 |
#Empty condition is true always.
|
|
316 |
return True
|
|
317 |
|
|
318 |
class Command(object):
|
|
319 |
"""
|
|
320 |
Command is a class that executes actual commands. It provides ways to handle input, output and error
|
|
321 |
streams and to control execution parameters.
|
|
322 |
"""
|
|
323 |
|
|
324 |
def __init__(self):
|
|
325 |
"""
|
|
326 |
Constructor
|
|
327 |
"""
|
|
328 |
self.executable = None
|
|
329 |
self.shell = False
|
|
330 |
self.bufsize = 0
|
|
331 |
self.cwd = None
|
|
332 |
self.envs = None
|
|
333 |
self.arguments = []
|
|
334 |
self.pipes = {}
|
|
335 |
self.streams = {}
|
|
336 |
self.filters = []
|
|
337 |
self.logger = None
|
|
338 |
self.dview = None
|
|
339 |
|
|
340 |
def set_executable(self, executable):
|
|
341 |
self.executable = executable
|
|
342 |
|
|
343 |
def set_shell(self, shell):
|
|
344 |
if shell and shell.lower() in ('true', 'yes', '1', 1, True):
|
|
345 |
self.shell = True
|
|
346 |
else:
|
|
347 |
self.shell = False
|
|
348 |
|
|
349 |
def set_bufsize(self, bufsize):
|
|
350 |
if bufsize:
|
|
351 |
self.bufsize = int(bufsize)
|
|
352 |
|
|
353 |
def set_cwd(self, cwd):
|
|
354 |
self.cwd = cwd
|
|
355 |
|
|
356 |
def set_all_envs(self, envs):
|
3
|
357 |
self.envs = envs
|
0
|
358 |
def set_default_view(self, dview):
|
|
359 |
self.dview = dview
|
|
360 |
|
|
361 |
def set_env(self, name, value):
|
|
362 |
self.envs[name] = value
|
|
363 |
|
|
364 |
def set_all_arguments(self, args):
|
|
365 |
self.arguments = args
|
|
366 |
|
|
367 |
def get_arguments_string(self):
|
|
368 |
"""
|
|
369 |
Function to return arguments as a string
|
|
370 |
"""
|
|
371 |
arg_string = ""
|
|
372 |
for value in self.arguments:
|
|
373 |
arg_string += value
|
|
374 |
arg_string += " "
|
|
375 |
return arg_string
|
|
376 |
|
|
377 |
def get_pipe(self, name, mode='w'):
|
|
378 |
"""
|
|
379 |
Function to return pipe based on the pipe name in requested mode.
|
|
380 |
"""
|
|
381 |
if self.pipes.has_key(name) and isinstance(self.pipes[name], types.IntType):
|
|
382 |
#Subprocess pipe
|
|
383 |
return self.pipes[name]
|
|
384 |
elif self.pipes.has_key(name) and isinstance(self.pipes[name], types.StringType):
|
|
385 |
return file(self.pipes[name], mode)
|
|
386 |
else:
|
|
387 |
return None
|
|
388 |
|
|
389 |
def set_streams(self, stdin, stdout, stderr):
|
|
390 |
self.streams["stdin"] = stdin
|
|
391 |
self.streams["stdout"] = stdout
|
|
392 |
self.streams["stderr"] = stderr
|
|
393 |
|
|
394 |
def get_streams(self, name, mode="r"):
|
|
395 |
if self.streams.has_key(name) and self.streams[name]:
|
|
396 |
#OK for streams set with subprocess.PIPE
|
|
397 |
return self.streams[name]
|
|
398 |
else:
|
|
399 |
#For file objects
|
|
400 |
return self.get_pipe(name, mode)
|
|
401 |
|
|
402 |
def set_filters(self, filters):
|
|
403 |
self.filters = filters
|
|
404 |
for f in self.filters:
|
|
405 |
f.set_command(self)
|
|
406 |
|
|
407 |
def get_filters(self):
|
|
408 |
return self.filters
|
|
409 |
|
|
410 |
def set_argument(self, value):
|
|
411 |
self.arguments.append(value)
|
|
412 |
|
|
413 |
def set_all_pipes(self, pipes):
|
|
414 |
for pipe in pipes.keys():
|
|
415 |
self.set_pipe(pipe, pipes[pipe])
|
|
416 |
|
|
417 |
def set_pipe(self, name, value):
|
|
418 |
if value == "PIPE":
|
|
419 |
#Creating new stream for this.
|
|
420 |
self.pipes[name] = subprocess.PIPE
|
|
421 |
elif value == "STDOUT":
|
|
422 |
self.pipes[name] = subprocess.STDOUT
|
|
423 |
else:
|
|
424 |
#Setting filename
|
|
425 |
self.pipes[name] = value
|
|
426 |
#self.pipes[name] = file(value, 'w')
|
|
427 |
|
|
428 |
def handle_filters(self):
|
|
429 |
"""
|
|
430 |
"""
|
|
431 |
for filter in self.filters:
|
|
432 |
filter.report(self.logger)
|
|
433 |
|
3
|
434 |
def execute(self, context, replaceDict=None):
|
|
435 |
self.dview = context.configuration.get_default_view()
|
|
436 |
|
0
|
437 |
self.solve_refs()
|
|
438 |
|
3
|
439 |
try:
|
|
440 |
if self.envs: env_dict = eval(self.envs)
|
|
441 |
else: env_dict = None
|
|
442 |
except Exception, e:
|
|
443 |
raise RuntimeError("Failed to evaluate env dictionary: %s: %s" % (e.__class__.__name__, e))
|
|
444 |
|
0
|
445 |
exit_code = 0
|
|
446 |
try:
|
|
447 |
try:
|
|
448 |
if self.cwd is not None:
|
|
449 |
cwd = self.__replace_helper_variables(self.cwd, replaceDict)
|
|
450 |
else:
|
|
451 |
cwd = self.cwd
|
|
452 |
command_str = self.executable + " " + self.__replace_helper_variables(self.get_arguments_string(), replaceDict)
|
|
453 |
self.logger.info("Running command: \"%s\"" % command_str)
|
|
454 |
self.logger.info("with args: shell=%s envs=%s cwd=%s bufsize=%s stdin=%s stdout=%s stderr=%s" \
|
|
455 |
% (self.shell, self.envs, cwd, self.bufsize, \
|
3
|
456 |
self.get_pipe("stdin", 'r'),self.get_pipe("stdout"), self.get_pipe("stderr")))
|
|
457 |
pid = subprocess.Popen(command_str, shell=self.shell, env=env_dict, cwd=cwd,\
|
0
|
458 |
bufsize=self.bufsize, stdin = self.get_pipe("stdin", 'r'),\
|
|
459 |
stdout = self.get_pipe("stdout"), stderr = self.get_pipe("stderr"))
|
|
460 |
#Waiting for process to complete
|
|
461 |
retcode = pid.wait()
|
|
462 |
#Storing stream information for possible further processing.
|
|
463 |
self.set_streams(pid.stdin, pid.stdout, pid.stderr)
|
|
464 |
|
|
465 |
if retcode < 0:
|
|
466 |
self.logger.error("Child was terminated by signal %s" % (-retcode))
|
|
467 |
else:
|
|
468 |
self.logger.info("Child returned: %s" % retcode)
|
|
469 |
except OSError, e:
|
|
470 |
self.logger.error("Execution failed: %s", repr(e))
|
|
471 |
self.handle_filters()
|
|
472 |
except Exception,e:
|
|
473 |
utils.log_exception(self.logger, "Failed to execute command: %s" % e)
|
|
474 |
|
|
475 |
def set_logger(self, logger):
|
|
476 |
self.logger = logger
|
|
477 |
|
|
478 |
def __replace_helper_variables(self, inputstr, dictionary):
|
|
479 |
retstr = inputstr
|
|
480 |
for key in dictionary.keys():
|
|
481 |
retstr = retstr.replace(key, dictionary[key])
|
|
482 |
return retstr
|
|
483 |
|
|
484 |
def solve_refs(self):
|
|
485 |
"""
|
|
486 |
Function to solve references just before generation.
|
|
487 |
"""
|
|
488 |
|
|
489 |
self.executable = self.__solve_ref(self.executable)
|
|
490 |
self.shell = self.__solve_ref(self.shell)
|
|
491 |
self.bufsize = self.__solve_ref(self.bufsize)
|
|
492 |
self.cwd = self.__solve_ref(self.cwd)
|
3
|
493 |
self.envs = self.__solve_ref(self.envs)
|
0
|
494 |
for argument in self.arguments:
|
|
495 |
self.arguments[self.arguments.index(argument)] = self.__solve_ref(argument)
|
|
496 |
for pipe in self.pipes.keys():
|
|
497 |
self.pipes[pipe] = self.__solve_ref(self.pipes[pipe])
|
|
498 |
|
|
499 |
def __solve_ref(self, inputstr):
|
|
500 |
"""
|
|
501 |
Internal function to solve whether input is ref or just normal input string.
|
|
502 |
For refs actual ConfML value is resolved and returned. Non-refs are returned
|
|
503 |
as such.
|
|
504 |
"""
|
|
505 |
if inputstr and isinstance(inputstr, types.StringType):
|
|
506 |
return utils.expand_refs_by_default_view(inputstr, self.dview)
|
|
507 |
else:
|
|
508 |
return inputstr
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
class Filter(object):
|
|
513 |
"""
|
|
514 |
Filter class handles printing information to ConE log using filtering information.
|
|
515 |
Filtering severity, condition and the format of output can be configured in command ml.
|
|
516 |
"""
|
|
517 |
|
|
518 |
def __init__(self):
|
|
519 |
self.severity = None
|
|
520 |
self.condition = None
|
|
521 |
self.input = None
|
|
522 |
self.command = None
|
|
523 |
self.formatter = None
|
|
524 |
|
|
525 |
def set_severity(self, severity):
|
|
526 |
self.severity = severity
|
|
527 |
|
|
528 |
def set_condition(self, condition):
|
|
529 |
self.condition = condition
|
|
530 |
|
|
531 |
def set_input(self, input):
|
|
532 |
self.input = input
|
|
533 |
|
|
534 |
def set_command(self, command):
|
|
535 |
self.command = command
|
|
536 |
|
|
537 |
def set_formatter(self, formatter):
|
|
538 |
self.formatter = formatter
|
|
539 |
|
|
540 |
def report(self, logger):
|
|
541 |
input_pipe = self.command.get_streams(self.input)
|
|
542 |
if isinstance(input_pipe, types.FileType):
|
|
543 |
#Subprocess.PIPE and file descriptors supported only.
|
|
544 |
data = input_pipe.read()
|
|
545 |
pattern = re.compile(self.condition)
|
|
546 |
for line in data.splitlines():
|
|
547 |
mo = pattern.match(line)
|
|
548 |
if mo:
|
|
549 |
lf = self.__get_logger_function(logger)
|
|
550 |
if self.formatter:
|
|
551 |
lf(self.formatter % mo.groupdict())
|
|
552 |
else:
|
|
553 |
lf(line)
|
|
554 |
|
|
555 |
def __get_logger_function(self, logger):
|
|
556 |
if self.severity == "info":
|
|
557 |
return logger.info
|
|
558 |
elif self.severity == "warning":
|
|
559 |
return logger.warning
|
|
560 |
elif self.severity == "debug":
|
|
561 |
return logger.debug
|
|
562 |
elif self.severity == "exception":
|
|
563 |
return logger.exception
|
|
564 |
elif self.severity == "error":
|
|
565 |
return logger.error
|
|
566 |
elif self.severity == "critical":
|
|
567 |
return logger.critical
|
|
568 |
else:
|
|
569 |
#Default
|
|
570 |
return logger.info
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|