def testValidConnection(self): self.assertGreater(len(utl.getAssets('TestValDb')), 0) self.assertIn((1,'DDL'), utl.getAssets('TestValDb').keys())
import sys import os import argparse as ap # Parse arguments pars= ap.ArgumentParser(description="Load GASCI-formatted data from csv file to ValDb") pars.add_argument('file',help='name of csv file in "dir" with GASCI/TTSE price history') pars.add_argument('dir',nargs='?', default='/Users/dpollard2/Documents/Work/Pollards&Filles/Research/GASCI_Analysis/GASCI_Data/Jan2012/', help='directory holding GASCI csv files with price histories') pars.add_argument('-ex --exchange',dest='exch',required=True,help='name of exchange e.g. GASCI') pars.add_argument('-db --dbase',dest='dbase',default='TestValDb',choices=['TestValDb','PeFValDb'],help='name of database') args= pars.parse_args() try: asst= utl.getAssets( args.dbase) exchange = utl.getExchanges( args.dbase) exID = exchange[(args.exch).upper()] except Exception, e: sys.exit('Exiting %s...Problem with Assets or Exchanges; %s' % (sys.argv[0], e)) # check file available filename = args.dir + args.file print filename if not(os.access(filename, os.F_OK)): sys.exit("Exiting ... File %s not found" % filename) # connect to database conn = utl.connectMysql(args.dbase) csr = conn.cursor()