I am trying to work on some code for updating google docs using the python gdata api's.
The code works perfectly fine when i try to run the code in a cafe internet or home network without my proxy. When i have to deploy the code in my workplace - it would never work because of the proxy. I understand i have to use urllib2. I tried all different combination's but still no luck.
This is a simple python code that i am using to get all the name of the sheets on a particular account.
try:
from xml.etree import ElementTree
except ImportError:
from elementtree import ElementTree
import gdata.spreadsheet.service
import gdata.service
import atom.service
import gdata.spreadsheet
import atom
import gdata.docs.service
import urllib2, urllib
proxy = urllib2.ProxyHandler({'http': 'http://myproxy:3000'})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
client = gdata.spreadsheet.service.SpreadsheetsService()
client.email = ''
client.password = ''
client.ClientLogin(client.email,client.password)
feed = client.GetDocumentListFeed()
for entry in feed.entry:
entry.title.text
1. What am i doing wrong in specifying the proxy that it should use ? (How can i specify so that i handle my proxy correctly)
2. Is there a mechanism by which i can autodetect the proxy without having to mention it in my code.
Thanks