/usr/share/pyshared/screenlets/plugins/Proxy.py is in screenlets 0.1.2-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # This application is released under the GNU General Public License
# v3 (or, at your option, any later version). You can find the full
# text of the license under http://www.gnu.org/licenses/gpl.txt.
# By using, editing and/or distributing this software you agree to
# the terms and conditions of this license.
# Thank you for using free softwa
# proxy module by Helder Fraga aka whise <helder.fraga@hotmail.com>
import gconf
class Proxy(object):
def __init__(self):
try:
self.gconf_client = gconf.client_get_default()
self.gconf_client.notify_add("/system/http_proxy/use_http_proxy", self.get_is_active)
self.gconf_client.notify_add("/system/http_proxy/port", self.get_port)
self.gconf_client.notify_add("/system/http_proxy/host", self.get_host)
except:pass
self.get_is_active()
self.get_port()
self.get_host()
def get_is_active (self):
"""Returns if the proxy gnome settings are enabled, shoulnt be used separatly"""
try:
a = bool(self.gconf_client.get_bool("/system/http_proxy/use_http_proxy"))
return a
except:
return None
def get_port (self):
"""Returns the proxy gnome settings port, shoulnt be used separatly"""
try:
a = self.gconf_client.get_int("/system/http_proxy/port")
return a
except:
return None
def get_host (self):
"""Returns the proxy gnome settings host, shoulnt be used separatly"""
try:
a = self.gconf_client.get_string("/system/http_proxy/host")
return a
except:
return None
def get_proxy(self):
"""Return {'http' : HOST:PORT } if available or {} if not"""
try:
proxy = {}
if self.get_is_active():
a = self.get_host()
b = self.get_port()
if a != None and b != None:
c = str(a) + ':' + str(b)
if c.find ('http://') == -1: c = 'http://' + c
proxy['http'] = c
return proxy
else: return proxy
except:
return {}
|