<s> from atc_thrift import Atcd <EOL> from atc_thrift . ttypes import TrafficControl <EOL> from thrift . protocol import TBinaryProtocol <EOL> from thrift . transport import TSocket , TTransport <EOL> from atc_thrift . ttypes import Shaping <EOL> from atc_thrift . ttypes import TrafficControlledDevice <EOL> from atc_thrift . ttypes import TrafficControlSetting <EOL> import argparse <EOL> def getAtcClient ( ) : <EOL> transport = TSocket . TSocket ( '<STR_LIT:localhost>' , <NUM_LIT> ) <EOL> transport = TTransport . TFramedTransport ( transport ) <EOL> transport . open ( ) <EOL> protocol = TBinaryProtocol . TBinaryProtocol ( transport ) <EOL> return Atcd . Client ( protocol ) <EOL> def parse_arguments ( ) : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> return parser . parse_args ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> options = parse_arguments ( ) <EOL> client = getAtcClient ( ) <EOL> dev = TrafficControlledDevice ( <EOL> controllingIP = options . controlling_ip , <EOL> controlledIP = options . controlling_ip if options . self <EOL> else options . controlled_ip <EOL> ) <EOL> settings = TrafficControlSetting ( <EOL> up = Shaping ( <EOL> rate = <NUM_LIT:100> , <EOL> ) , <EOL> down = Shaping ( <EOL> rate = <NUM_LIT:200> , <EOL> ) , <EOL> ) <EOL> print settings <EOL> tc = TrafficControl ( <EOL> device = dev , <EOL> settings = settings , <EOL> timeout = <NUM_LIT:1000> , <EOL> ) <EOL> print client . startShaping ( tc ) </s>
