<s> import time <EOL> import os <EOL> import distutils . spawn <EOL> from twisted . python import usage <EOL> from twisted . internet import reactor , threads <EOL> from ooni . templates import process <EOL> from ooni . utils import log <EOL> class JavaNotInstalled ( Exception ) : <EOL> pass <EOL> class CouldNotFindNetalyzrCli ( Exception ) : <EOL> pass <EOL> class UsageOptions ( usage . Options ) : <EOL> optParameters = [ <EOL> [ '<STR_LIT>' , '<STR_LIT:p>' , None , '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] <EOL> ] <EOL> class NetalyzrWrapperTest ( process . ProcessTest ) : <EOL> name = "<STR_LIT>" <EOL> description = "<STR_LIT>" <EOL> author = "<STR_LIT>" <EOL> requiredOptions = [ '<STR_LIT>' ] <EOL> usageOptions = UsageOptions <EOL> requiresRoot = False <EOL> requiresTor = False <EOL> timeout = <NUM_LIT> <EOL> def requirements ( self ) : <EOL> if not distutils . spawn . find_executable ( "<STR_LIT>" ) : <EOL> raise JavaNotInstalled ( "<STR_LIT>" ) <EOL> def setUp ( self ) : <EOL> if not os . path . exists ( self . localOptions [ '<STR_LIT>' ] ) : <EOL> raise CouldNotFindNetalyzrCli ( "<STR_LIT>" . format ( self . localOptions [ '<STR_LIT>' ] ) ) <EOL> self . command = [ <EOL> distutils . spawn . find_executable ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:{}>" . format ( self . localOptions [ '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" <EOL> ] <EOL> def test_run_netalyzr ( self ) : <EOL> """<STR_LIT>""" <EOL> log . msg ( "<STR_LIT>" ) <EOL> log . debug ( "<STR_LIT>" % self . command ) <EOL> self . d = self . run ( self . command , env = os . environ , usePTY = <NUM_LIT:1> ) <EOL> return self . d </s>
