Пример #1
0
#!/usr/bin/env python

from MovieCrew import MovieCrew
from QuitException import QuitException
import traceback

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'))
Пример #2
0
          #ask user for runtime
          runtime = promptUserForRuntime()
          #ask user for comments
          comments = promptUserForComments()
          #add an INSERT statement for the new movie
          _inserts.append(INSERT_FORMAT_STRING.format(_nextMid, title, year, stars, mpaa, country, comments, imdbId, seenInTheater, tmdbId, runtime, "'1'"))
          mid = _nextMid

        #ask user for tags for the movie
        print '\nTAGS'
        print '-----\n'
        tagger.promptUserForTag(mid, title, year)
        #ask user for crew members who worked on the movie
        print '\nCREW'
        print '-----'
        crewHandler.promptUserForCrewPerson(mid, title, year)

        if isNew:
          #update the next mid
          _nextMid = _nextMid + 1
      #end if-else
    #end for

    #write out all sql INSERT statements to sql files
    lg('main', 'writing to ' + _movieSqlFile)
    f = open(_movieSqlFile, 'a')
    for insertStatement in _inserts:
      f.write(insertStatement)
    f.close()

    if tagger:
Пример #3
0
    log('main', 'last mid processed (read from ' + TEMP_FILENAME + '): ' + lastProcessed)
    lastProcessed = int(lastProcessed)

    #grab all movies seen from movies file after "last processed"
    initMovies(lastProcessed)
  #process only the requested movies with the given ids
  else:
    log('main', 'mids: ' + str(mids))
    initRequestedMovies(mids)

  try:
    for movie in movies:
      log('main', 'Processing: ' + str(movie))
      lastProcessed = movie['mid']
      movieTagger.promptUserForTag(movie['mid'], movie['title'], movie['year'])
      crewHandler.promptUserForCrewPerson(movie['mid'], movie['title'], movie['year'])
  except QuitException, KeyboardInterrupt:
    pass
  except Exception:
    traceback.print_exc(file=logger)
    traceback.print_exc(file=sys.stdout)
  finally:
    if movieTagger.hasInserts():
      while True:
        response = raw_input('\n**WARNING: There 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':
          movieTagger.writeTagInsertsToFile(tagFile)
          movieTagger.writeTagGivenToInsertsToFile(tagGivenToFile)