<s> from subprocess import Popen <EOL> from test_common import * <EOL> import urllib . request , urllib . error , urllib . parse , socket , ssl , time , os , signal , json , sys <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> ghostunnel = None <EOL> try : <EOL> root = RootCert ( '<STR_LIT:root>' ) <EOL> root . create_signed_cert ( '<STR_LIT>' ) <EOL> root . create_signed_cert ( '<STR_LIT>' ) <EOL> ghostunnel = run_ghostunnel ( [ '<STR_LIT>' , '<STR_LIT>' . format ( LOCALHOST ) , <EOL> '<STR_LIT>' . format ( LOCALHOST , STATUS_PORT ) , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' . format ( LOCALHOST , STATUS_PORT ) ] ) <EOL> urlopen = lambda path : urllib . request . urlopen ( path , cafile = '<STR_LIT>' ) <EOL> TcpClient ( STATUS_PORT ) . connect ( <NUM_LIT:20> ) <EOL> status = json . loads ( str ( urlopen ( "<STR_LIT>" . format ( LOCALHOST , STATUS_PORT ) ) . read ( ) , '<STR_LIT:utf-8>' ) ) <EOL> metrics = json . loads ( str ( urlopen ( "<STR_LIT>" . format ( LOCALHOST , STATUS_PORT ) ) . read ( ) , '<STR_LIT:utf-8>' ) ) <EOL> if not status [ '<STR_LIT>' ] : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if type ( metrics ) != list : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> os . rename ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ghostunnel . send_signal ( signal . SIGUSR1 ) <EOL> TlsClient ( None , '<STR_LIT:root>' , STATUS_PORT ) . connect ( <NUM_LIT:20> , '<STR_LIT>' ) <EOL> print_ok ( '<STR_LIT>' ) <EOL> status = json . loads ( str ( urlopen ( "<STR_LIT>" . format ( LOCALHOST , STATUS_PORT ) ) . read ( ) , '<STR_LIT:utf-8>' ) ) <EOL> metrics = json . loads ( str ( urlopen ( "<STR_LIT>" . format ( LOCALHOST , STATUS_PORT ) ) . read ( ) , '<STR_LIT:utf-8>' ) ) <EOL> if not status [ '<STR_LIT>' ] : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if type ( metrics ) != list : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> print_ok ( "<STR_LIT:OK>" ) <EOL> finally : <EOL> terminate ( ghostunnel ) </s>
