Skip to content
Snippets Groups Projects

Resolve "Make ERS AppName more descriptive"

Merged Jonas Ladefoged Holm requested to merge 16-make-ers-appname-more-descriptive into master
All threads resolved!
Files
6
def createTestFiles(path):
"Creates 1 test file at the defined path with the following format: file0.data"
# And I populate only the src folder with files to copy
for x in range(1):
open(str(path) + '/file' + str(x) + '.data', "w").close()
class BaseLineReplacer():
"""Base class used for replacing config file settings line by line.
If a match in the dictionary is found, it returns a new value from the match.
Otherwise it returns the same line untouched."""
def __init__(self):
self.pairs = {}
def fixLine(self, line):
for k, v in self.pairs.iteritems():
if line.find(k) > -1:
return v
return line
class LocalCopyConfigLineReplacer(BaseLineReplacer):
"""This replaces the lines LogDir, DirList and CopyDir from the line, with
a path from the dict parsed to the constructor.
Expects the keywords "log" "src" and "des" to be present in the parsed directory dictionary.
If a match in the dictionary is found, it returns a new value from the match.
Otherwise it returns the same line untouched."""
def __init__(self, dirs):
BaseLineReplacer.__init__(self)
self.pairs = {"LogDir: ": "LogDir: \'" + dirs["log"] + "\'\n",
"DirList: ": "DirList: [\'" + dirs["src"] + "\',]\n",
"CopyDir: ":"CopyDir: \'" + dirs["des"] + "\'\n"}
class EOSLineConfigLineReplacer(BaseLineReplacer):
"""This replaces the lines in a config, relevant to activating
ERS Logging, but to STDOUT instead of MTS streams.
If a match in the dictionary is found, it returns a new value from the match.
Otherwise it returns the same line untouched."""
def __init__(self):
BaseLineReplacer.__init__(self)
self.pairs = {"ers_info: ": "ers_info: \'\'\n",
"ers_warning: ": "ers_warning: \'\'\n",
"ers_error: ": "ers_error: \'\'\n",
"ers_debug: ": "ers_debug: \'\'\n",
"ERSenabled: ": "ERSenabled: True\n"}
\ No newline at end of file
Loading