Example #1
0
def main(argv):
    '''Where magick happens.'''
    args = parse_args(argv[1:])
    setup_logging(args.logfile, args.log_level)
    log('\n### SQL_USER.PY: dbname=' + args.database + ' user='******' sqlfile=' + args.sql_file + ' host=' + args.host + ' ###')
    #log('### Arguments: ' + ' '.join(argv[1:]))

    # make sure main file exists
    if not util.file_exists(args.sql_file):
        log('ERROR: The file ' + args.sql_file + ' does not exist. Exiting.', logging.ERROR)
        sys.exit(EXIT_FAIL)

    # make sure all subscripts exist
    try:
        subs = util.find_subscripts(args.sql_file, args.dbms)
    except IOError, e:
        log('ERROR: One of the subscripts does not exist. Opening it threw and exception: ', logging.ERROR)
        log(e, logging.ERROR)
        sys.exit(EXIT_FAIL)
Example #2
0
def test_run(args):
        errors = False
        for handler in logging.getLogger('console').handlers:
            handler.setLevel(logging.DEBUG)
        log('## Doing a test run. ##')

        if not util.file_exists(args.sql_file):
            errors = True
            log('ERROR: SQL script file ' + args.sql_file + ' does not exist.', logging.ERROR)
            log('Exiting...')
            sys.exit(EXIT_FAIL)
        else:
            log('Found script file ' + args.sql_file)

        # make sure all subscripts exist
        log('## Looking for subscripts')
        try:
            subs = util.find_subscripts(args.sql_file, args.dbms)
        except IOError, e:
            errors = True
            log('ERROR: One of the subscripts does not exist. Opening it threw and exception: ', logging.ERROR)
            log(e, logging.ERROR)
            sys.exit(EXIT_FAIL)