<s> import os <EOL> from wlauto import Workload , Parameter <EOL> from wlauto . exceptions import ConfigError <EOL> class ShellScript ( Workload ) : <EOL> name = '<STR_LIT>' <EOL> description = """<STR_LIT>""" <EOL> parameters = [ <EOL> Parameter ( '<STR_LIT>' , mandatory = True , <EOL> description = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) , <EOL> Parameter ( '<STR_LIT>' , default = '<STR_LIT>' , <EOL> description = '<STR_LIT>' ) , <EOL> Parameter ( '<STR_LIT>' , kind = int , default = <NUM_LIT> , <EOL> description = '<STR_LIT>' ) , <EOL> ] <EOL> def __init__ ( self , device , ** kwargs ) : <EOL> super ( ShellScript , self ) . __init__ ( device , ** kwargs ) <EOL> self . script_file = os . path . expanduser ( self . script_file ) <EOL> if not os . path . isfile ( self . script_file ) : <EOL> raise ConfigError ( '<STR_LIT>' . format ( self . script_file ) ) <EOL> self . output = None <EOL> self . command = None <EOL> self . on_device_script_file = None <EOL> def setup ( self , context ) : <EOL> self . on_device_script_file = self . device . path . join ( self . device . working_directory , <EOL> os . path . basename ( self . script_file ) ) <EOL> self . device . push_file ( self . script_file , self . on_device_script_file ) <EOL> self . command = '<STR_LIT>' . format ( self . on_device_script_file , self . argstring ) <EOL> def run ( self , context ) : <EOL> self . output = self . device . execute ( self . command , timeout = self . timeout ) <EOL> def update_result ( self , context ) : <EOL> with open ( os . path . join ( context . output_directory , '<STR_LIT>' ) , '<STR_LIT:w>' ) as wfh : <EOL> wfh . write ( self . output ) <EOL> def teardown ( self , context ) : <EOL> self . device . delete_file ( self . on_device_script_file ) </s>
