Changeset 2397


Ignore:
Timestamp:
12/04/07 11:52:15 (12 years ago)
Author:
pjkersha
Message:

security/python/ndg.security.server/ndg/security/server/Log.py: added handler for writing to system log

security/python/ndg.security.test/ndg/security/test/Log: package for Log class unit tests.

Location:
TI12-security/trunk/python
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg-security-install.py

    r2391 r2397  
    1919from setuptools.command.easy_install import main 
    2020         
    21  
     21class SecurityInstallError(Exception): 
     22    """Errors related to security installation""" 
     23     
    2224class SecurityInstall(object): 
    2325    '''Wrapper class for NDG security installation 
     
    185187             
    186188        except IOError, (errMsg, e): 
    187             raise SystemExit, 'Error retrieving Twisted from "%s": %s' % \ 
     189            raise SecurityInstallError, 'Error retrieving Twisted from "%s": %s' % \ 
    188190                                                    (twistedTarURI, e[1]) 
    189191        except Exception, e: 
    190             raise SystemExit, 'Error retrieving Twisted from "%s": %s' % \ 
     192            raise SecurityInstallError, 'Error retrieving Twisted from "%s": %s' % \ 
    191193                                                    (twistedTarURI, str(e)) 
    192194 
     
    200202            twistedDir=os.path.splitext(os.path.splitext(twistedTarBz)[0])[0] 
    201203        except Exception: 
    202             raise SystemExit, \ 
     204            raise SecurityInstallError, \ 
    203205            'Error getting Twisted dir path from tar.bz file name: "%s"' % \ 
    204206                twistedTarBz 
     
    208210            retCode = call([sys.prefix+'/bin/python', 'setup.py', 'install']) 
    209211        except OSError, e: 
    210             raise SystemExit, "Error calling setup install for Twisted: " + \ 
    211                               str(e) 
     212            raise SecurityInstallError, \ 
     213                        "Error calling setup install for Twisted: " + str(e) 
    212214         
    213215        if retCode != 0: 
    214             raise SystemExit, "Twisted setup install returned %d" % retCode 
     216            raise SecurityInstallError, "Twisted setup install returned %d" %\ 
     217                                        retCode 
    215218         
    216219        os.chdir('..') 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/Log.py

    r2270 r2397  
    33NERC Data Grid Project 
    44 
    5 P J Kershaw 10/05/06 
     5@author P J Kershaw 10/05/06 
    66 
    7 Copyright (C) 2006 CCLRC & NERC 
     7@copyright (C) 2006 CCLRC & NERC 
    88 
    9 This software may be distributed under the terms of the Q Public License, 
    10 version 1.0 or later. 
     9@license This software may be distributed under the terms of the Q Public  
     10License, version 1.0 or later. 
    1111""" 
    1212 
     
    2323class LogError(Exception): 
    2424    """Exception handling for NDG Logging class.""" 
    25      
    26     def __init__(self, msg): 
    27         self.__msg = msg 
    28           
    29     def __str__(self): 
    30         return self.__msg 
    31  
    3225 
    3326#_____________________________________________________________________________ 
     
    3528    """NDG Logging class""" 
    3629     
    37     __msgFmt = '%(asctime)s %(name)s: %(levelname)-8s %(message)s' 
    38     __dateFmt = '%d %b %Y %H:%M:%S' 
     30    msgFmt = '%(asctime)s %(name)s: %(levelname)-8s %(message)s' 
     31    dateFmt = '%d %b %Y %H:%M:%S' 
    3932     
    4033    # Log file size limit and number of backups saved 
    41     __maxBytes = 1048576 
    42     __backUpCnt = 10 
     34    maxBytes = 1048576 
     35    backUpCnt = 10 
    4336     
    44     def __init__(self, logName='', logFilePath=None, console=False): 
     37    def __init__(self,  
     38                 logName='',  
     39                 logFilePath=None,  
     40                 console=False, 
     41                 sysLog=False, 
     42                 sysLogHandlerKw={}): 
    4543        """NDG Logging class 
    4644         
     
    5452         
    5553        # Set a format for messages 
    56         formatter = logging.Formatter(fmt=self.__msgFmt,  
    57                                       datefmt=self.__dateFmt) 
     54        formatter = logging.Formatter(fmt=self.msgFmt, datefmt=self.dateFmt) 
    5855 
    5956 
     
    7572        if logFilePath: 
    7673            fileLog = RotatingFileHandler(logFilePath,  
    77                                           maxBytes=self.__maxBytes,  
    78                                           backupCount=self.__backUpCnt) 
     74                                          maxBytes=self.maxBytes,  
     75                                          backupCount=self.backUpCnt) 
    7976            fileLog.setFormatter(formatter) 
    8077             
     
    8380             
    8481            self.addHandler(fileLog) 
     82             
     83        if sysLog: 
     84            sysLogHandler = SysLogHandler(**sysLogHandlerKw) 
     85            sysLogHandler.setFormatter(formatter) 
     86             
     87            sysLogHandler.setLevel(logging.DEBUG) 
     88             
     89            self.addHandler(sysLogHandler) 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/attAuthorityClientTest.cfg

    r2350 r2397  
    2222# Password protecting client private key - if omitted it will be prompted for 
    2323# from tty 
    24 #userprikeypwd =  
     24userprikeypwd =  
    2525usercertfilepath = ./proxy-cert.pem 
    2626userprikeyfilepath = ./proxy-key.pem 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/siteAAttAuthorityProperties.xml

    r2350 r2397  
    33    <name>Site A</name> 
    44    <portNum>5000</portNum> 
    5     <useSSL></useSSL> <!-- leave blank to use http --> 
     5    <useSSL>Yes</useSSL> <!-- leave blank to use http --> 
    66    <sslCertFile>$NDGSEC_AA_UNITTEST_DIR/aa-cert.pem</sslCertFile> 
    77    <sslKeyFile>$NDGSEC_AA_UNITTEST_DIR/aa-key.pem</sslKeyFile> 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/MyProxy/myProxyClientTest.cfg

    r2298 r2397  
    2121 
    2222[test2GetDelegation] 
    23 #username: sstljakTestUser 
    24 username: gabriel 
     23username: sstljakTestUser 
     24#username: gabriel 
    2525passphrase: 
    2626 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/MyProxy/myProxyProperties.xml

    r2298 r2397  
    2020        Set "host/" prefix to host cert CN as is default with globus 
    2121        --> 
    22         <serverCNprefix></serverCNprefix>        
     22        <serverCNprefix>host/</serverCNprefix>   
    2323        <!-- 
    2424        Nb. GRID_SECURITY_DIR environment variable if set, overrides this setting 
Note: See TracChangeset for help on using the changeset viewer.