<s> import os <EOL> import time <EOL> import urllib <EOL> from wlauto import settings , Workload , Parameter <EOL> from wlauto . exceptions import ConfigError <EOL> from wlauto . utils . types import boolean <EOL> DEFAULT_AUDIO_FILE_URL = "<STR_LIT>" <EOL> class Audio ( Workload ) : <EOL> name = '<STR_LIT>' <EOL> description = """<STR_LIT>""" <EOL> supported_platforms = [ '<STR_LIT>' ] <EOL> parameters = [ <EOL> Parameter ( '<STR_LIT>' , kind = int , default = <NUM_LIT:30> , <EOL> description = '<STR_LIT>' ) , <EOL> Parameter ( '<STR_LIT>' , default = os . path . join ( settings . dependencies_directory , '<STR_LIT>' ) , <EOL> description = '''<STR_LIT>''' ) , <EOL> Parameter ( '<STR_LIT>' , kind = boolean , default = False , <EOL> description = '<STR_LIT>' ) , <EOL> Parameter ( '<STR_LIT>' , kind = boolean , default = True , <EOL> description = '<STR_LIT>' ) <EOL> ] <EOL> def init_resources ( self , context ) : <EOL> if not os . path . isfile ( self . audio_file ) : <EOL> self . _download_audio_file ( ) <EOL> def setup ( self , context ) : <EOL> self . on_device_file = os . path . join ( self . device . working_directory , <EOL> os . path . basename ( self . audio_file ) ) <EOL> self . device . push_file ( self . audio_file , self . on_device_file , timeout = <NUM_LIT> ) <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . device . clear_logcat ( ) <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> if self . clear_file_cache : <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> self . device . set_sysfile_value ( '<STR_LIT>' , <NUM_LIT:3> ) <EOL> self . device . execute ( '<STR_LIT>' . format ( self . on_device_file ) ) <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> def run ( self , context ) : <EOL> time . sleep ( self . duration ) <EOL> def update_result ( self , context ) : <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> self . device . execute ( '<STR_LIT>' ) <EOL> def teardown ( self , context ) : <EOL> if self . perform_cleanup : <EOL> self . device . delete_file ( self . on_device_file ) <EOL> def _download_audio_file ( self ) : <EOL> self . logger . debug ( '<STR_LIT>' . format ( DEFAULT_AUDIO_FILE_URL ) ) <EOL> urllib . urlretrieve ( DEFAULT_AUDIO_FILE_URL , self . audio_file ) </s>
