#NEWLINE# def writeToFile( session , container ) : #NEWLINE# #INDENT# global dataFd , errorFd #NEWLINE# try : #NEWLINE# #INDENT# if ( ( not session . failed ) and ( session . dataContainer . title is not None ) ) : #NEWLINE# #INDENT# if ( session is None ) : #NEWLINE# #INDENT# dataFd = open ( 'output.txt' , 'w' ) #NEWLINE# #UNINDENT# dataFd . write ( ( ( ( ( ( container . author . replace ( ',' , '' ) + ',' ) + container . title . replace ( ',' , '' ) ) + ',' ) + session . url ) + '\n' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if session . failed : #NEWLINE# #INDENT# if ( errorFd is None ) : #NEWLINE# #INDENT# errorFd = open ( 'error.txt' , 'w' ) #NEWLINE# #UNINDENT# errorFd . write ( ( ( ( ( ( str ( session . returnCode ) . replace ( ',' , '' ) + ',' ) + str ( session . errorMsg ) . replace ( ',' , '' ) ) + '.' ) + session . url . replace ( ',' , '' ) ) + '\n' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# logger . log ( logging . ERROR , 'Unhandled exception in storage.py' )