From ee9bf1f12beb247bc8e9135d721d63192d76494e Mon Sep 17 00:00:00 2001 From: Silvan Date: Sun, 25 Feb 2024 15:39:30 +0100 Subject: [PATCH] mambatray.py: remove obsolete code for setting proxy for smart and more code cleanups --- mambatray.py | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/mambatray.py b/mambatray.py index 91fc55b..d320f5a 100755 --- a/mambatray.py +++ b/mambatray.py @@ -7,12 +7,10 @@ import sys import os import gettext -import libproxy import distro from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon, QCursor -from PyQt5.QtWidgets import QSystemTrayIcon, QApplication, QMenu, QMainWindow,\ - QMessageBox +from PyQt5.QtWidgets import QSystemTrayIcon, QApplication, QMenu, QMessageBox from PyQt5.QtCore import QTimer, QProcess 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 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): if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick, QSystemTrayIcon.Context): self.contextMenu().popup(QCursor.pos()) @@ -151,15 +135,12 @@ class SystemTrayIcon(QSystemTrayIcon): return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x']) def softwareManager(self): - #self.setProxyForSmart() softwareManagerProcess.execute("/usr/bin/plasma-discover") def softwareCheckUpgrades(self): - #self.setProxyForSmart() softwareCheckUpgradesProcess.start("/usr/bin/pkcon", ['refresh', 'force']) def refreshPackagesCache(self): - #self.setProxyForSmart() refreshPackagesTimer.stop() refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh', 'force']) @@ -201,7 +182,6 @@ class SystemTrayIcon(QSystemTrayIcon): networkProxyProcess.execute("/opt/kde/bin/kcmshell4", list(set(['proxy']))) elif desktop_session == 'gnome': networkProxyProcess.execute("/usr/bin/gnome-control-center", "network") - #self.setProxyForSmart() def SRPMSCheckUpgradeList(self): checkSRPMSUpdatesTimer.stop() @@ -209,7 +189,7 @@ class SystemTrayIcon(QSystemTrayIcon): if (self.networkOnline() == 0): try: SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]]) - except: #supera il limite dell'indice nella lista + except: contatore = 0 if NetsrpmsArg == '-c': self.SRPMSAskAndInstall() @@ -218,7 +198,7 @@ class SystemTrayIcon(QSystemTrayIcon): NetsrpmsArg = '-c' 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): global contatore, lista if status == 1: @@ -226,13 +206,16 @@ class SystemTrayIcon(QSystemTrayIcon): contatore += 1 self.SRPMSCheckUpgradeList() - #viene eseguita una volta terminata la fase di controllo degli aggiornamenti + # netsrpm updates ask and install def SRPMSAskAndInstall(self): global NetsrpmsArg, lista if not lista == []: Lista = self.Lista() - msg = QMessageBox.question(self.menu,(_("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) + msg = QMessageBox.question(self.menu, + (_("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: NetsrpmsArg = '-u' self.SRPMSCheckUpgradeList() @@ -242,7 +225,8 @@ class SystemTrayIcon(QSystemTrayIcon): else: 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): testo = '' for a in lista: