for insertStatement in _inserts: f.write(insertStatement) f.close() if tagger: writeOutTagInserts(tagger) if crewHandler: writeOutCrewInserts(crewHandler) except QuitException: lg('main', 'caught QuitException') except Exception as e: lg('main', 'caught Exception: ' + str(e)) print '\t***ERROR: Exception caught' if crewHandler and crewHandler.hasInserts(): while True: response = raw_input('\nThere are still unwritten crew sql insert statements. Write them out? ').lower() if response not in ['y','n']: print "Only 'y'/'n'\n" continue if response == 'y': writeOutCrewInserts(crewHandler) break if tagger and tagger.hasInserts(): while True: response = raw_input('\nThere are still unwritten tag sql insert statements. Write them out? ').lower() if response not in ['y','n']: print "Only 'y'/'n'\n" continue if response == 'y':
if __name__ == '__main__': log = open('/home/thayes/Projects/FiLTH/logs/MovieCrewTest.log', 'w') movieCrew = None try: movieCrew = MovieCrew('/home/thayes/Projects/FiLTH/sql/worked_on.sql', '/home/thayes/Projects/FiLTH/sql/crew_person.sql', log) movies = [(1063, 'Michael Clayton', 2007), (792, 'Il Postino', 1997), (1460, 'Shawshank', 1994)] for movie in movies: movieCrew.promptUserForCrewPerson(movie[0], movie[1], movie[2]) except QuitException: print '\nQUITTING\n' except Exception as e: print '\n***EXCEPTION!***' traceback.print_exc() finally: if movieCrew: if movieCrew.hasInserts(): while True: response = raw_input('\nThere are still unwritten sql insert statements. Write them out? ').lower() if response not in ['y','n']: print "Only 'y'/'n'\n" continue if response == 'y': movieCrew.writeCrewInsertsToFile(open('/home/thayes/Projects/FiLTH/sql/crew_person.sql', 'a')) movieCrew.writeWorkedOnInsertsToFile(open('/home/thayes/Projects/FiLTH/sql/worked_on.sql', 'a')) break else: break movieCrew.close() log.close()