def __get_sql_file_path(self, fname): from arjuna.core.utils import file_utils from arjuna import Arjuna, ArjunaOption fpath = os.path.abspath(os.path.join(self._config.value(ArjunaOption.DBAUTO_SQL_DIR), fname)) if file_utils.is_file(fpath): return fpath else: for linked_project in reversed(Arjuna.get_linked_projects()): fpath = os.path.abspath(os.path.join(linked_project.ref_conf.value(ArjunaOption.DBAUTO_SQL_DIR), fname)) if file_utils.is_file(fpath): return fpath raise Exception("DBAuto SQL File not found: {}".format(fname))
def get_localizer_file_path(self, ldir, fpath): if file_utils.is_absolute_path(fpath): if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return fpath else: fpath = os.path.abspath(os.path.join(ldir, fpath)) if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return fpath
def get_deps_dir_path(fpath): from arjuna.core.utils import file_utils if file_utils.is_absolute_path(fpath): if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception("Not a directory: {}".format(fpath)) return fpath else: fpath = os.path.abspath( os.path.join( self.ref_config.value(ArjunaOption.PROJECT_ROOT_DIR), fpath)) if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception("Not a directory: {}".format(fpath)) return fpath
def load_options_from_file(self, fpath): if file_utils.is_absolute_path(fpath): if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) else: from arjuna import Arjuna, ArjunaOption conf_dir = self.__default_ref_config.arjuna_options.value( ArjunaOption.CONF_DIR) fpath = os.path.abspath(os.path.join(conf_dir, fpath)) if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return EditableConfig.from_file( file_path=fpath, creation_context=f"Ad-hoc configuration file at {fpath}")
def __init__(self, path=None, delimiter="\t"): super().__init__() self.path = path self.delimiter = delimiter data_dir = Arjuna.get_central_config().get_arjuna_option_value(ArjunaOption.DATA_SOURCES_DIR).as_str() if file_utils.is_absolute_path(self.path): if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path)) else: self.path = os.path.abspath(os.path.join(data_dir, self.path)) if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path))
def load_session(self, session_name): from arjuna.tpi import Arjuna from arjuna.unitee.test.defs.session import UserDefinedSessionDef sdir = Arjuna.get_central_config().get_arjuna_option_value( ArjunaOption.UNITEE_PROJECT_SESSIONS_DIR).as_str() session_file_path = os.path.join(sdir, session_name + ".xml") if not file_utils.is_file(session_file_path): Arjuna.get_console().display_error( "Not able to find session file {}.xml at {}".format( session_name, sdir)) sys_utils.fexit() sdef = UserDefinedSessionDef(session_name, session_file_path) sdef.process() self.__session = sdef.pick() self.__session.context = self.__create_test_context() self.__session.load()
def get_arjuna_project_path_and_name(fpath): from arjuna.core.utils import file_utils if not file_utils.is_absolute_path(fpath): fpath = os.path.abspath(os.path.join(project_root_dir, fpath)) if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception( "The Linked Arjuna Project path is a file. It should be a directory: {}" .format(fpath)) else: raise Exception( "The Linked Arjuna Project path does not exist: {}". format(fpath)) else: if not os.path.exists( os.path.join(fpath, "script", "arjuna_launcher.py")): raise Exception( "The Linked Arjuna Project path exists but is not an Arjuna test project: {}" .format(fpath)) return os.path.basename(fpath), fpath, os.path.abspath(fpath + "/..")