Beispiel #1
0
def main():
	import themortgagemeter_db
	import themortgagemeter_utils
	themortgagemeter_db.open_db()
	if args.logging == 'DEBUG':
		logger = themortgagemeter_utils.setup_logging(logging.DEBUG)
	elif args.logging == 'INFO':
		logger = themortgagemeter_utils.setup_logging(logging.INFO)
	elif args.logging == 'WARNING':
		logger = themortgagemeter_utils.setup_logging(logging.WARNING)
	elif args.logging == 'ERROR':
		logger = themortgagemeter_utils.setup_logging(logging.ERROR)
	elif args.logging == 'CRITICAL':
		logger = themortgagemeter_utils.setup_logging(logging.CRITICAL)
	logger.info('Program starting: %s', args.institution)
	try:
		if args.institution == 'ONS':
			import ons
			ons.ons_main()
			print 'asd'
		else:
			raise Exception('Need to supply an institution','')
		if not args.test:
			themortgagemeter_db.db_connection.commit()
		else:
			logger.info('Not committing data, as --test passed in')
	except Exception as e:
		logger.critical('Error was thrown, quitting')
		logger.exception('Error was:')
	logger.info('Program complete for institution: %s', args.institution)
	themortgagemeter_db.commit_db()
Beispiel #2
0
def main():
    import themortgagemeter_db
    import themortgagemeter_utils
    themortgagemeter_db.open_db()
    if args.logging == 'DEBUG':
        logger = themortgagemeter_utils.setup_logging(logging.DEBUG)
    elif args.logging == 'INFO':
        logger = themortgagemeter_utils.setup_logging(logging.INFO)
    elif args.logging == 'WARNING':
        logger = themortgagemeter_utils.setup_logging(logging.WARNING)
    elif args.logging == 'ERROR':
        logger = themortgagemeter_utils.setup_logging(logging.ERROR)
    elif args.logging == 'CRITICAL':
        logger = themortgagemeter_utils.setup_logging(logging.CRITICAL)
    logger.info('Program starting: %s', args.institution)
    try:
        if args.institution == 'ONS':
            import ons
            ons.ons_main()
            print 'asd'
        else:
            raise Exception('Need to supply an institution', '')
        if not args.test:
            themortgagemeter_db.db_connection.commit()
        else:
            logger.info('Not committing data, as --test passed in')
    except Exception as e:
        logger.critical('Error was thrown, quitting')
        logger.exception('Error was:')
    logger.info('Program complete for institution: %s', args.institution)
    themortgagemeter_db.commit_db()
Beispiel #3
0
def main():
    global changes
    import themortgagemeter_db
    import themortgagemeter_utils
    themortgagemeter_db.open_db()
    if args.logging == 'DEBUG':
        logger = themortgagemeter_utils.setup_logging(logging.DEBUG,
                                                      stdout=args.stdout)
    elif args.logging == 'INFO':
        logger = themortgagemeter_utils.setup_logging(logging.INFO,
                                                      stdout=args.stdout)
    elif args.logging == 'WARNING':
        logger = themortgagemeter_utils.setup_logging(logging.WARNING,
                                                      stdout=args.stdout)
    elif args.logging == 'ERROR':
        logger = themortgagemeter_utils.setup_logging(logging.ERROR,
                                                      stdout=args.stdout)
    elif args.logging == 'CRITICAL':
        logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,
                                                      stdout=args.stdout)
    elif args.logging == 'STDOUT':
        logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,
                                                      stdout=args.stdout)
    logger.info('Program starting: %s', args.institution)
    try:
        #if args.institution == 'NTNWD':
        #	import nationwide
        #	nationwide.nationwide_main(args.static,args.forcedelete,logger)
        if args.institution == 'HSBC':
            import hsbc
            hsbc.hsbc_main(args.static, args.forcedelete, logger)
        elif args.institution == 'HLFX':
            import halifax
            halifax.halifax_main(args.static, args.forcedelete, logger)
        else:
            raise Exception('Need to supply an institution', '')
        if not args.test:
            themortgagemeter_db.db_connection.commit()
        else:
            logger.info('Not committing data, as --test passed in')
            themortgagemeter_db.db_connection.rollback()
    except Exception as e:
        logger.critical('Error was thrown, quitting')
        logger.exception('Error was:')
        themortgagemeter_utils.record_alert('ERROR: ' + args.institution,
                                            logger,
                                            themortgagemeter_db.db_connection,
                                            themortgagemeter_db.cursor)
    logger.info('Program complete for institution: %s', args.institution)
    # TOOD: why does this never seem to be set to true?
    global changes
    logger.info('Changes is: ' + str(changes))
    themortgagemeter_db.commit_db()
