mambatray.py: remove obsolete code for setting proxy for smart and more code cleanups
This commit is contained in:
parent
bc1b15a666
commit
ee9bf1f12b
38
mambatray.py
38
mambatray.py
@ -7,12 +7,10 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import gettext
|
import gettext
|
||||||
import libproxy
|
|
||||||
import distro
|
import distro
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon, QCursor
|
from PyQt5.QtGui import QIcon, QCursor
|
||||||
from PyQt5.QtWidgets import QSystemTrayIcon, QApplication, QMenu, QMainWindow,\
|
from PyQt5.QtWidgets import QSystemTrayIcon, QApplication, QMenu, QMessageBox
|
||||||
QMessageBox
|
|
||||||
from PyQt5.QtCore import QTimer, QProcess
|
from PyQt5.QtCore import QTimer, QProcess
|
||||||
|
|
||||||
DATADIR = os.path.dirname(os.path.realpath((__file__))) + "/"
|
DATADIR = os.path.dirname(os.path.realpath((__file__))) + "/"
|
||||||
@ -114,20 +112,6 @@ class SystemTrayIcon(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 = QProcess(self)
|
|
||||||
pf = libproxy.ProxyFactory()
|
|
||||||
for protocol in ["http","https","ftp"]:
|
|
||||||
proxies = pf.getProxies("%s://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 (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick, QSystemTrayIcon.Context):
|
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick, QSystemTrayIcon.Context):
|
||||||
self.contextMenu().popup(QCursor.pos())
|
self.contextMenu().popup(QCursor.pos())
|
||||||
@ -151,15 +135,12 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x'])
|
return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x'])
|
||||||
|
|
||||||
def softwareManager(self):
|
def softwareManager(self):
|
||||||
#self.setProxyForSmart()
|
|
||||||
softwareManagerProcess.execute("/usr/bin/plasma-discover")
|
softwareManagerProcess.execute("/usr/bin/plasma-discover")
|
||||||
|
|
||||||
def softwareCheckUpgrades(self):
|
def softwareCheckUpgrades(self):
|
||||||
#self.setProxyForSmart()
|
|
||||||
softwareCheckUpgradesProcess.start("/usr/bin/pkcon", ['refresh', 'force'])
|
softwareCheckUpgradesProcess.start("/usr/bin/pkcon", ['refresh', 'force'])
|
||||||
|
|
||||||
def refreshPackagesCache(self):
|
def refreshPackagesCache(self):
|
||||||
#self.setProxyForSmart()
|
|
||||||
refreshPackagesTimer.stop()
|
refreshPackagesTimer.stop()
|
||||||
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh', 'force'])
|
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh', 'force'])
|
||||||
|
|
||||||
@ -201,7 +182,6 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", list(set(['proxy'])))
|
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", 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()
|
||||||
@ -209,7 +189,7 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
if (self.networkOnline() == 0):
|
if (self.networkOnline() == 0):
|
||||||
try:
|
try:
|
||||||
SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]])
|
SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]])
|
||||||
except: #supera il limite dell'indice nella lista
|
except:
|
||||||
contatore = 0
|
contatore = 0
|
||||||
if NetsrpmsArg == '-c':
|
if NetsrpmsArg == '-c':
|
||||||
self.SRPMSAskAndInstall()
|
self.SRPMSAskAndInstall()
|
||||||
@ -218,7 +198,7 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
NetsrpmsArg = '-c'
|
NetsrpmsArg = '-c'
|
||||||
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
|
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
|
||||||
|
|
||||||
#viene eseguita per ogni SRPM al termine del processo SRPMUpdateProcess
|
# run for each netsrpm at the end of SRPMUpdateProcess
|
||||||
def SRPMSCheckUpgrade(self, status):
|
def SRPMSCheckUpgrade(self, status):
|
||||||
global contatore, lista
|
global contatore, lista
|
||||||
if status == 1:
|
if status == 1:
|
||||||
@ -226,13 +206,16 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
contatore += 1
|
contatore += 1
|
||||||
self.SRPMSCheckUpgradeList()
|
self.SRPMSCheckUpgradeList()
|
||||||
|
|
||||||
#viene eseguita una volta terminata la fase di controllo degli aggiornamenti
|
# netsrpm updates ask and install
|
||||||
def SRPMSAskAndInstall(self):
|
def SRPMSAskAndInstall(self):
|
||||||
global NetsrpmsArg, lista
|
global NetsrpmsArg, lista
|
||||||
if not lista == []:
|
if not lista == []:
|
||||||
Lista = self.Lista()
|
Lista = self.Lista()
|
||||||
msg = QMessageBox.question(self.menu,(_("Not Open Source {} components").format(distro.name())),
|
msg = QMessageBox.question(self.menu,
|
||||||
(_("The following components are available for update: ") + "\n\n" + Lista + "\n\n" + _("Ok to proceed?")), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
|
(_("Not Open Source {} components").format(distro.name())),
|
||||||
|
(_("The following components are available for update: ") +
|
||||||
|
"\n\n" + Lista + "\n\n" + _("Ok to proceed?")),
|
||||||
|
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
|
||||||
if msg == QMessageBox.Yes:
|
if msg == QMessageBox.Yes:
|
||||||
NetsrpmsArg = '-u'
|
NetsrpmsArg = '-u'
|
||||||
self.SRPMSCheckUpgradeList()
|
self.SRPMSCheckUpgradeList()
|
||||||
@ -242,7 +225,8 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
else:
|
else:
|
||||||
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
|
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
|
||||||
|
|
||||||
#partendo dalla lista lista (scusate il gioco di parole :) ) restituisce la lista in modo 'leggibile'
|
# starting from the list "lista" returns the list in readable format
|
||||||
|
# FIXME: make this code more clear and clean
|
||||||
def Lista(self):
|
def Lista(self):
|
||||||
testo = ''
|
testo = ''
|
||||||
for a in lista:
|
for a in lista:
|
||||||
|
Loading…
Reference in New Issue
Block a user