How to use repo_run_command method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...29 return match.groups()30 else:31 raise error.PackageUploadError(32 "Incorrect SSH path in global_config: %s" % repo)33def repo_run_command(repo, cmd, ignore_status=False, cd=True):34 """Run a command relative to the repos path"""35 repo = repo.strip()36 run_cmd = None37 cd_str = ''38 if repo.startswith('ssh://'):39 username = None40 hostline, remote_path = parse_ssh_path(repo)41 if cd:42 cd_str = 'cd %s && ' % remote_path43 if '@' in hostline:44 username, host = hostline.split('@')45 run_cmd = 'ssh %s@%s "%s%s"' % (username, host, cd_str, cmd)46 else:47 run_cmd = 'ssh %s "%s%s"' % (host, cd_str, cmd)48 else:49 if cd:50 cd_str = 'cd %s && ' % repo51 run_cmd = "%s%s" % (cd_str, cmd)52 if run_cmd:53 return, ignore_status=ignore_status)54def create_directory(repo):55 remote_path = repo56 if repo.startswith('ssh://'):57 _, remote_path = parse_ssh_path(repo)58 repo_run_command(repo, 'mkdir -p %s' % remote_path, cd=False)59def check_diskspace(repo, min_free=None):60 # Note: 1 GB = 10**9 bytes (SI unit).61 if min_free is None:62 min_free = global_config.global_config.get_config_value('PACKAGES',63 'minimum_free_space',64 type=int, default=1)65 try:66 df = repo_run_command(repo,67 'df -PB %d . | tail -1' % 10 ** 9).stdout.split()68 free_space_gb = int(df[3])69 except Exception, e:70 raise error.RepoUnknownError('Unknown Repo Error: %s' % e)71 if free_space_gb < min_free:72 raise error.RepoDiskFullError('Not enough disk space available '73 '%sg < %sg' % (free_space_gb, min_free))74def check_write(repo):75 try:76 repo_testfile = '.repo_test_file'77 repo_run_command(repo, 'touch %s' % repo_testfile).stdout.strip()78 repo_run_command(repo, 'rm ' + repo_testfile)79 except error.CmdError:80 raise error.RepoWriteError('Unable to write to ' + repo)81def trim_custom_directories(repo, older_than_days=None):82 if not repo:83 return84 if older_than_days is None:85 older_than_days = global_config.global_config.get_config_value(86 'PACKAGES', 'custom_max_age', type=int, default=40)87 cmd = 'find . -type f -atime +%s -exec rm -f {} \;' % older_than_days88 repo_run_command(repo, cmd, ignore_status=True)89class RepositoryFetcher(object):90 url = None91 def fetch_pkg_file(self, filename, dest_path):92 """ Fetch a package file from a package repository.93 @param filename: The filename of the package file to fetch.94 @param dest_path: Destination path to download the file to.95 @raises PackageFetchError if the fetch failed96 """97 raise NotImplementedError()98class HttpFetcher(RepositoryFetcher):99 wget_cmd_pattern = 'wget --connect-timeout=15 -nv %s -O %s'100 def __init__(self, package_manager, repository_url):101 """102 @param repository_url: The base URL of the http repository...

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:


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

Run autotest 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?