Beispiel #4
0
def main():
	global sender
	global contentfile
	global subject
	global mortgage_change_content
	global error_content
	global passfile
	themortgagemeter_db.open_db()
	# Perform qry_get_mortgage_change_alerts query
	# for each alert_id, send an email
	# If the email is successful, delete the row from the table, commit and continue.

	# Now mortgage change alerts.
	themortgagemeter_db.cursor.execute(qry_get_mortgage_change_alerts)
	alert_rows = themortgagemeter_db.cursor.fetchall()
	themortgagemeter_db.cursor.execute(qry_get_mailsubscribers)
	subscriber_rows = themortgagemeter_db.cursor.fetchall()
	print "Rows returned"
	print alert_rows
	for alert_row in alert_rows:
		print "alert row"
		print alert_row
		alert_id = alert_row[0]
		alert = alert_row[1]
		print "subscriber rows"
		for subscriber_row in subscriber_rows:
			print subscriber_row
			to = subscriber_row[0]
			# Send alert to subscriber
			# Wait a random length of time in case this triggers spam filters.
			time.sleep(random.randint(10,20))
			simple_mailer.main(sender,to,passfile,subject,contentfile,mortgage_change_content)
	# if we are here, we assume all has gone OK, and we delete the relevant alerts
	themortgagemeter_db.cursor.execute(qry_delete_mortgage_change_alerts)

	# Now errors.
	themortgagemeter_db.cursor.execute(qry_get_error_alerts)
	alert_rows = themortgagemeter_db.cursor.fetchall()
	for alert_row in alert_rows:
		alert_id = alert_row[0]
		alert = alert_row[1]
		simple_mailer.main(sender,'THEMORTGAGEMETER_ADMINEMAIL',passfile,subject,contentfile,error_content)
	# if we are here, we assume all has gone OK, and we delete the relevant alerts
	themortgagemeter_db.cursor.execute(qry_delete_error_alerts)

	# cleanup
	themortgagemeter_db.commit_db()
Beispiel #5
0
def main():
	global changes
	import themortgagemeter_db
	import themortgagemeter_utils
	themortgagemeter_db.open_db()
	if args.logging == 'DEBUG':
		logger = themortgagemeter_utils.setup_logging(logging.DEBUG,stdout=args.stdout)
	elif args.logging == 'INFO':
		logger = themortgagemeter_utils.setup_logging(logging.INFO,stdout=args.stdout)
	elif args.logging == 'WARNING':
		logger = themortgagemeter_utils.setup_logging(logging.WARNING,stdout=args.stdout)
	elif args.logging == 'ERROR':
		logger = themortgagemeter_utils.setup_logging(logging.ERROR,stdout=args.stdout)
	elif args.logging == 'CRITICAL':
		logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,stdout=args.stdout)
	elif args.logging == 'STDOUT':
		logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,stdout=args.stdout)
	logger.info('Program starting: %s', args.institution)
	try:
		#if args.institution == 'NTNWD':
		#	import nationwide
		#	nationwide.nationwide_main(args.static,args.forcedelete,logger)
		if args.institution == 'HSBC':
			import hsbc
			hsbc.hsbc_main(args.static,args.forcedelete,logger)
		elif args.institution == 'HLFX':
			import halifax
			halifax.halifax_main(args.static,args.forcedelete,logger)
		else:
			raise Exception('Need to supply an institution','')
		if not args.test:
			themortgagemeter_db.db_connection.commit()
		else:
			logger.info('Not committing data, as --test passed in')
			themortgagemeter_db.db_connection.rollback()
	except Exception as e:
		logger.critical('Error was thrown, quitting')
		logger.exception('Error was:')
		themortgagemeter_utils.record_alert('ERROR: ' + args.institution,logger,themortgagemeter_db.db_connection,themortgagemeter_db.cursor)
	logger.info('Program complete for institution: %s', args.institution)
	# TOOD: why does this never seem to be set to true?
	global changes
	logger.info('Changes is: ' + str(changes))
	themortgagemeter_db.commit_db()
def main():
    global changes
    import themortgagemeter_db
    import themortgagemeter_utils
    themortgagemeter_db.open_db()
    if args.logging == 'DEBUG':
        logger = themortgagemeter_utils.setup_logging(logging.DEBUG,
                                                      stdout=args.stdout)
    elif args.logging == 'INFO':
        logger = themortgagemeter_utils.setup_logging(logging.INFO,
                                                      stdout=args.stdout)
    elif args.logging == 'WARNING':
        logger = themortgagemeter_utils.setup_logging(logging.WARNING,
                                                      stdout=args.stdout)
    elif args.logging == 'ERROR':
        logger = themortgagemeter_utils.setup_logging(logging.ERROR,
                                                      stdout=args.stdout)
    elif args.logging == 'CRITICAL':
        logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,
                                                      stdout=args.stdout)
    elif args.logging == 'STDOUT':
        logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,
                                                      stdout=args.stdout)
    logger.info('Program starting: %s', args.institution)
    try:
        if args.institution == 'HSBC':
            import hsbc
            hsbc.hsbc_main(args.static, args.forcedelete, logger)
        elif args.institution == 'NTNWD':
            import nationwide
            nationwide.nationwide_main(args.static, args.forcedelete, logger)
        elif args.institution == 'LLOYDS':
            import lloyds
            lloyds.lloyds_main(args.static, args.forcedelete, logger)
        elif args.institution == 'SNTNDR':
            import santander
            santander.santander_main(args.static, args.forcedelete, logger)
        elif args.institution == 'HLFX':
            import halifax
            halifax.halifax_main(args.static, args.forcedelete, logger)
        elif args.institution == 'NTWST':
            import natwest
            natwest.natwest_main(args.static, args.forcedelete, logger)
        elif args.institution == 'NRTHNR':
            import northernrock
            northernrock.northernrock_main(args.static, args.forcedelete,
                                           logger)
        elif args.institution == 'CHLS':
            import chelsea
            chelsea.chelsea_main(args.static, args.forcedelete, logger)
        elif args.institution == 'YRKSHR':
            import yorkshire
            yorkshire.yorkshire_main(args.static, args.forcedelete, logger)
        elif args.institution == 'TSC':
            import tesco
            tesco.tesco_main(args.static, args.forcedelete, logger)
        elif args.institution == 'SKPTN':
            import skipton
            skipton.skipton_main(args.static, args.forcedelete, logger)
        elif args.institution == 'PSTFFC':
            import post_office
            post_office.post_office_main(args.static, args.forcedelete, logger)
        elif args.institution == 'FRSTDRCT':
            import first_direct
            first_direct.first_direct_main(args.static, args.forcedelete,
                                           logger)
        else:
            raise Exception('Need to supply an institution', '')
        if not args.test:
            themortgagemeter_db.db_connection.commit()
        else:
            logger.info('Not committing data, as --test passed in')
            themortgagemeter_db.db_connection.rollback()
    except Exception as e:
        logger.critical('Error was thrown, quitting')
        logger.exception('Error was:')
        themortgagemeter_utils.record_alert('ERROR: ' + args.institution,
                                            logger,
                                            themortgagemeter_db.db_connection,
                                            themortgagemeter_db.cursor)
    logger.info('Program complete for institution: %s', args.institution)
    # TOOD: why does this never seem to be set to true?
    global changes
    logger.info('Changes is: ' + str(changes))
    themortgagemeter_db.commit_db()
