<s> """<STR_LIT>""" <EOL> from common . core import globalVariables as gv <EOL> import exceptions <EOL> import getpass <EOL> import logging . handlers <EOL> import os <EOL> import sys <EOL> MAILHOST = '<STR_LIT>' <EOL> FROMADDRESS = '<STR_LIT>' <EOL> gameArtPipelineEmail = '<STR_LIT>' <EOL> teamATechArtistEmail = '<STR_LIT>' <EOL> teamBTechArtistEmail = '<STR_LIT>' <EOL> toAddresses = [ gameArtPipelineEmail ] <EOL> artTeam = '<STR_LIT>' <EOL> if artTeam == gv . teamA : <EOL> toAddresses = [ gameArtPipelineEmail , teamATechArtistEmail ] <EOL> if artTeam == gv . teamB : <EOL> toAddresses = [ gameArtPipelineEmail , teamBTechArtistEmail ] <EOL> CRITICAL = <NUM_LIT:50> <EOL> FATAL = CRITICAL <EOL> ERRORDIALOG = <NUM_LIT> <EOL> ERROR = <NUM_LIT> <EOL> WARNING = <NUM_LIT:30> <EOL> WARN = WARNING <EOL> INFODIALOG = <NUM_LIT> <EOL> INFO = <NUM_LIT:20> <EOL> DEBUGDIALOG = <NUM_LIT:15> <EOL> DEBUG = <NUM_LIT:10> <EOL> NOTSET = <NUM_LIT:0> <EOL> class PCSlogging ( logging . Logger ) : <EOL> """<STR_LIT>""" <EOL> def errorDialog ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" <EOL> if self . isEnabledFor ( INFODIALOG ) : <EOL> self . _log ( ERROR , msg , args , ** kwargs ) <EOL> title = '<STR_LIT>' <EOL> if len ( args ) > <NUM_LIT:1> : <EOL> title = args [ <NUM_LIT:1> ] <EOL> try : <EOL> from maya import cmds <EOL> result = cmds . confirmDialog ( t = title , m = msg , b = [ '<STR_LIT:OK>' , '<STR_LIT>' ] , db = '<STR_LIT:OK>' , cb = '<STR_LIT>' , ds = '<STR_LIT>' ) <EOL> if result == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) <EOL> except RuntimeError : <EOL> import pyfbsdk <EOL> pyfbsdk . FBMessageBox ( title , msg , "<STR_LIT:OK>" ) <EOL> finally : <EOL> print "<STR_LIT>" <EOL> raise exceptions . BaseException ( msg ) <EOL> def error ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" <EOL> if self . isEnabledFor ( ERROR ) : <EOL> self . _log ( ERROR , msg , args , ** kwargs ) <EOL> raise exceptions . BaseException ( msg ) <EOL> def infoDialog ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" <EOL> if self . isEnabledFor ( INFODIALOG ) : <EOL> self . _log ( INFO , msg , args , ** kwargs ) <EOL> title = '<STR_LIT>' <EOL> if len ( args ) > <NUM_LIT:1> : <EOL> title = args [ <NUM_LIT:1> ] <EOL> try : <EOL> import maya . cmds <EOL> result = maya . cmds . confirmDialog ( t = title , m = msg , b = [ '<STR_LIT:OK>' , '<STR_LIT>' ] , db = '<STR_LIT:OK>' , cb = '<STR_LIT>' , ds = '<STR_LIT>' ) <EOL> if result == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) <EOL> except ImportError : <EOL> import pyfbsdk <EOL> pyfbsdk . FBMessageBox ( title , msg , "<STR_LIT:OK>" ) <EOL> finally : <EOL> print "<STR_LIT>" <EOL> def debugDialog ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" <EOL> if self . isEnabledFor ( DEBUGDIALOG ) : <EOL> self . _log ( DEBUG , msg , args , ** kwargs ) <EOL> title = '<STR_LIT>' <EOL> if len ( args ) > <NUM_LIT:1> : <EOL> title = args [ <NUM_LIT:1> ] <EOL> try : <EOL> from maya import cmds <EOL> result = cmds . confirmDialog ( t = title , m = msg , b = [ '<STR_LIT:OK>' , '<STR_LIT>' ] , db = '<STR_LIT:OK>' , cb = '<STR_LIT>' , ds = '<STR_LIT>' ) <EOL> if result == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) <EOL> except RuntimeError : <EOL> import pyfbsdk <EOL> pyfbsdk . FBMessageBox ( title , msg , "<STR_LIT:OK>" ) <EOL> finally : <EOL> print "<STR_LIT>" <EOL> def pcs_logger ( filePathName = '<STR_LIT>' % ( gv . logLocation , getpass . getuser ( ) , getpass . getuser ( ) ) , _logger = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , fresh = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> filePathName = filePathName . replace ( '<STR_LIT:\\>' , '<STR_LIT:/>' ) <EOL> filePath = filePathName [ : filePathName . rfind ( '<STR_LIT:/>' ) ] <EOL> if not os . path . exists ( filePath ) : <EOL> os . makedirs ( filePath ) <EOL> if fresh : <EOL> try : <EOL> if os . path . exists ( filePathName ) : <EOL> os . remove ( filePathName ) <EOL> except RuntimeError : <EOL> print ( "<STR_LIT>" % filePathName ) <EOL> logging . setLoggerClass ( PCSlogging ) <EOL> if not isinstance ( _logger , logging . Logger ) : <EOL> _logger = logging . getLogger ( name ) <EOL> else : <EOL> name = _logger . name <EOL> logging . raiseExceptions = <NUM_LIT:1> <EOL> if sys . version_info [ <NUM_LIT:1> ] >= <NUM_LIT:5> : <EOL> formatter = logging . Formatter ( '<STR_LIT>' ) <EOL> else : <EOL> formatter = logging . Formatter ( '<STR_LIT>' ) <EOL> makeNewFileHandler = <NUM_LIT:1> <EOL> makeNewSMTPHandler = <NUM_LIT:1> <EOL> smtpHandlerFound = <NUM_LIT:0> <EOL> if len ( _logger . handlers ) : <EOL> for hndlr in map ( lambda x : x , _logger . handlers ) : <EOL> if hndlr . __class__ == logging . FileHandler : <EOL> if not hndlr . stream . closed : <EOL> if hndlr . stream . name == filePathName : <EOL> makeNewFileHandler = <NUM_LIT:0> <EOL> else : <EOL> deleteHandler ( _logger . handlers , hndlr ) <EOL> else : <EOL> deleteHandler ( _logger . handlers , hndlr ) <EOL> elif smtpHandlerFound and hndlr . __class__ == logging . handlers . SMTPHandler : <EOL> deleteHandler ( _logger . handlers , hndlr ) <EOL> else : <EOL> smtpHandlerFound = <NUM_LIT:1> <EOL> makeNewSMTPHandler = <NUM_LIT:0> <EOL> if makeNewFileHandler : <EOL> hdlr = logging . FileHandler ( filePathName ) <EOL> hdlr . setFormatter ( formatter ) <EOL> _logger . addHandler ( hdlr ) <EOL> if makeNewSMTPHandler : <EOL> userName = getpass . getuser ( ) <EOL> sHdlr = logging . handlers . SMTPHandler ( MAILHOST , '<STR_LIT>' % ( userName , FROMADDRESS ) , toAddresses , <EOL> '<STR_LIT>' % ( name , userName ) ) <EOL> sHdlr . setLevel ( logging . CRITICAL ) <EOL> _logger . addHandler ( sHdlr ) <EOL> _logger . setLevel ( logging . INFO ) <EOL> return _logger <EOL> def addMoBuHandler ( _logger ) : <EOL> hdlr = logging . StreamHandler ( ) <EOL> formatter = logging . Formatter ( '<STR_LIT>' ) <EOL> hdlr . setFormatter ( formatter ) <EOL> _logger . addHandler ( hdlr ) <EOL> return _logger <EOL> def deleteHandler ( handlers , handler ) : <EOL> """<STR_LIT>""" <EOL> i = <NUM_LIT:0> <EOL> for hnd in handlers : <EOL> if hnd == handler : <EOL> del ( handlers [ i ] ) <EOL> return <EOL> i += <NUM_LIT:1> <EOL> logger = pcs_logger ( ) <EOL> moBuLogger = addMoBuHandler ( pcs_logger ( name = '<STR_LIT>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print '<STR_LIT>' <EOL> else : <EOL> print "<STR_LIT>" </s>
