Which Python module to use to access the Proxy setting of Windows 7?

I am new to Python and would like to write a script to change Windows proxy settings based on the network I am connected to. Is there any existing python module I can use? Appreciate your help.

Thanks, Sethu

-------------Problems Reply------------

I would use winreg and query the settings directly from the registry.

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings] "MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"="<local>"

For example, something like:

import _winreg

def getProxy():
proxy = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings")
server, type = _winreg.QueryValueEx(proxy, "ProxyServer")
enabled, type = _winreg.QueryValueEx(proxy, "ProxyEnable")
if enabled:
return server
return None

Cannot you set the HTTP_PROXY environment variable in Windows (either manually or within your program) for your application before sending the request? That should take care that any request you send it via urllib2 goes via Proxy.

Category:python Views:0 Time:2011-08-04

Related post

  • How do I find the location of Python module sources? 2008-11-06

    How do I learn where the source file for a given Python module is installed? Is the method different on Windows than Linux? --------------Solutions------------- For a pure python module you can find the source by looking at themodule.__file__. The da

  • Is there a Python module to access Advantage Database Server? 2009-07-27

    As the title suggest, I was wondering if there is a Python module that can access an Advantage Database Server (Sybase) files such as ADT and DBF. I have searched the web and couldn't find what I'm looking for this is why I wanted to ask it here. ---

  • Is there a python module for regex matching in zip files 2008-08-18

    I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files. Is there any python module which can do a

  • Python module for converting PDF to text 2008-08-25

    Is there any python module to convert PDF files into text? I tried one piece of code found in Activestate which uses pypdf but the text generated had no space between and was of no use. --------------Solutions------------- Try PDFMiner. It can extrac

  • How to avoid computation every time a python module is reloaded 2008-10-12

    I have a python module that makes use of a huge dictionary global variable, currently I put the computation code in the top section, every first time import or reload of the module takes more then one minute which is totally unacceptable. How can I s

  • Invoke Python modules from Java 2009-01-17

    I have a Python interface of a graph library written in C - igraph (the name of library). My need is to invoke the python modules pertaining to this graph library from Java code. It goes like this, the core of library is in c. This core has been impo

  • How can I get a list of locally installed Python modules? 2009-04-11

    I would like to get a list of Python modules, which are in my Python installation (UNIX server). How can you get a list of Python modules installed in your computer? --------------Solutions------------- Solution My 50 cents for getting a pip freeze-l

  • Is there a Python module/recipe (not numpy) for 2d arrays for small games 2009-05-30

    I am writing some small games in Python with Pygame & Pyglet as hobby projects. A class for 2D array would be very handy. I use py2exe to send the games to relatives/friends and numpy is just too big and most of it's features are unnecessary for

  • Storing system-wide DB connection password for a Python module 2010-01-18

    I have a written a Python module which due to its specifics needs to have a MySQL database connection. Right now, details of this connection (host, database, username and password to connect with) are stored in /etc/mymodule.conf in plaintext, which

  • install python modules on shared web hosting 2010-05-29

    I am using a shared hosting environment that will not give me access to the command line. Can I download the python module on my computer, compile it using python setup.py installand then simply upload a .py file to the web host? If yes, where does t

  • Importing Python modules without installing - Sybase ASE 2010-06-08

    I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? Fro

  • Python Module Initialization Order? 2010-06-21

    I am a Python newbie coming from a C++ background. While I know it's not Pythonic to try to find a matching concept using my old C++ knowledge, I think this question is still a general question to ask: Under C++, there is a well known problem called

  • Why do Python modules sometimes not import their sub-modules? 2010-09-23

    I noticed something weird today I would like explained. I wasn't 100% sure how to even phrase this as a question, so google is out of the question. The logging module does not have access to the module logging.handlers for some odd reason. Try it you

  • using python module in java with jython 2010-10-13

    I have a couple of python modules in an existing Python project that I wish to make use of in my Java app. I found an article and followed the steps mentioned there. In particular, I need to import the java interface: package jyinterface.interfaces;

  • How do I use a relative path in a Python module when the CWD has changed? 2010-11-15

    I have a Python module which uses some resources in a subdirectory of the module directory. After searching around on stack overflow and finding related answers, I managed to direct the module to the resources by using something like import os os.pat

  • Python module get top scope variables 2011-02-08

    Hey, in my python modules (written in python) I want to be able to access the variables from the top level scope, that is, the file that is calling the modules. How would I go about doing this? Thanks. --------------Solutions------------- In general,

  • What is the standard Python module for SQL queries? 2011-04-21

    Good afternoon! I am wondering what is the standard Python module for SQL queries? I am writing queries for an Oracle database in particular. I am looking to write quick, easy, and direct queries, in the context of both scripts and small programs. --

  • Can I reliably unimport a Python module if I import it in a namespace? 2011-05-31

    Basically, I have a long running process where I would like to be able to unimport modules and recover memory via the gc. I've read about deleting modules How do I unload (reload) a Python module? and it seems like there are still dangling references

  • Import Python module with PyImport_ImportModuleEx for a gedit plugin 2011-06-01

    I'm learning Python and I try to use Python Markdown in a gedit plugin. Here's how my files are organized: ~/.gnome2/gedit/plugins/mytest.gedit-plugin ~/.gnome2/gedit/plugins/mytest/ ~/.gnome2/gedit/plugins/mytest/__init__.py ~/.gnome2/gedit/plugins/

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.076 (s). 11 q(s)