@ -179,6 +179,7 @@ does for the generation of the update excuses.
* The excuses are written in an HTML file .
* The excuses are written in an HTML file .
"""
"""
import logging
import optparse
import optparse
import os
import os
import sys
import sys
@ -253,6 +254,32 @@ class Britney(object):
the information needed by the other methods of the class .
the information needed by the other methods of the class .
"""
"""
# setup logging - provide the "short level name" (i.e. INFO -> I) that
# we used to use prior to using the logging module.
old_factory = logging . getLogRecordFactory ( )
short_level_mapping = {
' CRITIAL ' : ' F ' ,
' INFO ' : ' I ' ,
' WARNING ' : ' W ' ,
' ERROR ' : ' E ' ,
' DEBUG ' : ' N ' ,
}
def record_factory ( * args , * * kwargs ) :
record = old_factory ( * args , * * kwargs )
try :
record . shortlevelname = short_level_mapping [ record . levelname ]
except KeyError :
record . shortlevelname = record . levelname
return record
logging . setLogRecordFactory ( record_factory )
logging . basicConfig ( format = ' {shortlevelname} : [ {asctime} ] - {message} ' , style = ' { ' ,
datefmt = " % Y- % m- %d T % H: % M: % S % z " )
self . logger = logging . getLogger ( )
# parse the command line arguments
# parse the command line arguments
self . policies = [ ]
self . policies = [ ]
self . _hint_parser = HintParser ( self )
self . _hint_parser = HintParser ( self )
@ -416,6 +443,11 @@ class Britney(object):
help = " Do not compute which packages can migrate. " )
help = " Do not compute which packages can migrate. " )
( self . options , self . args ) = parser . parse_args ( )
( self . options , self . args ) = parser . parse_args ( )
if self . options . verbose :
self . logger . setLevel ( logging . INFO )
else :
self . logger . setLevel ( logging . WARNING )
# integrity checks
# integrity checks
if self . options . nuninst_cache and self . options . print_uninst : # pragma: no cover
if self . options . nuninst_cache and self . options . print_uninst : # pragma: no cover
self . log ( " nuninst_cache and print_uninst are mutually exclusive! " , type = " E " )
self . log ( " nuninst_cache and print_uninst are mutually exclusive! " , type = " E " )
@ -529,8 +561,12 @@ class Britney(object):
` Error ' . Warnings and errors are always printed, and information is
` Error ' . Warnings and errors are always printed, and information is
printed only if verbose logging is enabled .
printed only if verbose logging is enabled .
"""
"""
if self . options . verbose or type in ( " E " , " W " ) :
level = {
print ( " %s : [ %s ] - %s " % ( type , time . asctime ( ) , msg ) )
' I ' : logging . INFO ,
' W ' : logging . WARNING ,
' E ' : logging . ERROR ,
} . get ( type , logging . INFO )
self . logger . log ( level , msg )
def _load_faux_packages ( self , faux_packages_file ) :
def _load_faux_packages ( self , faux_packages_file ) :
""" Loads fake packages
""" Loads fake packages
@ -2771,6 +2807,7 @@ class Britney(object):
self . log ( ' > %s ' % stat , type = " I " )
self . log ( ' > %s ' % stat , type = " I " )
else :
else :
self . log ( ' Migration computation skipped as requested. ' , type = ' I ' )
self . log ( ' Migration computation skipped as requested. ' , type = ' I ' )
logging . shutdown ( )
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :