<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import unittest <EOL> from SystemConfiguration import * <EOL> class SCPreferences ( object ) : <EOL> """<STR_LIT>""" <EOL> proxy_protocols = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> session = None <EOL> def __init__ ( self ) : <EOL> super ( SCPreferences , self ) . __init__ ( ) <EOL> self . session = SCPreferencesCreate ( None , "<STR_LIT>" , None ) <EOL> def save ( self ) : <EOL> if not self . session : <EOL> return <EOL> if not SCPreferencesCommitChanges ( self . session ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> if not SCPreferencesApplyChanges ( self . session ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> def set_proxy ( self , enable = True , protocol = "<STR_LIT>" , server = "<STR_LIT:localhost>" , port = <NUM_LIT> ) : <EOL> new_settings = SCPreferencesPathGetValue ( self . session , u'<STR_LIT>' ) <EOL> for interface in new_settings : <EOL> new_settings [ interface ] [ '<STR_LIT>' ] [ "<STR_LIT>" % protocol ] = <NUM_LIT:1> if enable else <NUM_LIT:0> <EOL> if enable : <EOL> new_settings [ interface ] [ '<STR_LIT>' ] [ '<STR_LIT>' % protocol ] = int ( port ) <EOL> new_settings [ interface ] [ '<STR_LIT>' ] [ '<STR_LIT>' % protocol ] = server <EOL> SCPreferencesPathSetValue ( self . session , u'<STR_LIT>' , new_settings ) <EOL> class SCPreferencesTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
