def valid_args(args): """ Checks to see if the arguments make sense. :param args: The command line arguments. :return: True if valid, false otherwise. """ is_valid = True # allow descriptions to be shown and no tests run. if not args.show_tests: if not args.database: eprint("A database name must be provided.") is_valid = False if not args.database_file and not args.ts_ip: eprint( "Either a database file or ThoughtSpot IP must be provided.") is_valid = False if args.database_file and args.ts_ip: eprint("Only database_file or ts_ip can be provided.") is_valid = False if args.worksheet_file: if not os.path.exists(args.worksheet_file): eprint(f"Worksheet file {args.worksheet_file} doesn't exist.") is_valid = False return is_valid
def valid_args(args): """ Checks to see if the arguments make sense. :param args: The command line arguments. :return: True if valid, false otherwise. """ # make sure there is a to_ flag since data has to come from somewhere unless this is just creating blank Excel. if not args.empty and not args.version and not args.from_ddl \ and not args.from_excel and not args.to_excel and not args.from_ts: eprint( "--version, --empty, --from_ddl, --from_excel, or from_ts must be provided as arguments." ) return False if (args.from_ddl or args.from_ts) and not args.database: eprint("--from_ddl and --from_ts require the --database parameter.") return False return True
def read_excel(args): """ Reads the database description from XLS and returns a database model. Note that XLSReader can read multiple databases at a time, but convert only supports one. If there are more than one database, the first will be returned and an error message written. :param args: The command line arguments. :returns: The database read from Excel. :rtype: Database """ reader = XLSReader() databases = reader.read_xls(filepath=args.from_excel) if len(databases) == 0: eprint("ERROR: No databases read.") return None if len(databases) > 1: eprint("WARNING: multiple databases read. Only using %s" % list(databases.values())[0].database_name) return list(databases.values())[0]
def valid_args(args): """ Checks to see if the arguments make sense. :param args: The command line arguments. :return: True if valid, False otherwise. """ ret_value = True # make sure there is a to_ flag since data has to come from somewhere unless this is just creating blank Excel. if not args.ddl1 or not args.ddl2: eprint("--ddl1 and --ddl2 must be provided") ret_value = False else: if not os.path.exists(args.ddl1): eprint("file %s doesn't exist" % args.ddl1) ret_value = False if not os.path.exists(args.ddl2): eprint("file %s doesn't exist" % args.ddl2) ret_value = False return ret_value