Beispiel #7
0
def main():
	global changes
	import themortgagemeter_db
	import themortgagemeter_utils
	themortgagemeter_db.open_db()
	if args.logging == 'DEBUG':
		logger = themortgagemeter_utils.setup_logging(logging.DEBUG,stdout=args.stdout)
	elif args.logging == 'INFO':
		logger = themortgagemeter_utils.setup_logging(logging.INFO,stdout=args.stdout)
	elif args.logging == 'WARNING':
		logger = themortgagemeter_utils.setup_logging(logging.WARNING,stdout=args.stdout)
	elif args.logging == 'ERROR':
		logger = themortgagemeter_utils.setup_logging(logging.ERROR,stdout=args.stdout)
	elif args.logging == 'CRITICAL':
		logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,stdout=args.stdout)
	elif args.logging == 'STDOUT':
		logger = themortgagemeter_utils.setup_logging(logging.CRITICAL,stdout=args.stdout)
	logger.info('Program starting: %s', args.institution)
	try:
		if args.institution == 'HSBC':
			import hsbc
			hsbc.hsbc_main(args.static,args.forcedelete,logger)
		elif args.institution == 'NTNWD':
			import nationwide
			nationwide.nationwide_main(args.static,args.forcedelete,logger)
		elif args.institution == 'LLOYDS':
			import lloyds
			lloyds.lloyds_main(args.static,args.forcedelete,logger)
		elif args.institution == 'SNTNDR':
			import santander
			santander.santander_main(args.static,args.forcedelete,logger)
		elif args.institution == 'HLFX':
			import halifax
			halifax.halifax_main(args.static,args.forcedelete,logger)
		elif args.institution == 'NTWST':
			import natwest
			natwest.natwest_main(args.static,args.forcedelete,logger)
		elif args.institution == 'NRTHNR':
			import northernrock
			northernrock.northernrock_main(args.static,args.forcedelete,logger)
		elif args.institution == 'CHLS':
			import chelsea
			chelsea.chelsea_main(args.static,args.forcedelete,logger)
		elif args.institution == 'YRKSHR':
			import yorkshire
			yorkshire.yorkshire_main(args.static,args.forcedelete,logger)
		elif args.institution == 'TSC':
			import tesco
			tesco.tesco_main(args.static,args.forcedelete,logger)
		elif args.institution == 'SKPTN':
			import skipton
			skipton.skipton_main(args.static,args.forcedelete,logger)
		elif args.institution == 'PSTFFC':
			import post_office
			post_office.post_office_main(args.static,args.forcedelete,logger)
		elif args.institution == 'FRSTDRCT':
			import first_direct
			first_direct.first_direct_main(args.static,args.forcedelete,logger)
		else:
			raise Exception('Need to supply an institution','')
		if not args.test:
			themortgagemeter_db.db_connection.commit()
		else:
			logger.info('Not committing data, as --test passed in')
			themortgagemeter_db.db_connection.rollback()
	except Exception as e:
		logger.critical('Error was thrown, quitting')
		logger.exception('Error was:')
		themortgagemeter_utils.record_alert('ERROR: ' + args.institution,logger,themortgagemeter_db.db_connection,themortgagemeter_db.cursor)
	logger.info('Program complete for institution: %s', args.institution)
	# TOOD: why does this never seem to be set to true?
	global changes
	logger.info('Changes is: ' + str(changes))
	themortgagemeter_db.commit_db()