How to use check_for_remote_file method in avocado

Best Python code snippet using avocado_python

distro.py

Source:distro.py Github

copy

Full Screen

...96 CHECK_VERSION_REGEX = None97 def __init__(self, session=None):98 self.score = 099 self.session = session100 def check_for_remote_file(self, file_name):101 """102 Checks if provided file exists in remote machine103 :param file_name: name of file104 :type file_name: str105 :returns: whether the file exists in remote machine or not106 :rtype: bool107 """108 if self.session and self.session.cmd("test -f %s" % file_name).exit_status == 0:109 return True110 else:111 return False112 def check_name_for_file(self):113 """114 Checks if this class will look for a file and return a distro115 The conditions that must be true include the file that identifies the116 distro file being set (:attr:`CHECK_FILE`) and the name of the117 distro to be returned (:attr:`CHECK_FILE_DISTRO_NAME`)118 """119 if self.CHECK_FILE is None:120 return False121 if self.CHECK_FILE_DISTRO_NAME is None:122 return False123 return True124 def name_for_file(self):125 """126 Get the distro name if the :attr:`CHECK_FILE` is set and exists127 """128 if self.check_name_for_file():129 if self.check_for_remote_file(self.CHECK_FILE):130 return self.CHECK_FILE_DISTRO_NAME131 elif os.path.exists(self.CHECK_FILE):132 return self.CHECK_FILE_DISTRO_NAME133 def check_name_for_file_contains(self):134 """135 Checks if this class will look for text on a file and return a distro136 The conditions that must be true include the file that identifies the137 distro file being set (:attr:`CHECK_FILE`), the text to look for138 inside the distro file (:attr:`CHECK_FILE_CONTAINS`) and the name139 of the distro to be returned (:attr:`CHECK_FILE_DISTRO_NAME`)140 """141 if self.CHECK_FILE is None:142 return False143 if self.CHECK_FILE_CONTAINS is None:144 return False145 if self.CHECK_FILE_DISTRO_NAME is None:146 return False147 return True148 def name_for_file_contains(self):149 """150 Get the distro if the :attr:`CHECK_FILE` is set and has content151 """152 if self.check_name_for_file_contains():153 check_file = None154 if self.check_for_remote_file(self.CHECK_FILE):155 check_file = self.session.cmd("cat %s" % self.CHECK_FILE).stdout_text.split('/n')156 elif os.path.exists(self.CHECK_FILE):157 try:158 check_file = open(self.CHECK_FILE, encoding='utf-8')159 except IOError as err:160 LOGGER.debug("Could not open %s", self.CHECK_FILE)161 LOGGER.debug("Exception: %s", str(err))162 return None163 if not check_file:164 return None165 for line in check_file:166 if self.CHECK_FILE_CONTAINS in line:167 return self.CHECK_FILE_DISTRO_NAME168 def check_version(self):...

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