Giter VIP home page Giter VIP logo

pypac's Introduction

PyPAC: Proxy auto-config for Python

https://img.shields.io/pypi/v/pypac.svg?maxAge=2592000 https://readthedocs.org/projects/pypac/badge/?version=latest https://img.shields.io/travis/carsonyl/pypac.svg?maxAge=2592000 https://ci.appveyor.com/api/projects/status/y7nxvu2feu87i39t/branch/master?svg=true https://img.shields.io/coveralls/carsonyl/pypac/HEAD.svg?maxAge=2592000 https://img.shields.io/codacy/grade/71ac103b491d44efb94976ca5ea5d89c.svg?maxAge=2592000

PyPAC is a Python library for finding proxy auto-config (PAC) files and making HTTP requests that respect them. PAC files are often used in organizations that need fine-grained and centralized control of proxy settings.

PyPAC provides a subclass of a Requests Session, so you can start using it immediately, with any PAC file transparently discovered and honoured:

>>> from pypac import PACSession
>>> session = PACSession()
>>> session.get('http://example.org')
...

If a PAC file isn't found, then PACSession acts exactly like a regular Session.

PyPAC can find PAC files according to the DNS portion of the Web Proxy Auto-Discovery (WPAD) protocol. On Windows, PyPAC can also obtain the PAC file URL from the Internet Options dialog, via the registry. On macOS, PyPAC can obtain the PAC file URL from System Preferences.

If you're looking to add basic PAC functionality to a library that you're using, try the pac_context_for_url() context manager:

from pypac import pac_context_for_url
import boto3

with pac_context_for_url('https://example.amazonaws.com'):
    client = boto3.client('sqs')
    client.list_queues()

This sets up proxy environment variables at the start of the scope, based on any auto-discovered PAC and the given URL. pac_context_for_url() should work for any library that honours proxy environment variables.

Features

  • The same Requests API that you already know and love
  • Honour PAC setting from Windows Internet Options and macOS System Preferences
  • Follow DNS Web Proxy Auto-Discovery protocol
  • Proxy authentication pass-through
  • Proxy failover and load balancing
  • Generic components for adding PAC support to other code

PyPAC supports Python 2.7 and 3.4+.

Installation

Install PyPAC using pip:

$ pip install pypac

Documentation

PyPAC's documentation is available at http://pypac.readthedocs.io/.

pypac's People

Contributors

aslafy-z avatar carsonyl avatar schlomo avatar sdementen avatar seyfsv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.