All pastes #139281 Raw Edit

Something

public python v1 · immutable
#139281 ·published 2006-08-19 20:16 UTC
rendered paste body
import os,sys,timedef writeError(exp):        script_filepath = sys.argv[0]        index = script_filepath.rfind(os.sep)        if index != -1:                script_filename = script_filepath[script_filepath.rfind(os.sep)+1:]        else:                script_filename = script_filepath        header = "-"*((80-len(script_filename))/2)+script_filename+"-"*((80-len(script_filename))/2)        file = open('error.log','a')        file.write(os.linesep)        file.write(header)        file.write(os.linesep)        file.write(time.strftime("%m-%d-%Y-%H-%M"))        file.write(os.linesep)        file.write(str(exp)+os.linesep)        file.write("-"*80)        file.write(os.linesep)        file.close()def test():        try:                open("some_file_that_doesnt_exist",'r')        except Exception,e:                print e                writeError(e)if __name__ == '__main__':        test()