#NEWLINE# def _process_responsehandler( self , xml ) : #NEWLINE# #INDENT# ' Process response handler ' #NEWLINE# if ( self . kvp [ 'responsehandler' ] is not None ) : #NEWLINE# #INDENT# LOGGER . debug ( ( 'Processing responsehandler %s.' % self . kvp [ 'responsehandler' ] ) ) #NEWLINE# uprh = urlparse ( self . kvp [ 'responsehandler' ] ) #NEWLINE# if ( uprh . scheme == 'mailto' ) : #NEWLINE# #INDENT# import smtplib #NEWLINE# LOGGER . debug ( 'Email detected.' ) #NEWLINE# smtp_host = 'localhost' #NEWLINE# if self . config . has_option ( 'server' , 'smtp_host' ) : #NEWLINE# #INDENT# smtp_host = self . config . get ( 'server' , 'smtp_host' ) #NEWLINE# #UNINDENT# body = ( 'Subject: pycsw %s results\n\n%s' % ( self . kvp [ 'request' ] , xml ) ) #NEWLINE# try : #NEWLINE# #INDENT# LOGGER . debug ( 'Sending email.' ) #NEWLINE# msg = smtplib . SMTP ( smtp_host ) #NEWLINE# msg . sendmail ( self . config . get ( 'metadata:main' , 'contact_email' ) , uprh . path , body ) #NEWLINE# msg . quit ( ) #NEWLINE# LOGGER . debug ( 'Email sent successfully.' ) #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# LOGGER . debug ( ( 'Error processing email: %s.' % str ( err ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( uprh . scheme == 'ftp' ) : #NEWLINE# #INDENT# import ftplib #NEWLINE# LOGGER . debug ( 'FTP detected.' ) #NEWLINE# try : #NEWLINE# #INDENT# LOGGER . debug ( 'Sending to FTP server.' ) #NEWLINE# ftp = ftplib . FTP ( uprh . hostname ) #NEWLINE# if ( uprh . username is not None ) : #NEWLINE# #INDENT# ftp . login ( uprh . username , uprh . password ) #NEWLINE# #UNINDENT# ftp . storbinary ( ( 'STOR %s' % uprh . path [ 1 : ] ) , StringIO ( xml ) ) #NEWLINE# ftp . quit ( ) #NEWLINE# LOGGER . debug ( 'FTP sent successfully.' ) #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# LOGGER . debug ( ( 'Error processing FTP: %s.' % str ( err ) ) )