I made a patch to make proxy configurable for weather applet, but my calender also need it.
So it's better to add a global proxy configuration for all applets who require network access.
# Counts the number of minutes until the next attempted fetch.
countdown = 0
+
+ # HTTP Proxy switch can proxy
+ proxy = False
+ http_proxy = "http://"
I made a patch to make proxy configurable for weather applet, but my calender also need it.
So it's better to add a global proxy configuration for all applets who require network access.
diff -uNr weather. orig/weathercon fig.py weather/ weatherconfig. py orig/weathercon fig.py 2009-01-12 20:36:29.000000000 +0800 weatherconfig. py 2009-01-12 16:39:43.000000000 +0800 connect( "clicked" , self.search_button, "search") pack_start( hbox2,True, False,2)
--- weather.
+++ weather/
@@ -212,6 +212,24 @@
search.
vbox.
+ # proxy settings (_("HTTP Proxy")) checkbox. set_active( True) editor. set_sensitive( True) editor. set_text( applet. http_proxy) checkbox. set_active( False) editor. set_sensitive( False) start(self. proxy_checkbox, True,False, 0) end(self. proxy_editor) checkbox. connect( "toggled" , self.proxy_cb, "proxy") start(hbox5, True,False, 0) stock=gtk. STOCK_OK) "clicked" , self.ok_button, "ok") applet. gconf_client. set_int( self.applet. gconf_path + "/temp_position", self.temp_ pos.get_ active( )) applet. gconf_client. set_bool( self.applet. gconf_path + "/open_ til_clicked" , self.click_ checkbox. get_active( )) applet. gconf_client. set_bool( self.applet. gconf_path + "/curved_dialog", self.click_ checkbox2. get_active( )) gconf_client. set_bool( self.applet. gconf_path + "/proxy", self.proxy_ checkbox. get_active( )) gconf_client. set_string( self.applet. gconf_path + "/http_proxy", self.proxy_ editor. get_text( ))
+ self.proxy_checkbox = gtk.CheckButton
+ # enable proxy editor
+ self.proxy_editor = gtk.Entry()
+ if applet.proxy:
+ self.proxy_
+ self.proxy_
+ self.proxy_
+ else:
+ self.proxy_
+ self.proxy_
+ hbox5 = gtk.HBox(True,0)
+ hbox5.pack_
+ hbox5.pack_
+ self.proxy_
+ vbox.pack_
+
+ # ok/cancel button
hbox4 = gtk.HBox(True, 0)
ok = gtk.Button(
ok.connect(
@@ -242,7 +260,16 @@
self.
self.
self.
+ self.applet.
+ self.applet.
self.destroy()
def cancel_button(self, widget, event): checkbox. get_active( ): editor. set_sensitive( True) editor. set_text( self.applet. http_proxy) editor. set_sensitive( False) orig/weather. py weather/weather.py orig/weather. py 2009-01-13 19:29:06.000000000 +0800
self.destroy()
+
+ def proxy_cb(self, widget, event):
+ if self.proxy_
+ self.proxy_
+ self.proxy_
+ else:
+ self.proxy_
diff -uNr weather.
--- weather.
+++ weather/weather.py 2009-01-12 16:34:37.000000000 +0800
@@ -98,6 +98,10 @@
# Counts the number of minutes until the next attempted fetch.
countdown = 0
+
+ # HTTP Proxy switch can proxy
+ proxy = False
+ http_proxy = "http://"
def __init__(self, uid, orient, height): AppletSimple. __init_ _ (self, uid, orient, height) curved_ dialog = self.gconf_ client. get_bool( self.gconf_ path + "/curved_dialog") gconf_client. set_bool( self.gconf_ path + "/curved_dialog", self.curved_dialog) client. get_bool( self.gconf_ path + "/proxy") client. set_bool( self.gconf_ path + "/proxy", self.proxy) client. get_string( self.gconf_ path + "/http_proxy") client. set_string( self.gconf_ path + "/http_proxy", "http://")
awn.
@@ -207,6 +211,14 @@
# Curved Look
self.
self.
+
+ # HTTP Proxy
+ self.proxy = self.gconf_
+ self.gconf_
+ self.http_proxy = self.gconf_
+ if self.http_proxy == None:
+ self.gconf_
+
return True
@@ -319,7 +331,11 @@ parse(usock) getElementsByTa gName(' weather' )[0] parse(usock) getElementsByTa gName(' loc')[0] www.weather. com/outlook/ travel/ businesstravele r/map/' + self.location_code) www.weather. com/outlook/ travel/ businesstravele r/map/' + self.location_code, proxies=proxies) ".*[iI] [fF][rR] [aA][mM] [eE].*" ) src_start+ 5 : frame_src_end] www.weather. com' + frame_src) www.weather. com' + frame_src, proxies=proxies) ".*[iI] [mM][gG] [nN][aA] [mM][eE] =\"mapImg\ ".*")
if self.units == "Metric":
url = url + '&unit=m'
try:
- usock = urllib.urlopen(url)
+ if self.proxy:
+ proxies = {'http': self.http_proxy}
+ else:
+ proxies = {}
+ usock = urllib.urlopen(url, proxies=proxies)
xmldoc = minidom.
usock.close()
weather_n = xmldoc.
@@ -375,7 +391,11 @@
if self.units == "Metric":
url = url + '&unit=m'
try:
- usock = urllib.urlopen(url)
+ if self.proxy:
+ proxies = {'http': self.http_proxy}
+ else:
+ proxies = {}
+ usock = urllib.urlopen(url, proxies=proxies)
xmldoc = minidom.
usock.close()
location_n = xmldoc.
@@ -421,7 +441,11 @@
if self.map != "":
old_map = self.map
try:
- usock = urllib.urlopen('http://
+ if self.proxy:
+ proxies = {'http': self.http_proxy}
+ else:
+ proxies = {}
+ usock = urllib.urlopen('http://
lines = usock.readlines()
iframe_re = re.compile(
for line in lines:
@@ -430,7 +454,7 @@
frame_src_end = line.find("?")
if frame_src_start > -1 and frame_src_end > -1:
frame_src = line[frame_
- usock2 = urllib.urlopen('http://
+ usock2 = urllib.urlopen('http://
frame_lines = usock2.readlines()
img_re = re.compile(
for frame_line in frame_lines: