How to use _get_rw_dir method in avocado

Best Python code snippet using avocado_python

data_dir.py

Source:data_dir.py Github

copy

Full Screen

...48 """49 Returns a given "datadir" directory as set by the configuration system50 """51 return settings.settings.get_value('datadir.paths', dir_name, 'path')52def _get_rw_dir(settings_location, system_location, user_location):53 if utils_path.usable_rw_dir(settings_location):54 return settings_location55 if utils_path.usable_rw_dir(system_location):56 return system_location57 user_location = os.path.expanduser(user_location)58 if utils_path.usable_rw_dir(user_location):59 return user_location60def get_base_dir():61 """62 Get the most appropriate base dir.63 The base dir is the parent location for most of the avocado other64 important directories.65 Examples:66 * Log directory67 * Data directory68 * Tests directory69 """70 return _get_rw_dir(_get_settings_dir('base_dir'),71 SYSTEM_BASE_DIR, USER_BASE_DIR)72def get_test_dir():73 """74 Get the most appropriate test location.75 The test location is where we store tests written with the avocado API.76 The heuristics used to determine the test dir are:77 1) If an explicit test dir is set in the configuration system, it78 is used.79 2) If user is running Avocado out of the source tree, the example80 test dir is used81 3) System wide test dir is used82 4) User default test dir (~/avocado/tests) is used83 """84 configured = _get_settings_dir('test_dir')85 if utils_path.usable_ro_dir(configured):86 return configured87 if settings.settings.intree:88 return _IN_TREE_TESTS_DIR89 if utils_path.usable_ro_dir(SYSTEM_TEST_DIR):90 return SYSTEM_TEST_DIR91 if utils_path.usable_ro_dir(USER_TEST_DIR):92 return USER_TEST_DIR93def get_data_dir():94 """95 Get the most appropriate data dir location.96 The data dir is the location where any data necessary to job and test97 operations are located.98 Examples:99 * ISO files100 * GPG files101 * VM images102 * Reference bitmaps103 """104 return _get_rw_dir(_get_settings_dir('data_dir'),105 SYSTEM_DATA_DIR, USER_DATA_DIR)106def get_datafile_path(*args):107 """108 Get a path relative to the data dir.109 :param args: Arguments passed to os.path.join. Ex ('images', 'jeos.qcow2')110 """111 new_args = tuple([get_data_dir()] + list(args))112 return os.path.join(*new_args)113def get_logs_dir():114 """115 Get the most appropriate log dir location.116 The log dir is where we store job/test logs in general.117 """118 return _get_rw_dir(_get_settings_dir('logs_dir'),119 SYSTEM_LOG_DIR, USER_LOG_DIR)120def create_job_logs_dir(logdir=None, unique_id=None):121 """122 Create a log directory for a job, or a stand alone execution of a test.123 :param logdir: Base log directory, if `None`, use value from configuration.124 :param unique_id: The unique identification. If `None`, create one.125 :rtype: basestring126 """127 start_time = time.strftime('%Y-%m-%dT%H.%M')128 if logdir is None:129 logdir = get_logs_dir()130 if not os.path.exists(logdir):131 utils_path.init_dir(logdir)132 # Stand alone tests handling...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful