Esempio n. 1
0
def main():
    logging.basicConfig(
        format=
        '%(asctime)s\t%(name)-16s\t%(funcName)-16s\t[%(levelname)-8s] %(message)s',
        level=logging.INFO)
    logger = logging.getLogger('main')
    blurb = "Symbol Adder"
    logger.warning(blurb)
    ## ARGPARSE
    parser = argparse.ArgumentParser(description=blurb)
    #Model building
    parser.add_argument('--exchange',
                        dest='exchange',
                        type=str,
                        help='Exchange')
    parser.add_argument('--symbol',
                        dest='symbol',
                        type=str,
                        help='Stock symbol')
    parser.add_argument('--name',
                        dest='name',
                        type=str,
                        help='Human readable name')
    parser.add_argument('--enable', dest='enable', type=str, help='Enable')
    #TODO: Add means to query exchange and symbols (--get)
    #Get the arguments
    args = parser.parse_args()
    logger.info("Args: %s", args)

    #Connect to DB
    db = db_connection.DBConnection()
    db.connect()
    #Get change state
    state = getEnableState(args.enable)
    logging.info("Enabled state: %s", state)
    # Change DB
    if (None != args.symbol):
        if (None != state):
            logger.info("Enable Symbol: %s - %s", args.symbol, state)
            setSymbolEnabled(db, args.symbol, state)
        else:
            logger.info("Add Symbol: %s", args.symbol)
            addSymbol(db, args.exchange, args.symbol, args.name)
    else:
        if (None != state):
            logger.info("Enable Exchange: %s - %s", args.exchange, state)
            setExchangeEnabled(db, args.exchange, state)
        else:
            logger.info("Add Exchange: %s", args.exchange)
            addExchange(db, args.exchange)
    #Commit
    logger.info("Commiting transaction")
    db.commit()
Esempio n. 2
0
 def __init__(self):
     self.feeds_object = feeds_core_api.FeedsCoreAPI()
     self.database = db_connection.DBConnection()
Esempio n. 3
0
	def __init__(self):
		self.database		=	db_connection.DBConnection()
		self.logger			=	logging.getLogger('DataImportTicker')
		self.todayDate		=	None
Esempio n. 4
0
 def __init__(self):
     self.database = db_connection.DBConnection()
     self.logger = logging.getLogger("ImportBase")
     pass
Esempio n. 5
0
 def __init__(self, port):
     super(StockTickerServer, self).__init__(port)
     self.logger = logging.getLogger('StockTickerServer')
     # Service of data retrieval
     self.database = db_connection.DBConnection()