<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import platform <EOL> from os import access , F_OK <EOL> from sys import stdout <EOL> from time import sleep <EOL> from subprocess import call <EOL> class HostTestPluginBase : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> type = "<STR_LIT>" <EOL> capabilities = [ ] <EOL> required_parameters = [ ] <EOL> stable = False <EOL> def setup ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def execute ( self , capability , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def is_os_supported ( self , os_name = None ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def print_plugin_error ( self , text ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" % ( self . name , self . type , text ) <EOL> return False <EOL> def print_plugin_info ( self , text , NL = True ) : <EOL> """<STR_LIT>""" <EOL> if NL : <EOL> print "<STR_LIT>" % ( self . name , self . type , text ) <EOL> else : <EOL> print "<STR_LIT>" % ( self . name , self . type , text ) , <EOL> return True <EOL> def print_plugin_char ( self , char ) : <EOL> """<STR_LIT>""" <EOL> stdout . write ( char ) <EOL> stdout . flush ( ) <EOL> return True <EOL> def check_mount_point_ready ( self , destination_disk , init_delay = <NUM_LIT> , loop_delay = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> result = False <EOL> if not access ( destination_disk , F_OK ) : <EOL> self . print_plugin_info ( "<STR_LIT>" % destination_disk , NL = False ) <EOL> sleep ( init_delay ) <EOL> for i in range ( <NUM_LIT:30> ) : <EOL> if access ( destination_disk , F_OK ) : <EOL> result = True <EOL> break <EOL> sleep ( loop_delay ) <EOL> self . print_plugin_char ( '<STR_LIT:.>' ) <EOL> return result <EOL> def check_parameters ( self , capability , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> missing_parameters = [ ] <EOL> for parameter in self . required_parameters : <EOL> if parameter not in kwargs : <EOL> missing_parameters . append ( parameter ) <EOL> if len ( missing_parameters ) : <EOL> self . print_plugin_error ( "<STR_LIT>" % ( '<STR_LIT:U+002CU+0020>' . join ( missing_parameters ) ) ) <EOL> return False <EOL> return True <EOL> def run_command ( self , cmd , shell = True ) : <EOL> """<STR_LIT>""" <EOL> result = True <EOL> try : <EOL> ret = call ( cmd , shell = shell ) <EOL> if ret : <EOL> self . print_plugin_error ( "<STR_LIT>" % ( int ( ret ) , cmd ) ) <EOL> return False <EOL> except Exception as e : <EOL> result = False <EOL> self . print_plugin_error ( "<STR_LIT>" % ( int ( ret ) , cmd ) ) <EOL> self . print_plugin_error ( str ( e ) ) <EOL> return result <EOL> def mbed_os_info ( self ) : <EOL> """<STR_LIT>""" <EOL> result = ( os . name , <EOL> platform . system ( ) , <EOL> platform . release ( ) , <EOL> platform . version ( ) , <EOL> sys . platform ) <EOL> return result <EOL> def mbed_os_support ( self ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> os_info = self . mbed_os_info ( ) <EOL> if ( os_info [ <NUM_LIT:0> ] == '<STR_LIT>' and os_info [ <NUM_LIT:1> ] == '<STR_LIT>' ) : <EOL> result = '<STR_LIT>' <EOL> elif ( os_info [ <NUM_LIT:0> ] == '<STR_LIT>' and os_info [ <NUM_LIT:1> ] == '<STR_LIT>' and ( '<STR_LIT>' in os_info [ <NUM_LIT:3> ] ) ) : <EOL> result = '<STR_LIT>' <EOL> elif ( os_info [ <NUM_LIT:0> ] == '<STR_LIT>' and os_info [ <NUM_LIT:1> ] == '<STR_LIT>' ) : <EOL> result = '<STR_LIT>' <EOL> elif ( os_info [ <NUM_LIT:0> ] == '<STR_LIT>' and os_info [ <NUM_LIT:1> ] == '<STR_LIT>' ) : <EOL> result = '<STR_LIT>' <EOL> return result </s>
