Best Python code snippet using autotest_python
remote.py
Source:remote.py
...16 settings.parse_config_file()17 for option, value in settings.config.items('INSTALL_SERVER'):18 server_info[option] = value19 return server_info20def install_server_is_configured():21 server_info = get_install_server_info()22 if server_info.get('xmlrpc_url', None):23 return True24 return False25class RemoteHost(base_classes.Host):26 """27 This class represents a remote machine on which you can run28 programs.29 It may be accessed through a network, a serial line, ...30 It is not the machine autoserv is running on.31 Implementation details:32 This is an abstract class, leaf subclasses must implement the methods33 listed here and in parent classes which have no implementation. They34 may reimplement methods which already have an implementation. You35 must not instantiate this class but should instantiate one of those36 leaf subclasses.37 """38 DEFAULT_REBOOT_TIMEOUT = base_classes.Host.DEFAULT_REBOOT_TIMEOUT39 LAST_BOOT_TAG = object()40 DEFAULT_HALT_TIMEOUT = 2 * 6041 VAR_LOG_MESSAGES_COPY_PATH = "/var/tmp/messages.autotest_start"42 VAR_LOG_MESSAGES_PATHS = ["/var/log/messages", "/var/log/syslog"]43 INSTALL_SERVER_MAPPING = {'cobbler': install_server.CobblerInterface}44 def _initialize(self, hostname, autodir=None, profile='',45 *args, **dargs):46 super(RemoteHost, self)._initialize(*args, **dargs)47 self.hostname = hostname48 self.autodir = autodir49 self.profile = profile50 self.tmp_dirs = []51 def __repr__(self):52 return "<remote host: %s, profile: %s>" % (self.hostname,53 self.profile)54 def close(self):55 super(RemoteHost, self).close()56 self.stop_loggers()57 if hasattr(self, 'tmp_dirs'):58 for dir in self.tmp_dirs:59 try:60 self.run('rm -rf "%s"' % (utils.sh_escape(dir)))61 except error.AutoservRunError:62 pass63 def machine_install(self, profile='', timeout=None):64 """65 Install a profile using the install server.66 :param profile: Profile name inside the install server database.67 """68 if timeout is None:69 timeout = settings.get_value('INSTALL_SERVER',70 'default_install_timeout',71 type=int,72 default=3600)73 server_info = get_install_server_info()74 if install_server_is_configured():75 if not profile:76 profile = self.profile77 if profile in ['Do_not_install', 'N/A']:78 return79 num_attempts = int(server_info.get('num_attempts', 2))80 ServerInterface = self.INSTALL_SERVER_MAPPING[server_info['type']]81 end_time = time.time() + (timeout / 10)82 step = int(timeout / 100)83 server_interface = None84 while time.time() < end_time:85 try:86 server_interface = ServerInterface(**server_info)87 break88 except socket.error:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!