Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _read_conf(self):
conf={}
client=gconf.client_get_default()
if client.get_string(KEYS['version'])==None:
return None
ver=client.get_string(KEYS['version'])
ver=ver.split('.')
ver[0], ver[1], ver[2]=int(ver[0]), int(ver[1]), int(ver[2])
if ver[1]<5:
self._remove_conf(None)
return None
if ver[0]==0:
if ver[1]==5:
if ver[2]==0:
client.set_string(KEYS['template'], DEFAULT['template'])
if ver[2]<=1:
def get_active_opacity(self, type):
client = gconf.client_get_default()
if type == "matches":
return client.get_list("/apps/compiz/general/screen0/options/opacity_matches", gconf.VALUE_STRING)
if type == "values":
return client.get_list("/apps/compiz/general/screen0/options/opacity_values", gconf.VALUE_INT)
def filebrowser_root():
base = u'/apps/gedit-2/plugins/filebrowser/on_load'
client = gconf.client_get_default()
client.add_dir(base, gconf.CLIENT_PRELOAD_NONE)
path = os.path.join(base, u'virtual_root')
val = client.get(path)
if val is not None:
#also read hidden files setting
base = u'/apps/gedit-2/plugins/filebrowser'
client = gconf.client_get_default()
client.add_dir(base, gconf.CLIENT_PRELOAD_NONE)
path = os.path.join(base, u'filter_mode')
try:
fbfilter = client.get(path).get_string()
except AttributeError:
fbfilter = "hidden"
return (val.get_string(), (fbfilter.find("hidden") == -1))
def __set__(self, instance, value):
assert hasattr(value, '__iter__'), 'value of ListOption must be iterable'
gvalues = [gconf.Value(self.list_type) for i in range(len(value))]
for g, v in map(None, gvalues, value):
getattr(g, 'set_%s' % self.list_type.value_nick)(v)
gconf_value = gconf.Value(self.gconf_type)
gconf_value.set_list_type(self.list_type)
self.setter(gconf_value, gvalues)
Option.__set__(self, instance, gconf_value)
class Options(object):
__metaclass__ = OptionsContainerType
_storage = gconf.client_get_default()
def __init__(self):
# create gconf directory if not set yet
if not self._storage.dir_exists(self._uri):
self._storage.add_dir(self._uri, gconf.CLIENT_PRELOAD_NONE)
def __init__(self):
rb.Plugin.__init__(self)
path = os.path.abspath( __file__ )
self.daemon = None
self.cwd = path[:path.rfind("/")]
self.gconf_keys = {
'port' : '/apps/rhythmbox/plugins/rhythmote/port'
}
self.client = gconf.client_get_default()
self.port = self.client.get_string(self.gconf_keys["port"]) or "8484"
def button_toggled(self, widget, data = None):
client = gconf.client_get_default()
if self.get_active():
client.set_bool(data, True)
else:
client.set_bool(data, False)
def __init__(self, post_actions):
self.format = 'json'
self.username = None
self.password = None
self.post_actions = post_actions
self.log = logging.getLogger('TurpialHTTP')
# timeout in seconds
timeout = 20
socket.setdefaulttimeout(timeout)
proxies = {}
if detect_desktop_environment() == 'gnome' and GCONF:
gclient = gconf.client_get_default()
if gclient.get_bool('/system/http_proxy/use_http_proxy'):
proxies['http'] = "%s:%d" % (
gclient.get_string('/system/http_proxy/host'),
gclient.get_int('/system/http_proxy/port'))
if gclient.get_bool('/system/http_proxy/use_same_proxy'):
proxies['https'] = proxies['http']
elif gclient.get_string('/system/proxy/secure_host'):
proxies['https'] = "%s:%d" % (
gclient.get_string('/system/proxy/secure_host'),
gclient.get_int('/system/proxy/secure_port'))
if proxies:
self.log.debug('Proxies detectados: %s' % proxies)
if _py26_or_greater():
opener = urllib2.build_opener(urllib2.ProxyHandler(proxies), urllib2.HTTPHandler)
else:
def get_eddt_root(self):
base = u'/apps/gedit-2/plugins/eddt'
client = gconf.client_get_default()
client.add_dir(base, gconf.CLIENT_PRELOAD_NONE)
path = os.path.join(base, u'repository')
val = client.get(path)
if val is not None:
return self._file_uri_to_filename(val.get_string())
def gconf_get_bool(key, default = False):
val = gconf.client_get_default().get(key)
if val is not None and val.type == gconf.VALUE_BOOL:
return val.get_bool()
else:
return default