def setUp(self): initdb(postgres_test_db, postgres_user, postgres_password) self.session = model.SessionManager.create(postgres_test_db, postgres_user, postgres_password) from pypitches import select_gamedirs from pypitches import load select_gamedirs.classify_local_dirs_by_filesystem(static_dir) try: load.load() except IntegrityError: import pdb pdb.set_trace() self.assertEqual(self.session.query(Game).count(), 3)
def main(): try: cmd = sys.argv[1] assert (cmd in cmds) except: invocations = ["python pypitches.py {0}".format(cmd) for cmd in cmds] print "usage: " + "\n ".join(invocations) sys.exit() if cmd == 'initdb': setup_postgres.initdb(postgres_db, postgres_user, postgres_password) sys.exit() else: import model model.SessionManager.create(postgres_db, postgres_user, postgres_password) import load from web.app import app import select_gamedirs from plot_pitch_locations import do_plots if cmd == 'web': app.run() elif cmd == 'webtest': app.run('pypitchestest', 'pypitches', 'slider') elif cmd == 'ipython': embed() elif cmd == 'file': # will generate output by a config file # a la plot_pitch_locations.py assert len(sys.argv) > 2, "usage: python pypitches.py file file.yaml" do_plots(sys.argv[2]) elif cmd == 'download': # hit the MLBAM server and get it all pass elif cmd == 'classify': with model.SessionManager.get().begin_nested(): static_dir = sys.argv[2] select_gamedirs.classify_local_dirs_by_filesystem(static_dir) model.SessionManager.commit() elif cmd == 'load': statuses = set(sys.argv[2:]) or set(['final']) with model.SessionManager.get().begin_nested(): load.load(statuses) model.SessionManager.commit()
def main(): try: cmd = sys.argv[1] assert(cmd in cmds) except: invocations = ["python pypitches.py {0}".format(cmd) for cmd in cmds] print "usage: " + "\n ".join(invocations) sys.exit() if cmd == 'initdb': setup_postgres.initdb(postgres_db, postgres_user, postgres_password) sys.exit() else: import model model.SessionManager.create(postgres_db, postgres_user, postgres_password) import load from web.app import app import select_gamedirs from plot_pitch_locations import do_plots if cmd == 'web': app.run() elif cmd == 'webtest': app.run('pypitchestest', 'pypitches', 'slider') elif cmd == 'ipython': embed() elif cmd == 'file': # will generate output by a config file # a la plot_pitch_locations.py assert len(sys.argv) > 2, "usage: python pypitches.py file file.yaml" do_plots(sys.argv[2]) elif cmd == 'download': # hit the MLBAM server and get it all pass elif cmd == 'classify': with model.SessionManager.get().begin_nested(): static_dir = sys.argv[2] select_gamedirs.classify_local_dirs_by_filesystem(static_dir) model.SessionManager.commit() elif cmd == 'load': statuses=set(sys.argv[2:]) or set(['final']) with model.SessionManager.get().begin_nested(): load.load(statuses) model.SessionManager.commit()
def setUp(self): # Destroy/Create test database initdb(postgres_test_db, postgres_user, postgres_password) self.session = model.SessionManager.create(postgres_test_db, postgres_user, postgres_password)