if (len(sys.argv) != 2): printUsage() expCode = upper(sys.argv[1]) try: if (os.getenv("DIFXROOT") == None): sys.exit("Error: DIFXROOT environment must be defined.") configPath = os.getenv("DIFXROOT") + "/conf/difxdb.ini" config = DifxDbConfig(configPath, create=True) # try to open the database connection connection = Connection() connection.type = config.get("Database", "type") connection.server = config.get("Database", "server") connection.port = config.get("Database", "port") connection.user = config.get("Database", "user") connection.password = config.get("Database", "password") connection.database = config.get("Database", "database") connection.echo = False dbConn = Schema(connection) session = dbConn.session() try: experiment = getExperimentByCode(session, expCode) except: raise Exception("Unknown experiment")
if (options.verbose > 0): print "Using options:" for key, value in options.__dict__.items(): print "%s : %s" % (key, value) if len(args) == 0: parser.print_help() exit(0) if (getenv("DIFXROOT") == None): sys.exit("Error: DIFXROOT environment must be defined.") config = DifxDbConfig(getenv("DIFXROOT") + "/conf/difxdb.ini") # try to open the database connection connection = Connection(config) connection.echo = False try: dbConn = Schema(connection) session = dbConn.session() except Exception as e: exitOnError(e) if not isSchemaVersion(session, minSchemaMajor, minSchemaMinor): major, minor = getCurrentSchemaVersionNumber(session) exitOnError( "Current difxdb database schema is %s.%s but %s.%s is minimum requirement" % (major, minor, minSchemaMajor, minSchemaMinor)) action = lower(args[0])