mambatray: configure smart through libproxy (requires python-libproxy)
This commit is contained in:
parent
77e45e4e2b
commit
cac69a870d
@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# mambatray2
|
# mambatray 2
|
||||||
# Copyright (C) 2011 by Silvan Calarco
|
# Copyright (C) 2011-2013 by Silvan Calarco
|
||||||
# Copyright (C) 2011 by michiamophil
|
# Copyright (C) 2011 by michiamophil
|
||||||
# Distributed under the terms of the GPL version 3 FLOSS License
|
# Distributed under the terms of the GPL version 3 FLOSS License
|
||||||
#
|
#
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import gettext
|
import gettext
|
||||||
|
import libproxy
|
||||||
from PyQt4.QtCore import SIGNAL
|
from PyQt4.QtCore import SIGNAL
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
@ -93,6 +94,19 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
# the first time check for SRPMS updates after 4 minutes
|
# the first time check for SRPMS updates after 4 minutes
|
||||||
checkSRPMSUpdatesTimer.start( 4 * 60000 )
|
checkSRPMSUpdatesTimer.start( 4 * 60000 )
|
||||||
|
|
||||||
|
def setProxyForSmart(self):
|
||||||
|
setProxyProcess = QtCore.QProcess(self)
|
||||||
|
pf = libproxy.ProxyFactory()
|
||||||
|
for protocol in ["http","https","ftp"]:
|
||||||
|
proxies = pf.getProxies("%s://www.openmamba.org" % protocol)
|
||||||
|
for proxy in proxies:
|
||||||
|
if proxy == "direct://":
|
||||||
|
setProxyProcess.execute("smart",['config','--remove','%s_proxy' % protocol])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
setProxyProcess.execute("smart",['config','--set','%s_proxy=%s' %(protocol,proxy)])
|
||||||
|
break
|
||||||
|
|
||||||
def iconActivated(self, reason):
|
def iconActivated(self, reason):
|
||||||
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
|
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
|
||||||
menu.popup(self.geometry().center())
|
menu.popup(self.geometry().center())
|
||||||
@ -110,7 +124,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
version = _("Error: Unable to find /etc/openmamba-release")
|
version = _("Error: Unable to find /etc/openmamba-release")
|
||||||
QtGui.QMessageBox.about(menu, _("About"),
|
QtGui.QMessageBox.about(menu, _("About"),
|
||||||
"<center><b>"+_("openmamba control center")+"</b>"
|
"<center><b>"+_("openmamba control center")+"</b>"
|
||||||
"<br><br>Copyright(c) 2011 by Silvan Calarco"
|
"<br><br>Copyright(c) 2011-2013 by Silvan Calarco"
|
||||||
"<br>Copyright(c) 2011 by michiamophil"
|
"<br>Copyright(c) 2011 by michiamophil"
|
||||||
"<br><br><b>"+_("System info:")+"</b></center>"
|
"<br><br><b>"+_("System info:")+"</b></center>"
|
||||||
""+_(version)+"<center><a href=\"http://www.openmamba.org\">http://www.openmamba.org</a></center>")
|
""+_(version)+"<center><a href=\"http://www.openmamba.org\">http://www.openmamba.org</a></center>")
|
||||||
@ -125,17 +139,21 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def softwareManager(self):
|
def softwareManager(self):
|
||||||
|
self.setProxyForSmart()
|
||||||
if desktop_session == 'kde':
|
if desktop_session == 'kde':
|
||||||
softwareManagerProcess.execute("/opt/kde/bin/apper")
|
softwareManagerProcess.execute("/opt/kde/bin/apper")
|
||||||
else:
|
else:
|
||||||
softwareManagerProcess.execute("/usr/bin/gpk-application")
|
softwareManagerProcess.execute("/usr/bin/gpk-application")
|
||||||
|
|
||||||
def softwareCheckUpgrades(self):
|
def softwareCheckUpgrades(self):
|
||||||
|
self.setProxyForSmart()
|
||||||
if desktop_session == 'kde':
|
if desktop_session == 'kde':
|
||||||
softwareCheckUpgradesProcess.start("/opt/kde/bin/apper", ['--updates'])
|
softwareCheckUpgradesProcess.start("/opt/kde/bin/apper", ['--updates'])
|
||||||
else:
|
else:
|
||||||
softwareCheckUpgradesProcess.start("/usr/bin/gpk-update-viewer")
|
softwareCheckUpgradesProcess.start("/usr/bin/gpk-update-viewer")
|
||||||
|
|
||||||
def refreshPackagesCache(self):
|
def refreshPackagesCache(self):
|
||||||
|
self.setProxyForSmart()
|
||||||
refreshPackagesTimer.stop()
|
refreshPackagesTimer.stop()
|
||||||
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh'])
|
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh'])
|
||||||
|
|
||||||
@ -176,6 +194,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", QtCore.QStringList(list(set(['proxy']))))
|
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", QtCore.QStringList(list(set(['proxy']))))
|
||||||
elif desktop_session == 'gnome':
|
elif desktop_session == 'gnome':
|
||||||
networkProxyProcess.execute("/usr/bin/gnome-control-center", "network")
|
networkProxyProcess.execute("/usr/bin/gnome-control-center", "network")
|
||||||
|
self.setProxyForSmart()
|
||||||
|
|
||||||
def SRPMSCheckUpgradeList(self):
|
def SRPMSCheckUpgradeList(self):
|
||||||
checkSRPMSUpdatesTimer.stop()
|
checkSRPMSUpdatesTimer.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user