def setup_connection():
<EOL>try:<EOL><INDENT>con_params = {<EOL>'<STR_LIT:username>': os.getenv('<STR_LIT>') or cfg.get('<STR_LIT>', '<STR_LIT:username>'),<EOL>'<STR_LIT:password>': os.getenv('<STR_LIT>') or cfg.get('<STR_LIT>', '<STR_LIT:password>'),<EOL>'<STR_LIT>': os.getenv('<STR_LIT>') or cfg.get('<STR_LIT>', '<STR_LIT>'),<EOL>'<STR_LIT:port>'    : os.getenv('<STR_LIT>') or cfg.get('<STR_LIT>', '<STR_LIT:port>')<EOL>}<EOL><DEDENT>except (configparser.NoOptionError, configparser.NoSectionError) as exc:<EOL><INDENT>print("<STR_LIT>", str(exc), file=sys.stderr)<EOL>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if con_params['<STR_LIT:password>'] is None:<EOL><INDENT>import getpass<EOL>con_params['<STR_LIT:password>'] = getpass.getpass()<EOL><DEDENT>pynipap.xmlrpc_uri = "<STR_LIT>" % con_params<EOL>ao = pynipap.AuthOptions({<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:username>': os.getenv('<STR_LIT>') or con_params['<STR_LIT:username>'],<EOL>'<STR_LIT>': os.getenv('<STR_LIT>'),<EOL>})<EOL>
Set up the global pynipap connection object