summaryrefslogtreecommitdiffstats
path: root/src/lib/Logger.py
diff options
context:
space:
mode:
authorFabian Affolter <fabian@bernewireless.net>2010-06-07 13:26:11 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-06-07 08:42:53 -0500
commit6d2a8b48de43d5a07c8c0ea813f61db30722b320 (patch)
treefad57e3a0ccc188d9fa69c5c93a18346d5d3b558 /src/lib/Logger.py
parent3599dc2990dafbacdb5aa54a6bd338850cefa770 (diff)
downloadbcfg2-6d2a8b48de43d5a07c8c0ea813f61db30722b320.tar.gz
bcfg2-6d2a8b48de43d5a07c8c0ea813f61db30722b320.tar.bz2
bcfg2-6d2a8b48de43d5a07c8c0ea813f61db30722b320.zip
Updated files to match PEP 257
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5899 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Logger.py')
-rw-r--r--src/lib/Logger.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/Logger.py b/src/lib/Logger.py
index 65ee0e596..5616d7469 100644
--- a/src/lib/Logger.py
+++ b/src/lib/Logger.py
@@ -1,4 +1,4 @@
-'''Bcfg2 logging support'''
+"""Bcfg2 logging support"""
__revision__ = '$Revision$'
import copy
@@ -14,16 +14,16 @@ import termios
logging.raiseExceptions = 0
def print_attributes(attrib):
- ''' Add the attributes for an element'''
+ """Add the attributes for an element."""
return ' '.join(['%s="%s"' % data for data in list(attrib.items())])
def print_text(text):
- ''' Add text to the output (which will need normalising '''
+ """Add text to the output (which will need normalising."""
charmap = {'<':'&lt;', '>':'&gt;', '&':'&amp;'}
return ''.join([charmap.get(char, char) for char in text]) + '\n'
def xml_print(element, running_indent=0, indent=4):
- ''' Add an element and its children to the return string '''
+ """Add an element and its children to the return string."""
if (len(element.getchildren()) == 0) and (not element.text):
ret = (' ' * running_indent)
ret += '<%s %s/>\n' % (element.tag, print_attributes(element.attrib))
@@ -41,7 +41,7 @@ def xml_print(element, running_indent=0, indent=4):
return ret
class TermiosFormatter(logging.Formatter):
- '''The termios formatter displays output in a terminal-sensitive fashion'''
+ """The termios formatter displays output in a terminal-sensitive fashion."""
def __init__(self, fmt=None, datefmt=None):
logging.Formatter.__init__(self, fmt, datefmt)
@@ -92,10 +92,10 @@ class TermiosFormatter(logging.Formatter):
return '\n'.join(returns)
class FragmentingSysLogHandler(logging.handlers.SysLogHandler):
- '''
+ """
This handler fragments messages into
chunks smaller than 250 characters
- '''
+ """
def __init__(self, procname, path, facility):
self.procname = procname
@@ -103,7 +103,7 @@ class FragmentingSysLogHandler(logging.handlers.SysLogHandler):
logging.handlers.SysLogHandler.__init__(self, path, facility)
def emit(self, record):
- '''chunk and deliver records'''
+ """Chunk and deliver records."""
record.name = self.procname
if str(record.msg) > 250:
msgs = []
@@ -138,7 +138,7 @@ class FragmentingSysLogHandler(logging.handlers.SysLogHandler):
self.socket.send(msg)
def setup_logging(procname, to_console=True, to_syslog=True, syslog_facility='daemon', level=0, to_file=None):
- '''setup logging for bcfg2 software'''
+ """Setup logging for Bcfg2 software."""
if hasattr(logging, 'already_setup'):
return
# add the handler to the root logger
@@ -170,12 +170,13 @@ def setup_logging(procname, to_console=True, to_syslog=True, syslog_facility='da
logging.already_setup = True
def trace_process(**kwargs):
-
"""Literally log every line of python code as it runs.
Keyword arguments:
log -- file (name) to log to (default stderr)
- scope -- base scope to log to (default Cobalt)"""
+ scope -- base scope to log to (default Cobalt)
+
+ """
file_name = kwargs.get("log", None)
if file_name is not None: